Skip to content

Commit

Permalink
[WPT] Distinguish base URLs in string-compilation-of-promise-result.html
Browse files Browse the repository at this point in the history
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 <hiroshige@chromium.org>
Reviewed-by: Domenic Denicola <domenic@chromium.org>
Cr-Commit-Position: refs/heads/main@{#918862}
  • Loading branch information
hiroshige-g authored and chromium-wpt-export-bot committed Sep 7, 2021
1 parent ba638d1 commit e51a2c6
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,35 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<body>
<base href="scripts/foo/">
<script>
"use strict";

// This test is based on the current specification, but all browser
// implementations aren't conformant. See
// https://bugs.chromium.org/p/chromium/issues/detail?id=1245063
// https://github.com/heycam/webidl/pull/902

// Tweak the base URL of the document here to distinguish:
// - document URL
// - document base URL = ../
// - This inline script's base URL = ./scripts/foo/
document.querySelector("base").remove();
const base = document.createElement("base");
base.setAttribute("href", "../");
document.body.appendChild(base);

self.ran = false;

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

return Promise.resolve(`import("../imports-a.js?1").then(() => { self.ran = true; })`)
return Promise.resolve(`import("../../../imports-a.js?1").then(() => { self.ran = true; })`)
.then(eval)
.then(() => {
assert_true(self.ran);
Expand All @@ -42,7 +60,7 @@
self.ran = false;
})

return Promise.resolve(`return import("../imports-a.js?2").then(() => { self.ran = true; })`)
return Promise.resolve(`return import("../../../imports-a.js?2").then(() => { self.ran = true; })`)
.then(Function)
.then(Function.prototype.call.bind(Function.prototype.call))
.then(() => {
Expand Down

0 comments on commit e51a2c6

Please sign in to comment.