diff --git a/tools/wave/ecmascript/generate-tests.js b/tools/wave/ecmascript/generate-tests.js index cb0fcdb528..34e0e539b8 100644 --- a/tools/wave/ecmascript/generate-tests.js +++ b/tools/wave/ecmascript/generate-tests.js @@ -63,9 +63,18 @@ const writeFile = async (path, data) => { }; const parseFrontmatter = (src) => { + let sharedArrayBufferTest = false; + + var sharedArrayBuffer = src.indexOf("sharedarraybuffer"); + if (sharedArrayBuffer === -1) { + sharedArrayBufferTest = false; + } else { + sharedArrayBufferTest = true; + } + var start = src.indexOf("/*---"); var end = src.indexOf("---*/"); - if (start === -1 || end === -1) return null; + if (start === -1 || end === -1) return sharedArrayBufferTest; var match, includes = [], @@ -160,6 +169,7 @@ const parseFrontmatter = (src) => { flags: flags, negative: negative, isDynamic: /dynamic-import/.test(frontmatter), + sharedArrayBufferTest: sharedArrayBufferTest }; // lol, do better }; @@ -189,6 +199,8 @@ const generateTest = async ({ currentPath, templateContent, iframeTemplateContent, + headerContent, + headerIFrameContent, }) => { if (!currentPath) currentPath = testsPath; let stats = await readStats(currentPath); @@ -207,6 +219,8 @@ const generateTest = async ({ testsPath, templateContent, iframeTemplateContent, + headerContent, + headerIFrameContent, }); } } else { @@ -217,13 +231,19 @@ const generateTest = async ({ return; } + const jsSrc = await readFile(currentPath); + const meta = parseFrontmatter(jsSrc); + let isSharedArrayBufferTest = meta.sharedArrayBufferTest; + const jsRelativePath = path.relative(testsPath, currentPath); // console.log(jsRelativePath.replace('.js', '')) const jsOutputPath = path.join(outputPath, jsRelativePath); - const htmlOutputPath = jsOutputPath.replace(".js", ".html"); - const iframeHtmlOutputPath = jsOutputPath.replace(".js", ".iframe.html"); - const jsSrc = await readFile(currentPath); - const meta = parseFrontmatter(jsSrc); + const htmlOutputPath = jsOutputPath.replace(".js", isSharedArrayBufferTest == true ? ".https.html" : ".html"); + const iframeHtmlOutputPath = jsOutputPath.replace(".js", isSharedArrayBufferTest == true ? ".iframe.https.html" : ".iframe.html"); + + const htmlOutputHeadersPath = jsOutputPath.replace(".js", ".https.html.headers"); + const iframeHtmlOutputHeadersPath = jsOutputPath.replace(".js", ".iframe.https.html.headers"); + const includes = (meta && meta.includes) || []; //console.log(includes); const testContent = replacePlaceholders(templateContent, { @@ -240,6 +260,10 @@ const generateTest = async ({ await writeFile(htmlOutputPath, testContent); await writeFile(iframeHtmlOutputPath, iframeTestContent); + if (isSharedArrayBufferTest) { + await writeFile(htmlOutputHeadersPath, headerContent); + await writeFile(iframeHtmlOutputHeadersPath, headerIFrameContent); + } await fs.copy(currentPath, jsOutputPath); testCount++; } @@ -276,6 +300,8 @@ function replacePlaceholders( __dirname, "test-template.iframe.html" ); + const HEADER_TEMPLATE_NAME = path.join(__dirname, "header-template.html"); + const IFRAME_HEADER_TEMPLATE_NAME = path.join(__dirname, "header-template.html"); const DEFAULT_TEST_DIR = "./test262"; const DEFAULT_OUTPUT_DIR = "."; const SUB_DIR_NAME = "ecmascript"; @@ -295,12 +321,16 @@ function replacePlaceholders( console.log("Reading test templates ..."); const templateContent = await readFile(HTML_TEMPLATE_NAME); const iframeTemplateContent = await readFile(IFRAME_HTML_TEMPLATE_NAME); + const headerContent = await readFile(HEADER_TEMPLATE_NAME); + const headerIFrameContent = await readFile(IFRAME_HEADER_TEMPLATE_NAME); console.log("Generating tests ..."); await generateTest({ testsPath, outputPath: testsOutputPath, templateContent, iframeTemplateContent, + headerContent, + headerIFrameContent, }); await fs.copy(adapterSourcePath, adapterDestinationPath); await fs.copy(harnessDir, harnessOutputDir); diff --git a/tools/wave/ecmascript/header-template.html b/tools/wave/ecmascript/header-template.html new file mode 100644 index 0000000000..c9146ee9d7 --- /dev/null +++ b/tools/wave/ecmascript/header-template.html @@ -0,0 +1,2 @@ +Cross-Origin-Opener-Policy:same-origin +Cross-Origin-Embedder-Policy:require-corp \ No newline at end of file diff --git a/wmas2022-subset.sh b/wmas2022-subset.sh old mode 100755 new mode 100644 index 304df45d51..e5a0f69ef0 --- a/wmas2022-subset.sh +++ b/wmas2022-subset.sh @@ -647,6 +647,9 @@ node tools/wave/ecmascript/generate-tests.js $ECMADISTDIR cp $ECMADISTDIR/LICENSE $WPTBASEDIR/ecmascript rm -rf ecmascript/tests/**/*lookBehind* rm -rf ecmascript/tests/**/*lookbehind* +rm -rf ecmascript/tests/**/*Temporal* +rm -rf ecmascript/tests/**/*temporal* +rm -rf ecmascript/tests/staging # Integrate webgl tests [WEBGL-103] WEBGLDISTDIR=$DISTDIR/webgl