-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WPT] Migrate most of import-maps resolution tests out of blink inter…
…nals This CL migrates most of import maps resolution tests by observing the resolution results by intercepting module script requests by a service worker. This CL also introduces `useInternalMethods` flag to clarify the tests still requiring internal methods. Bug: 1026809 Change-Id: I16c2a87bb67b530dc97b1631f6968b2d3bafdac6
- Loading branch information
1 parent
7de50cb
commit 2bd9d65
Showing
7 changed files
with
255 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
let serveImporterScript = false; | ||
|
||
self.addEventListener('message', event => { | ||
serveImporterScript = true; | ||
event.source.postMessage("Done"); | ||
}); | ||
|
||
self.addEventListener('fetch', function(event) { | ||
if (serveImporterScript) { | ||
serveImporterScript = false; | ||
event.respondWith( | ||
new Response( | ||
'window.importHelper = (specifier) => import(specifier);', | ||
{headers: {"Content-Type": "text/javascript"}} | ||
)); | ||
} else { | ||
event.respondWith( | ||
new Response( | ||
'export const response = ' + | ||
JSON.stringify({url: event.request.url}) + ';', | ||
{headers: {"Access-Control-Allow-Origin": "*", | ||
"Content-Type": "text/javascript"}} | ||
)); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
import-maps/common/resolving-internal.tentative.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<meta name="timeout" content="long"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script> | ||
<script> | ||
// This test file is for resolution tests that require Chromium's internal | ||
// methods. | ||
// For tests that don't use Chromium's internal methods, see | ||
// resolving.tentative.https.html. | ||
globalThis.useInternalMethods = true; | ||
</script> | ||
<body> | ||
<script type="module"> | ||
import { runTestsFromJSON, setupGlobalCleanup } from "./resources/common-test-helper.js"; | ||
|
||
const promises = []; | ||
|
||
for (const json of [ | ||
'resources/empty-import-map-internal.json', | ||
]) { | ||
promise_test(() => { | ||
const promise = runTestsFromJSON(json); | ||
promises.push(promise); | ||
return promise; | ||
}, | ||
"Test helper: fetching and sanity checking test JSON: " + json); | ||
} | ||
|
||
Promise.all(promises).then(setupGlobalCleanup); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.