Skip to content

Commit 5b3ca0b

Browse files
[WPT] Distinguish base URLs in string-compilation-of-promise-result.html
The tests fail on Safari/Firefox/Chromium, and thus this change exposes that the browsers set no active scripts for `Promise.resolve(...).then(eval)`. Bug: 1245063, whatwg/webidl#902 Change-Id: Ic7debcd66e3f90c2fcb973d1e4100daabf2895dc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3130646 Commit-Queue: Hiroshige Hayashizaki <[email protected]> Reviewed-by: Domenic Denicola <[email protected]> Cr-Commit-Position: refs/heads/main@{#918862}
1 parent 6271c7f commit 5b3ca0b

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

html/semantics/scripting-1/the-script-element/module/dynamic-import/string-compilation-of-promise-result.html

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,35 @@
88
<script src="/resources/testharness.js"></script>
99
<script src="/resources/testharnessreport.js"></script>
1010

11+
<body>
12+
<base href="scripts/foo/">
1113
<script>
1214
"use strict";
1315

16+
// This test is based on the current specification, but all browser
17+
// implementations aren't conformant. See
18+
// https://bugs.chromium.org/p/chromium/issues/detail?id=1245063
19+
// https://github.com/heycam/webidl/pull/902
20+
21+
// Tweak the base URL of the document here to distinguish:
22+
// - document URL
23+
// - document base URL = ../
24+
// - This inline script's base URL = ./scripts/foo/
25+
document.querySelector("base").remove();
26+
const base = document.createElement("base");
27+
base.setAttribute("href", "../");
28+
document.body.appendChild(base);
29+
1430
self.ran = false;
1531

32+
// The active script for the dynamic import is this inline script
33+
// (see https://html.spec.whatwg.org/C/#hostmakejobcallback).
1634
promise_test(t => {
1735
t.add_cleanup(() => {
1836
self.ran = false;
1937
})
2038

21-
return Promise.resolve(`import("../imports-a.js?1").then(() => { self.ran = true; })`)
39+
return Promise.resolve(`import("../../../imports-a.js?1").then(() => { self.ran = true; })`)
2240
.then(eval)
2341
.then(() => {
2442
assert_true(self.ran);
@@ -42,7 +60,7 @@
4260
self.ran = false;
4361
})
4462

45-
return Promise.resolve(`return import("../imports-a.js?2").then(() => { self.ran = true; })`)
63+
return Promise.resolve(`return import("../../../imports-a.js?2").then(() => { self.ran = true; })`)
4664
.then(Function)
4765
.then(Function.prototype.call.bind(Function.prototype.call))
4866
.then(() => {

0 commit comments

Comments
 (0)