Skip to content

Commit

Permalink
Bug 1728215 [wpt PR 30241] - [WPT] Distinguish base URLs in string-co…
Browse files Browse the repository at this point in the history
…mpilation-of-promise-result.html, a=testonly

Automatic update from web-platform-tests
[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}

--

wpt-commits: e51a2c65259e52cf9258660ed0a3d8565409e128
wpt-pr: 30241
  • Loading branch information
hiroshige-g authored and moz-wptsync-bot committed Sep 21, 2021
1 parent 26252a4 commit 14f4cd8
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 14f4cd8

Please sign in to comment.