forked from mykmelez/gecko
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1508928 [wpt PR 14157] - Add tests for no active script in import…
…(), a=testonly Automatic update from web-platform-testsAdd tests for no active script in import() (#14157) Follows whatwg/html#4181. -- wpt-commits: 5241a3fe2c638f9fadcc040f39f3e6a71a2be2e1 wpt-pr: 14157
- Loading branch information
1 parent
737d896
commit d9c67b8
Showing
3 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
...scripting-1/the-script-element/module/dynamic-import/no-active-script-manual-classic.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,55 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Dynamic import when there is no active script</title> | ||
<link rel="help" href="https://github.com/whatwg/html/pull/4181"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<p>Click these buttons in sequence:</p> | ||
|
||
<button id="button1">Click me 1</button> | ||
|
||
<button id="button2">Click me 2</button> | ||
|
||
<p>The result will be pass/fail per the testharness.js results</p> | ||
|
||
<!-- We set the attributes from a separate script to specifically make | ||
sure that it's not that script's base URL that gets used, but instead this page's. --> | ||
<script src="scripts/no-active-script.js"></script> | ||
|
||
<script> | ||
"use strict"; | ||
setup({ explicit_timeout: true }); | ||
|
||
promise_test(t => { | ||
t.add_cleanup(() => { | ||
delete window.evaluated_imports_a; | ||
}); | ||
|
||
const promise = new Promise((resolve, reject) => { | ||
window.continueTest1 = resolve; | ||
window.errorTest1 = reject; | ||
}); | ||
|
||
return promise.then(module => { | ||
assert_true(window.evaluated_imports_a, "The module must have been evaluated"); | ||
assert_equals(module.A.from, "imports-a.js", "The module namespace object must be correct"); | ||
}); | ||
}, "onclick that directly imports should successfully import, using page's base URL"); | ||
|
||
promise_test(t => { | ||
t.add_cleanup(() => { | ||
delete window.evaluated_imports_a; | ||
}); | ||
|
||
const promise = new Promise((resolve, reject) => { | ||
window.continueTest2 = resolve; | ||
window.errorTest2 = reject; | ||
}); | ||
|
||
return promise.then(module => { | ||
assert_true(window.evaluated_imports_a, "The module must have been evaluated"); | ||
assert_equals(module.A.from, "imports-a.js", "The module namespace object must be correct"); | ||
}); | ||
}, "onclick that indirectly imports after a task should successfully import, using page's base URL"); | ||
</script> |
55 changes: 55 additions & 0 deletions
55
.../scripting-1/the-script-element/module/dynamic-import/no-active-script-manual-module.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,55 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Dynamic import when there is no active script</title> | ||
<link rel="help" href="https://github.com/whatwg/html/pull/4181"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<p>Click these buttons in sequence:</p> | ||
|
||
<button id="button1">Click me 1</button> | ||
|
||
<button id="button2">Click me 2</button> | ||
|
||
<p>The result will be pass/fail per the testharness.js results</p> | ||
|
||
<!-- We set the attributes from a separate script to specifically make | ||
sure that it's not that script's base URL that gets used, but instead this page's. --> | ||
<script src="scripts/no-active-script.js" type="module"></script> | ||
|
||
<script type="module"> | ||
"use strict"; | ||
setup({ explicit_timeout: true }); | ||
|
||
promise_test(t => { | ||
t.add_cleanup(() => { | ||
delete window.evaluated_imports_a; | ||
}); | ||
|
||
const promise = new Promise((resolve, reject) => { | ||
window.continueTest1 = resolve; | ||
window.errorTest1 = reject; | ||
}); | ||
|
||
return promise.then(module => { | ||
assert_true(window.evaluated_imports_a, "The module must have been evaluated"); | ||
assert_equals(module.A.from, "imports-a.js", "The module namespace object must be correct"); | ||
}); | ||
}, "onclick that directly imports should successfully import, using page's base URL"); | ||
|
||
promise_test(t => { | ||
t.add_cleanup(() => { | ||
delete window.evaluated_imports_a; | ||
}); | ||
|
||
const promise = new Promise((resolve, reject) => { | ||
window.continueTest2 = resolve; | ||
window.errorTest2 = reject; | ||
}); | ||
|
||
return promise.then(module => { | ||
assert_true(window.evaluated_imports_a, "The module must have been evaluated"); | ||
assert_equals(module.A.from, "imports-a.js", "The module namespace object must be correct"); | ||
}); | ||
}, "onclick that indirectly imports after a task should successfully import, using page's base URL"); | ||
</script> |
5 changes: 5 additions & 0 deletions
5
...emantics/scripting-1/the-script-element/module/dynamic-import/scripts/no-active-script.js
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,5 @@ | ||
"use strict"; | ||
|
||
document.querySelector("#button1").setAttribute("onclick", "import('../imports-a.js?label=button1').then(window.continueTest1, window.errorTest1)"); | ||
|
||
document.querySelector("#button2").setAttribute("onclick", "Promise.resolve(`import('../imports-a.js?label=button2')`).then(eval).then(window.continueTest2, window.errorTest2);"); |