@@ -6,6 +6,8 @@ var path = require('path')
66var tape = require ( 'tape' )
77var fs = require ( 'fs' )
88
9+ var __PRELOAD_INTEGRITY__ = 'ADDfrBcy5Z/jCgJsnxz75acy+CtquYdLuj+nu8nCaVZtvf9HI2TV08KKH3ZsSwYrkmfzEomyc626T8TlddpyiQ=='
10+
911var bankai = require ( '../' )
1012
1113tape ( 'renders some HTML' , function ( assert ) {
@@ -16,9 +18,9 @@ tape('renders some HTML', function (assert) {
1618 <meta charset="utf-8">
1719 <meta name="viewport" content="width=device-width, initial-scale=1.0">
1820 <script src="https://cdn.polyfill.io/v2/polyfill.min.js" defer></script>
19- <script src="/__HASH__ /bundle.js" defer></script>
20- <link rel="preload" as="style" href="/ebfdda3dbc9e925b /bundle.css" onload="this.rel='stylesheet'">
21- <script>;(function(a){"use strict";var b=function(b,c,d){function e(a){return h.body?a():void setTimeout(function(){e(a)})}function f(){i.addEventListener&&i.removeEventListener("load",f),i.media=d||"all"}var g,h=a.document,i=h.createElement("link");if(c)g=c;else{var j=(h.body||h.getElementsByTagName("head")[0]).childNodes;g=j[j.length-1]}var k=h.styleSheets;i.rel="stylesheet",i.href=b,i.media="only x",e(function(){g.parentNode.insertBefore(i,c?g:g.nextSibling)});var l=function(a){for(var b=i.href,c=k.length;c--;)if(k[c].href===b)return a();setTimeout(function(){l(a)})};return i.addEventListener&&i.addEventListener("load",f),i.onloadcssdefined=l,l(f),i};"undefined"!=typeof exports?exports.loadCSS=b:a.loadCSS=b})("undefined"!=typeof global?global:this);;(function(a){if(a.loadCSS){var b=loadCSS.relpreload={};if(b.support=function(){try{return a.document.createElement("link").relList.supports("preload")}catch(b){return!1}},b.poly=function(){for(var b=a.document.getElementsByTagName("link"),c=0;c<b.length;c++){var d=b[c];"preload"===d.rel&&"style"===d.getAttribute("as")&&(a.loadCSS(d.href,d,d.getAttribute("media")),d.rel=null)}},!b.support()){b.poly();var c=a.setInterval(b.poly,300);a.addEventListener&&a.addEventListener("load",function(){b.poly(),a.clearInterval(c)}),a.attachEvent&&a.attachEvent("onload",function(){a.clearInterval(c)})}}})(this);</script>
21+ <script src="/__SCRIPTS_HASH__ /bundle.js" integrity="sha512-__SCRIPTS_INTEGRITY__ " defer></script>
22+ <link rel="preload" as="style" href="/__STYLE_HASH__ /bundle.css" onload="this.rel='stylesheet'">
23+ <script nomodule integrity="sha512-__PRELOAD_INTEGRITY__">;(function(a){"use strict";var b=function(b,c,d){function e(a){return h.body?a():void setTimeout(function(){e(a)})}function f(){i.addEventListener&&i.removeEventListener("load",f),i.media=d||"all"}var g,h=a.document,i=h.createElement("link");if(c)g=c;else{var j=(h.body||h.getElementsByTagName("head")[0]).childNodes;g=j[j.length-1]}var k=h.styleSheets;i.rel="stylesheet",i.href=b,i.media="only x",e(function(){g.parentNode.insertBefore(i,c?g:g.nextSibling)});var l=function(a){for(var b=i.href,c=k.length;c--;)if(k[c].href===b)return a();setTimeout(function(){l(a)})};return i.addEventListener&&i.addEventListener("load",f),i.onloadcssdefined=l,l(f),i};"undefined"!=typeof exports?exports.loadCSS=b:a.loadCSS=b})("undefined"!=typeof global?global:this);;(function(a){if(a.loadCSS){var b=loadCSS.relpreload={};if(b.support=function(){try{return a.document.createElement("link").relList.supports("preload")}catch(b){return!1}},b.poly=function(){for(var b=a.document.getElementsByTagName("link"),c=0;c<b.length;c++){var d=b[c];"preload"===d.rel&&"style"===d.getAttribute("as")&&(a.loadCSS(d.href,d,d.getAttribute("media")),d.rel=null)}},!b.support()){b.poly();var c=a.setInterval(b.poly,300);a.addEventListener&&a.addEventListener("load",function(){b.poly(),a.clearInterval(c)}),a.attachEvent&&a.attachEvent("onload",function(){a.clearInterval(c)})}}})(this);</script>
2224 <link rel="manifest" href="/manifest.json">
2325 <meta name="description" content=>
2426 <meta name="theme-color" content=#fff>
@@ -48,8 +50,16 @@ tape('renders some HTML', function (assert) {
4850 } )
4951
5052 compiler . scripts ( 'bundle.js' , function ( err , res ) {
51- expected = expected . replace ( '__HASH__' , res . hash )
52- assert . error ( err , 'no error writing script' )
53+ assert . ifError ( err , 'no err bundling scripts' )
54+ expected = expected . replace ( '__SCRIPTS_HASH__' , res . hash . toString ( 'hex' ) . slice ( 0 , 16 ) )
55+ expected = expected . replace ( '__SCRIPTS_INTEGRITY__' , res . hash . toString ( 'base64' ) )
56+
57+ compiler . style ( function ( err , res ) {
58+ assert . ifError ( err , 'no err bundling style' )
59+ expected = expected . replace ( '__STYLE_HASH__' , res . hash . toString ( 'hex' ) . slice ( 0 , 16 ) )
60+ expected = expected . replace ( '__STYLE_INTEGRITY__' , res . hash . toString ( 'base64' ) )
61+ expected = expected . replace ( '__PRELOAD_INTEGRITY__' , __PRELOAD_INTEGRITY__ )
62+ } )
5363 } )
5464} )
5565
@@ -61,9 +71,9 @@ tape('server render choo apps', function (assert) {
6171 <meta charset="utf-8">
6272 <meta name="viewport" content="width=device-width, initial-scale=1.0">
6373 <script src="https://cdn.polyfill.io/v2/polyfill.min.js" defer></script>
64- <script src="/__HASH__ /bundle.js" defer></script>
65- <link rel="preload" as="style" href="/ebfdda3dbc9e925b /bundle.css" onload="this.rel='stylesheet'">
66- <script>;(function(a){"use strict";var b=function(b,c,d){function e(a){return h.body?a():void setTimeout(function(){e(a)})}function f(){i.addEventListener&&i.removeEventListener("load",f),i.media=d||"all"}var g,h=a.document,i=h.createElement("link");if(c)g=c;else{var j=(h.body||h.getElementsByTagName("head")[0]).childNodes;g=j[j.length-1]}var k=h.styleSheets;i.rel="stylesheet",i.href=b,i.media="only x",e(function(){g.parentNode.insertBefore(i,c?g:g.nextSibling)});var l=function(a){for(var b=i.href,c=k.length;c--;)if(k[c].href===b)return a();setTimeout(function(){l(a)})};return i.addEventListener&&i.addEventListener("load",f),i.onloadcssdefined=l,l(f),i};"undefined"!=typeof exports?exports.loadCSS=b:a.loadCSS=b})("undefined"!=typeof global?global:this);;(function(a){if(a.loadCSS){var b=loadCSS.relpreload={};if(b.support=function(){try{return a.document.createElement("link").relList.supports("preload")}catch(b){return!1}},b.poly=function(){for(var b=a.document.getElementsByTagName("link"),c=0;c<b.length;c++){var d=b[c];"preload"===d.rel&&"style"===d.getAttribute("as")&&(a.loadCSS(d.href,d,d.getAttribute("media")),d.rel=null)}},!b.support()){b.poly();var c=a.setInterval(b.poly,300);a.addEventListener&&a.addEventListener("load",function(){b.poly(),a.clearInterval(c)}),a.attachEvent&&a.attachEvent("onload",function(){a.clearInterval(c)})}}})(this);</script>
74+ <script src="/__SCRIPTS_HASH__ /bundle.js" integrity="sha512-__SCRIPTS_INTEGRITY__ " defer></script>
75+ <link rel="preload" as="style" href="/__STYLE_HASH__ /bundle.css" onload="this.rel='stylesheet'">
76+ <script nomodule integrity="sha512-__PRELOAD_INTEGRITY__">;(function(a){"use strict";var b=function(b,c,d){function e(a){return h.body?a():void setTimeout(function(){e(a)})}function f(){i.addEventListener&&i.removeEventListener("load",f),i.media=d||"all"}var g,h=a.document,i=h.createElement("link");if(c)g=c;else{var j=(h.body||h.getElementsByTagName("head")[0]).childNodes;g=j[j.length-1]}var k=h.styleSheets;i.rel="stylesheet",i.href=b,i.media="only x",e(function(){g.parentNode.insertBefore(i,c?g:g.nextSibling)});var l=function(a){for(var b=i.href,c=k.length;c--;)if(k[c].href===b)return a();setTimeout(function(){l(a)})};return i.addEventListener&&i.addEventListener("load",f),i.onloadcssdefined=l,l(f),i};"undefined"!=typeof exports?exports.loadCSS=b:a.loadCSS=b})("undefined"!=typeof global?global:this);;(function(a){if(a.loadCSS){var b=loadCSS.relpreload={};if(b.support=function(){try{return a.document.createElement("link").relList.supports("preload")}catch(b){return!1}},b.poly=function(){for(var b=a.document.getElementsByTagName("link"),c=0;c<b.length;c++){var d=b[c];"preload"===d.rel&&"style"===d.getAttribute("as")&&(a.loadCSS(d.href,d,d.getAttribute("media")),d.rel=null)}},!b.support()){b.poly();var c=a.setInterval(b.poly,300);a.addEventListener&&a.addEventListener("load",function(){b.poly(),a.clearInterval(c)}),a.attachEvent&&a.attachEvent("onload",function(){a.clearInterval(c)})}}})(this);</script>
6777 <link rel="manifest" href="/manifest.json">
6878 <meta name="description" content=>
6979 <meta name="theme-color" content=#fff>
@@ -103,7 +113,15 @@ tape('server render choo apps', function (assert) {
103113 } )
104114
105115 compiler . scripts ( 'bundle.js' , function ( err , res ) {
106- expected = expected . replace ( '__HASH__' , res . hash )
107- assert . error ( err , 'no error writing script' )
116+ assert . ifError ( err , 'no err bundling scripts' )
117+ expected = expected . replace ( '__SCRIPTS_HASH__' , res . hash . toString ( 'hex' ) . slice ( 0 , 16 ) )
118+ expected = expected . replace ( '__SCRIPTS_INTEGRITY__' , res . hash . toString ( 'base64' ) )
119+ compiler . style ( function ( err , res ) {
120+ assert . ifError ( err , 'no err bundling style' )
121+ assert . ifError ( err )
122+ expected = expected . replace ( '__STYLE_HASH__' , res . hash . toString ( 'hex' ) . slice ( 0 , 16 ) )
123+ expected = expected . replace ( '__STYLE_INTEGRITY__' , res . hash . toString ( 'base64' ) )
124+ expected = expected . replace ( '__PRELOAD_INTEGRITY__' , __PRELOAD_INTEGRITY__ )
125+ } )
108126 } )
109127} )
0 commit comments