-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test entry settings object for promise jobs
Follows whatwg/html#5212.
- Loading branch information
Showing
9 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
...pting/processing-model-2/integration-with-the-javascript-job-queue/promise-job-entry.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,94 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Entry settings object for promise jobs</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<!-- https://github.com/whatwg/html/pull/5212 --> | ||
<!-- https://github.com/whatwg/html/issues/1426 --> | ||
|
||
<!-- This is the entry page, so window.open() should resolve relative to it, even inside promise jobs. --> | ||
|
||
<iframe src="resources/promise-job-entry-incumbent.html"></iframe> | ||
|
||
<script> | ||
setup({ explicit_done: true }); | ||
|
||
const relativeURL = "resources/window-to-open.html"; | ||
const expectedURL = (new URL(relativeURL, location.href)).href; | ||
|
||
window.onload = () => { | ||
async_test(t => { | ||
const w = frames[0].runWindowOpenVeryIndirectly(relativeURL); | ||
w.onload = t.step_func_done(() => { | ||
t.add_cleanup(() => w.close()); | ||
assert_equals(w.location.href, expectedURL); | ||
}); | ||
}, "Sanity check: this all works as expected with no promises involved"); | ||
|
||
async_test(t => { | ||
Promise.resolve().then(t.step_func(() => { | ||
const w = frames[0].runWindowOpenVeryIndirectly(relativeURL); | ||
w.onload = t.step_func_done(() => { | ||
t.add_cleanup(() => w.close()); | ||
assert_equals(w.location.href, expectedURL); | ||
}); | ||
})); | ||
}, "Fulfillment handler on fulfilled promise"); | ||
|
||
async_test(t => { | ||
Promise.reject().catch(t.step_func(() => { | ||
const w = frames[0].runWindowOpenVeryIndirectly(relativeURL); | ||
w.onload = t.step_func_done(() => { | ||
t.add_cleanup(() => w.close()); | ||
assert_equals(w.location.href, expectedURL); | ||
}); | ||
})); | ||
}, "Rejection handler on rejected promise"); | ||
|
||
async_test(t => { | ||
let resolve; | ||
const p = new Promise(r => { resolve = r; }); | ||
|
||
p.then(t.step_func(() => { | ||
const w = frames[0].runWindowOpenVeryIndirectly(relativeURL); | ||
w.onload = t.step_func_done(() => { | ||
t.add_cleanup(() => w.close()); | ||
assert_equals(w.location.href, expectedURL); | ||
}); | ||
})); | ||
|
||
t.step_timeout(resolve, 0); | ||
}, "Fulfillment handler on pending-then-fulfilled promise"); | ||
|
||
async_test(t => { | ||
let reject; | ||
const p = new Promise((_, r) => { reject = r; }); | ||
|
||
p.catch(t.step_func(() => { | ||
const w = frames[0].runWindowOpenVeryIndirectly(relativeURL); | ||
w.onload = t.step_func_done(() => { | ||
t.add_cleanup(() => w.close()); | ||
assert_equals(w.location.href, expectedURL); | ||
}); | ||
})); | ||
|
||
t.step_timeout(reject, 0); | ||
}, "Rejection handler on pending-then-rejected promise"); | ||
|
||
async_test(t => { | ||
const thenable = { | ||
then: t.step_func((f) => { | ||
const w = frames[0].runWindowOpenVeryIndirectly(relativeURL); | ||
w.onload = t.step_func_done(() => { | ||
t.add_cleanup(() => w.close()); | ||
assert_equals(w.location.href, expectedURL); | ||
}); | ||
}) | ||
}; | ||
|
||
Promise.resolve(thenable); | ||
}, "Thenable resolution"); | ||
|
||
done(); | ||
}; | ||
</script> |
5 changes: 5 additions & 0 deletions
5
...rocessing-model-2/integration-with-the-javascript-job-queue/resources/README.md
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 @@ | ||
A couple notes about the files scattered in this `resources/` directory: | ||
|
||
* The nested directory structure is necessary here so that relative URL resolution can be tested; we need different sub-paths for each document. | ||
|
||
* The semi-duplicate `window-to-open.html`s scattered throughout are present because Firefox, at least, does not fire `Window` `load` events for 404s, so we want to ensure that no matter which global is used, `window`'s `load` event is hit and our tests can proceed. |
3 changes: 3 additions & 0 deletions
3
...ocessing-model-2/integration-with-the-javascript-job-queue/resources/current/current.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,3 @@ | ||
<!DOCTYPE html> | ||
<title>Current page used as a test helper</title> | ||
|
2 changes: 2 additions & 0 deletions
2
...integration-with-the-javascript-job-queue/resources/current/resources/window-to-open.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,2 @@ | ||
<!DOCTYPE html> | ||
<title>If the current settings object is used this page will be opened</title> |
14 changes: 14 additions & 0 deletions
14
...el-2/integration-with-the-javascript-job-queue/resources/promise-job-entry-incumbent.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,14 @@ | ||
<!DOCTYPE html> | ||
<title>Incumbent page used as a test helper</title> | ||
|
||
<iframe src="relevant/relevant.html" id="r"></iframe> | ||
<iframe src="current/current.html" id="c"></iframe> | ||
|
||
<script> | ||
const relevant = document.querySelector("#r"); | ||
const current = document.querySelector("#c"); | ||
|
||
window.runWindowOpenVeryIndirectly = (...args) => { | ||
return current.contentWindow.open.call(relevant.contentWindow, ...args); | ||
}; | ||
</script> |
3 changes: 3 additions & 0 deletions
3
...essing-model-2/integration-with-the-javascript-job-queue/resources/relevant/relevant.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,3 @@ | ||
<!DOCTYPE html> | ||
<title>Relevant page used as a test helper</title> | ||
|
2 changes: 2 additions & 0 deletions
2
...ntegration-with-the-javascript-job-queue/resources/relevant/resources/window-to-open.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,2 @@ | ||
<!DOCTYPE html> | ||
<title>If the relevant settings object is used this page will be opened</title> |
2 changes: 2 additions & 0 deletions
2
...model-2/integration-with-the-javascript-job-queue/resources/resources/window-to-open.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,2 @@ | ||
<!DOCTYPE html> | ||
<title>If the incumbent settings object is used this page will be opened</title> |
2 changes: 2 additions & 0 deletions
2
...rocessing-model-2/integration-with-the-javascript-job-queue/resources/window-to-open.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,2 @@ | ||
<!DOCTYPE html> | ||
<title>If the entry settings object is used this page will be opened</title> |