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 <[email protected]>
Reviewed-by: Domenic Denicola <[email protected]>
Cr-Commit-Position: refs/heads/main@{#918862}
  • Loading branch information
hiroshige-g authored and Chromium LUCI CQ committed Sep 7, 2021
1 parent 056e52a commit 068960d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This is a testharness.js-based test.
FAIL Evaled the script via eval, successful import promise_test: Unhandled rejection with value: object "TypeError: Failed to fetch dynamically imported module: http://web-platform.test:8001/html/semantics/imports-a.js?1"
PASS Evaled the script via eval, failed import
FAIL Evaled the script via Function, successful import promise_test: Unhandled rejection with value: object "TypeError: Failed to fetch dynamically imported module: http://web-platform.test:8001/html/semantics/imports-a.js?2"
PASS Evaled the script via Function, failed import
Harness: the test ran to completion.

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 068960d

Please sign in to comment.