зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1471815 [wpt PR 11705] - Worker: Add WPTs for module loading with blob, data, and file URLs, a=testonly
Automatic update from web-platform-testsWorker: Add WPTs for module loading with blob, data, and file URLs Bug: 680046 Change-Id: I8b3894bfbc8df999952fa82e8f2b3abb4088f434 Reviewed-on: https://chromium-review.googlesource.com/1114566 Reviewed-by: Kouhei Ueno <kouhei@chromium.org> Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org> Cr-Commit-Position: refs/heads/master@{#571378} -- wpt-commits: a2c108ffd92458de51acc02a0f79221548c785ab wpt-pr: 11705
This commit is contained in:
Родитель
f104186389
Коммит
698986984b
|
@ -302490,6 +302490,11 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"workers/modules/resources/export-on-dynamic-import-script.js.headers": [
|
||||
[
|
||||
{}
|
||||
]
|
||||
],
|
||||
"workers/modules/resources/export-on-load-script.js": [
|
||||
[
|
||||
{}
|
||||
|
@ -302500,6 +302505,11 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"workers/modules/resources/export-on-static-import-script.js.headers": [
|
||||
[
|
||||
{}
|
||||
]
|
||||
],
|
||||
"workers/modules/resources/import-meta-url-worker.js": [
|
||||
[
|
||||
{}
|
||||
|
@ -302510,6 +302520,11 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"workers/modules/resources/import-test-cases.js": [
|
||||
[
|
||||
{}
|
||||
]
|
||||
],
|
||||
"workers/modules/resources/nested-dynamic-import-worker.js": [
|
||||
[
|
||||
{}
|
||||
|
@ -387746,6 +387761,26 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"workers/modules/dedicated-worker-import-blob-url.any.js": [
|
||||
[
|
||||
"/workers/modules/dedicated-worker-import-blob-url.any.html",
|
||||
{}
|
||||
],
|
||||
[
|
||||
"/workers/modules/dedicated-worker-import-blob-url.any.worker.html",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"workers/modules/dedicated-worker-import-data-url.any.js": [
|
||||
[
|
||||
"/workers/modules/dedicated-worker-import-data-url.any.html",
|
||||
{}
|
||||
],
|
||||
[
|
||||
"/workers/modules/dedicated-worker-import-data-url.any.worker.html",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"workers/modules/dedicated-worker-import-failure.html": [
|
||||
[
|
||||
"/workers/modules/dedicated-worker-import-failure.html",
|
||||
|
@ -631841,8 +631876,16 @@
|
|||
"6bffa3be83d81e2faa93119e710e4fee93fb855e",
|
||||
"testharness"
|
||||
],
|
||||
"workers/modules/dedicated-worker-import-blob-url.any.js": [
|
||||
"811bccb876055daee01bc50152c425dc931c0f72",
|
||||
"testharness"
|
||||
],
|
||||
"workers/modules/dedicated-worker-import-data-url.any.js": [
|
||||
"599db2cf40a1173d66b06c1b53229a654bc4473f",
|
||||
"testharness"
|
||||
],
|
||||
"workers/modules/dedicated-worker-import-failure.html": [
|
||||
"63b2320a3ecf6133a3525574bf5a1d185d1f3aa7",
|
||||
"29932911fcc6804e8d5f77f3d8f2a8adc4cd2fed",
|
||||
"testharness"
|
||||
],
|
||||
"workers/modules/dedicated-worker-import-meta.html": [
|
||||
|
@ -631854,7 +631897,7 @@
|
|||
"testharness"
|
||||
],
|
||||
"workers/modules/dedicated-worker-import.any.js": [
|
||||
"8a3a5bdcf6034d99cb244cc6ff36ada8f422ef37",
|
||||
"b890d5e557f526ed2d6c43f8e4f413faa93e58ff",
|
||||
"testharness"
|
||||
],
|
||||
"workers/modules/dedicated-worker-options-credentials.html": [
|
||||
|
@ -631905,6 +631948,10 @@
|
|||
"dbb6eaa13def20fd310c7aaafab3d3ef9fe99859",
|
||||
"support"
|
||||
],
|
||||
"workers/modules/resources/export-on-dynamic-import-script.js.headers": [
|
||||
"90d51a5e46cc58404dd5ec1e9e4e10934a6c0707",
|
||||
"support"
|
||||
],
|
||||
"workers/modules/resources/export-on-load-script.js": [
|
||||
"fab13482dce29d3150f4eb06b1375c2610ab07f3",
|
||||
"support"
|
||||
|
@ -631913,6 +631960,10 @@
|
|||
"fccc8ed2855b857d435d71382ed056f94be6e69d",
|
||||
"support"
|
||||
],
|
||||
"workers/modules/resources/export-on-static-import-script.js.headers": [
|
||||
"90d51a5e46cc58404dd5ec1e9e4e10934a6c0707",
|
||||
"support"
|
||||
],
|
||||
"workers/modules/resources/import-meta-url-worker.js": [
|
||||
"83f231a886c36543721c2b0204c18b97d10968f8",
|
||||
"support"
|
||||
|
@ -631921,6 +631972,10 @@
|
|||
"53c6df8251db9e255ba4199c5f4828acc16b93ac",
|
||||
"support"
|
||||
],
|
||||
"workers/modules/resources/import-test-cases.js": [
|
||||
"b86e4129ec023b2d9e13664c3d8c420ce0ea6ed8",
|
||||
"support"
|
||||
],
|
||||
"workers/modules/resources/nested-dynamic-import-worker.js": [
|
||||
"a6da499a70bce69c7faa79fc9f22ad2cd41c7fd5",
|
||||
"support"
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
// META: script=/workers/modules/resources/import-test-cases.js
|
||||
|
||||
// Imports |testCase.scriptURL| on a dedicated worker loaded from a blob URL,
|
||||
// and waits until the list of imported modules is sent from the worker. Passes
|
||||
// if the list is equal to |testCase.expectation|.
|
||||
function import_blob_url_test(testCase) {
|
||||
promise_test(async () => {
|
||||
const importURL = new URL(testCase.scriptURL, location.href);
|
||||
const blob = new Blob([`import "${importURL}";`],
|
||||
{ type: 'text/javascript' });
|
||||
const blobURL = URL.createObjectURL(blob);
|
||||
|
||||
const worker = new Worker(blobURL, { type: 'module'});
|
||||
const msgEvent = await new Promise(resolve => worker.onmessage = resolve);
|
||||
assert_array_equals(msgEvent.data, testCase.expectation);
|
||||
}, testCase.description);
|
||||
}
|
||||
|
||||
testCases.forEach(import_blob_url_test);
|
|
@ -0,0 +1,21 @@
|
|||
// META: script=/workers/modules/resources/import-test-cases.js
|
||||
|
||||
// Imports |testCase.scriptURL| on a dedicated worker loaded from a data URL,
|
||||
// and waits until the list of imported modules is sent from the worker. Passes
|
||||
// if the list is equal to |testCase.expectation|.
|
||||
function import_data_url_test(testCase) {
|
||||
promise_test(async () => {
|
||||
// The Access-Control-Allow-Origin header is necessary because a worker
|
||||
// loaded from a data URL has a null origin and import() on the worker
|
||||
// without the header is blocked.
|
||||
const importURL = new URL(testCase.scriptURL, location.href) +
|
||||
'?pipe=header(Access-Control-Allow-Origin, *)';
|
||||
const dataURL = `data:text/javascript,import "${importURL}";`;
|
||||
|
||||
const worker = new Worker(dataURL, { type: 'module'});
|
||||
const msgEvent = await new Promise(resolve => worker.onmessage = resolve);
|
||||
assert_array_equals(msgEvent.data, testCase.expectation);
|
||||
}, testCase.description);
|
||||
}
|
||||
|
||||
testCases.forEach(import_data_url_test);
|
|
@ -11,10 +11,10 @@ promise_test(async () => {
|
|||
assert_equals(msg_event.data, 'TypeError');
|
||||
}, 'importScripts() on module worker should throw an exception.');
|
||||
|
||||
promise_test(async () => {
|
||||
promise_test(() => {
|
||||
const scriptURL = 'resources/static-import-worker.js';
|
||||
const worker = new Worker(scriptURL, { type: 'classic' });
|
||||
await new Promise(resolve => worker.onerror = resolve);
|
||||
return new Promise(resolve => worker.onerror = resolve);
|
||||
}, 'Static import on classic worker should throw an exception.');
|
||||
|
||||
promise_test(() => {
|
||||
|
@ -31,12 +31,22 @@ promise_test(() => {
|
|||
}, 'Static import for non-existent script should dispatch an ErrorEvent.');
|
||||
|
||||
promise_test(async () => {
|
||||
const script_url = './non-existent-worker.js';
|
||||
const scriptURL = './non-existent-worker.js';
|
||||
const worker = new Worker('resources/dynamic-import-given-url-worker.js',
|
||||
{ type: 'module' });
|
||||
worker.postMessage(script_url);
|
||||
worker.postMessage(scriptURL);
|
||||
const msg_event = await new Promise(resolve => worker.onmessage = resolve);
|
||||
assert_equals(msg_event.data, 'TypeError');
|
||||
}, 'Dynamic import for non-existent script should throw an exception.');
|
||||
|
||||
test(() => {
|
||||
const scriptURL = 'http://invalid:123$';
|
||||
assert_throws('SyntaxError', () => new Worker(scriptURL, { type: 'module' }));
|
||||
}, 'Worker construction for an invalid URL should throw an exception.');
|
||||
|
||||
test(() => {
|
||||
const scriptURL = 'file:///static-import-worker.js';
|
||||
assert_throws('SecurityError', () => new Worker(scriptURL, { type: 'module' }));
|
||||
}, 'Worker construction for a file URL should throw an exception.');
|
||||
|
||||
</script>
|
||||
|
|
|
@ -1,39 +1,14 @@
|
|||
// Starts a dedicated worker for |scriptURL| and waits until the list of
|
||||
// imported modules is sent from the worker. Passes if the list is equal to
|
||||
// |expectedImportedModules|.
|
||||
function import_test(scriptURL, expectedImportedModules, description) {
|
||||
// META: script=/workers/modules/resources/import-test-cases.js
|
||||
|
||||
// Starts a dedicated worker for |testCase.scriptURL| and waits until the list
|
||||
// of imported modules is sent from the worker. Passes if the list is equal to
|
||||
// |testCase.expectation|.
|
||||
function import_test(testCase) {
|
||||
promise_test(async () => {
|
||||
const worker = new Worker(scriptURL, { type: 'module' });
|
||||
const msg_event = await new Promise(resolve => worker.onmessage = resolve);
|
||||
assert_array_equals(msg_event.data, expectedImportedModules);
|
||||
}, description);
|
||||
const worker = new Worker(testCase.scriptURL, { type: 'module' });
|
||||
const msgEvent = await new Promise(resolve => worker.onmessage = resolve);
|
||||
assert_array_equals(msgEvent.data, testCase.expectation);
|
||||
}, testCase.description);
|
||||
}
|
||||
|
||||
import_test('resources/static-import-worker.js',
|
||||
['export-on-load-script.js'],
|
||||
'Static import.');
|
||||
|
||||
import_test('resources/nested-static-import-worker.js',
|
||||
['export-on-static-import-script.js', 'export-on-load-script.js'],
|
||||
'Nested static import.');
|
||||
|
||||
|
||||
import_test('resources/static-import-and-then-dynamic-import-worker.js',
|
||||
['export-on-dynamic-import-script.js', 'export-on-load-script.js'],
|
||||
'Static import and then dynamic import.');
|
||||
|
||||
import_test('resources/dynamic-import-worker.js',
|
||||
['export-on-load-script.js'],
|
||||
'Dynamic import.');
|
||||
|
||||
import_test('resources/nested-dynamic-import-worker.js',
|
||||
['export-on-dynamic-import-script.js', 'export-on-load-script.js'],
|
||||
'Nested dynamic import.');
|
||||
|
||||
import_test('resources/dynamic-import-and-then-static-import-worker.js',
|
||||
['export-on-static-import-script.js', 'export-on-load-script.js'],
|
||||
'Dynamic import and then static import.');
|
||||
|
||||
import_test('resources/eval-dynamic-import-worker.js',
|
||||
['export-on-load-script.js'],
|
||||
'eval(import()).');
|
||||
testCases.forEach(import_test);
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Access-Control-Allow-Origin: *
|
|
@ -0,0 +1 @@
|
|||
Access-Control-Allow-Origin: *
|
|
@ -0,0 +1,49 @@
|
|||
const testCases = [
|
||||
{
|
||||
scriptURL: 'resources/static-import-worker.js',
|
||||
expectation: ['export-on-load-script.js'],
|
||||
description: 'Static import.'
|
||||
},
|
||||
{
|
||||
scriptURL: 'resources/nested-static-import-worker.js',
|
||||
expectation: [
|
||||
'export-on-static-import-script.js',
|
||||
'export-on-load-script.js'
|
||||
],
|
||||
description: 'Nested static import.'
|
||||
},
|
||||
{
|
||||
scriptURL: 'resources/static-import-and-then-dynamic-import-worker.js',
|
||||
expectation: [
|
||||
'export-on-dynamic-import-script.js',
|
||||
'export-on-load-script.js'
|
||||
],
|
||||
description: 'Static import and then dynamic import.'
|
||||
},
|
||||
{
|
||||
scriptURL: 'resources/dynamic-import-worker.js',
|
||||
expectation: ['export-on-load-script.js'],
|
||||
description: 'Dynamic import.'
|
||||
},
|
||||
{
|
||||
scriptURL: 'resources/nested-dynamic-import-worker.js',
|
||||
expectation: [
|
||||
'export-on-dynamic-import-script.js',
|
||||
'export-on-load-script.js'
|
||||
],
|
||||
description: 'Nested dynamic import.'
|
||||
},
|
||||
{
|
||||
scriptURL: 'resources/dynamic-import-and-then-static-import-worker.js',
|
||||
expectation: [
|
||||
'export-on-static-import-script.js',
|
||||
'export-on-load-script.js'
|
||||
],
|
||||
description: 'Dynamic import and then static import.'
|
||||
},
|
||||
{
|
||||
scriptURL: 'resources/eval-dynamic-import-worker.js',
|
||||
expectation: ['export-on-load-script.js'],
|
||||
description: 'eval(import()).'
|
||||
}
|
||||
];
|
Загрузка…
Ссылка в новой задаче