-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1930930 [wpt PR 49138] - HTML: Consume user activation for window…
….open (multi-global test), a=testonly Automatic update from web-platform-tests HTML: Consume user activation for window.open (multi-global test) See whatwg/html#10547 -- wpt-commits: 5ec8ba6d68f27d49a056cbf940e3bc9a8324c538 wpt-pr: 49138 UltraBlame original commit: 3da7235374ed270a493d09f34f3c394c87b74de9
- Loading branch information
Showing
5 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...ing/web-platform/tests/html/browsers/windows/consume-user-activation/support/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,11 @@ | ||
<!DOCTYPE html> | ||
<title>Current page used as a test helper</title> | ||
<button id="focus-opener-button" onclick="opener.focus()">Focus opener</button> | ||
<script> | ||
'use strict'; | ||
|
||
onload = async () => { | ||
await opener.opener.test_driver.click(document.getElementById("focus-opener-button")); | ||
opener.postMessage("current page", "*"); | ||
}; | ||
</script> |
35 changes: 35 additions & 0 deletions
35
...g/web-platform/tests/html/browsers/windows/consume-user-activation/support/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,35 @@ | ||
<!DOCTYPE html> | ||
<title>Incumbent page used as a test helper</title> | ||
<button id="focus-opener-button" onclick="opener.focus()">Focus opener</button> | ||
<script> | ||
'use strict'; | ||
|
||
function pageDone(expectedMessage) { | ||
return new Promise(resolve => { | ||
window.addEventListener('message', e => { | ||
if (e.data === expectedMessage) { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
onload = async () => { | ||
await opener.test_driver.bless("open current popup", null, window); | ||
const currentDone = pageDone("current page"); | ||
const currentWin = window.open("current.html", "_blank"); | ||
await currentDone; | ||
await opener.test_driver.bless("open relevant popup", null, window); | ||
const relevantDone = pageDone("relevant page"); | ||
const relevantWin = window.open("relevant.html", "_blank"); | ||
await relevantDone; | ||
window.openTestPopup = function() { | ||
// This is the multi-global incarnation | ||
return currentWin.open.call(relevantWin, "/resources/blank.html", "_blank"); | ||
}; | ||
opener.currentWin = currentWin; | ||
opener.relevantWin = relevantWin; | ||
await opener.test_driver.click(document.getElementById("focus-opener-button")); | ||
opener.postMessage("incumbent page", "*"); | ||
}; | ||
</script> |
11 changes: 11 additions & 0 deletions
11
...ng/web-platform/tests/html/browsers/windows/consume-user-activation/support/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,11 @@ | ||
<!DOCTYPE html> | ||
<title>Relevant page used as a test helper</title> | ||
<button id="focus-opener-button" onclick="opener.focus()">Focus opener</button> | ||
<script> | ||
'use strict'; | ||
|
||
onload = async () => { | ||
await opener.opener.test_driver.click(document.getElementById("focus-opener-button")); | ||
opener.postMessage("relevant page", "*"); | ||
}; | ||
</script> |
48 changes: 48 additions & 0 deletions
48
...latform/tests/html/browsers/windows/consume-user-activation/window-open-multi-global.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,48 @@ | ||
<!DOCTYPE html> | ||
<title>window.open() and consuming user activation with multiple globals in play</title> | ||
<link rel="help" href="https://html.spec.whatwg.org/#window-open-steps"> | ||
<link rel="help" href="https://html.spec.whatwg.org/#the-rules-for-choosing-a-navigable"> | ||
<!-- | ||
2. Let sourceDocument be the entry global object's associated Document. | ||
10. Let targetNavigable and windowType be the result of applying the rules for choosing a navigable | ||
given target, sourceDocument's node navigable, and noopener. | ||
--> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
|
||
<!-- This is the entry global --> | ||
|
||
<script> | ||
'use strict'; | ||
|
||
function pageDone(expectedMessage) { | ||
return new Promise(resolve => { | ||
window.addEventListener('message', e => { | ||
if (e.data === expectedMessage) { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
promise_test(async function(t) { | ||
await test_driver.bless("open incumbent popup"); | ||
const incumbentDone = pageDone("incumbent page"); | ||
const incumbentWin = window.open("support/incumbent.html", "_blank"); | ||
// incumbent.html opens two further popups and sets these properties (for this window): | ||
// window.currentWin | ||
// window.relevantWin | ||
await incumbentDone; | ||
await test_driver.bless("user activation in entry global"); | ||
const testWin = incumbentWin.openTestPopup(); | ||
t.add_cleanup(() => { | ||
testWin.close(); | ||
relevantWin.close(); | ||
currentWin.close(); | ||
incumbentWin.close(); | ||
}); | ||
assert_false(navigator.userActivation.isActive, "User activation of the entry global should be consumed"); | ||
}); | ||
</script> |
19 changes: 19 additions & 0 deletions
19
testing/web-platform/tests/html/browsers/windows/consume-user-activation/window-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,19 @@ | ||
<!DOCTYPE html> | ||
<title>window.open() and consuming user activation</title> | ||
<link rel="help" href="https://html.spec.whatwg.org/#the-rules-for-choosing-a-navigable"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
<script> | ||
'use strict'; | ||
|
||
promise_test(async function(t) { | ||
await test_driver.bless("user activation"); | ||
const testWin = window.open("/resources/blank.html", "_blank"); | ||
t.add_cleanup(() => { | ||
testWin.close(); | ||
}); | ||
assert_false(navigator.userActivation.isActive, "User activation should be consumed"); | ||
}); | ||
</script> |