-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1936441 [wpt PR 49631] - Add WPTs for named window lookup and BCG…
… swap limits, a=testonly Automatic update from web-platform-tests Add WPTs for named window lookup and BCG swap limits These tests verify the behaviour discussed here: whatwg/html#10818 While there is some implementation defined behaviour, we can add tests for the behaviour that's consistent between the major implementations, namely that proactive browsing context group swaps can't be done while another context exists in the group, that named lookups are scoped to browsing context groups, and the lookup order in the case of multiple contexts with the same name. Bug: None Change-Id: I515f527fb94a711bdd8eeb6610df2127571dcc3c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6081814 Reviewed-by: Domenic Denicola <[email protected]> Commit-Queue: Kevin McNee <[email protected]> Cr-Commit-Position: refs/heads/main@{#1394596} -- wpt-commits: 1f7679ad01691ea3885537b8b19e1b88a0e7f152 wpt-pr: 49631
- Loading branch information
1 parent
0e1c09f
commit 94039b3
Showing
3 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...rs/windows/auxiliary-browsing-contexts/named-lookup-scoped-to-browsing-context-group.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,27 @@ | ||
<!DOCTYPE html> | ||
<title>Named lookup scoped to browsing context group</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/dispatcher/dispatcher.js"></script> | ||
<script src="/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js"></script> | ||
|
||
<body> | ||
<script> | ||
|
||
promise_test(async t => { | ||
const rcHelper = new RemoteContextHelper(); | ||
// This test harness cannot be in the same browsing context group as the | ||
// popup. | ||
const rcPopup1 = await rcHelper.addWindow(undefined, { features: 'noopener' }); | ||
|
||
await rcPopup1.executeScript(() => { | ||
window.name = 'my_popup'; | ||
window.firstPopup = true; | ||
}); | ||
assert_equals(window.open('', 'my_popup').firstPopup, undefined, | ||
'cannot lookup across browsing context groups'); | ||
}, 'named lookup scoped to browsing context group'); | ||
|
||
</script> | ||
</body> |
38 changes: 38 additions & 0 deletions
38
...s/windows/auxiliary-browsing-contexts/no-proactive-swap-when-other-contexts-in-group.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,38 @@ | ||
<!DOCTYPE html> | ||
<title>No proactive browsing context group changes when other contexts in group</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/dispatcher/dispatcher.js"></script> | ||
<script src="/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js"></script> | ||
|
||
<body> | ||
<script> | ||
|
||
promise_test(async t => { | ||
const rcHelper = new RemoteContextHelper(); | ||
const rcPopup1 = await rcHelper.addWindow(undefined, { target: 'my_popup' }); | ||
|
||
await rcPopup1.executeScript(() => { | ||
window.intendedTarget1 = true; | ||
}); | ||
assert_true(window.open('', 'my_popup').intendedTarget1, | ||
'lookup by name'); | ||
|
||
// There is no security reason (e.g. COOP) to change browsing context groups | ||
// for this navigation. Some implementations perform BCG swaps for performance | ||
// reasons, but they cannot do so in this case, as this test harness page and | ||
// the popup are in the same browsing context group. | ||
const rcPopup2 = await rcPopup1.navigateToNew(); | ||
|
||
// In order to find the popup by name, the popup and this opener must be in | ||
// the same browsing context group. | ||
await rcPopup2.executeScript(() => { | ||
window.intendedTarget2 = true; | ||
}); | ||
assert_true(window.open('', 'my_popup').intendedTarget2, | ||
'lookup by name after navigation'); | ||
}, 'no proactive browsing context group change when other contexts in group'); | ||
|
||
</script> | ||
</body> |
55 changes: 55 additions & 0 deletions
55
...web-platform/tests/html/browsers/windows/browsing-context-names/duplicate-name-order.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,55 @@ | ||
<!DOCTYPE html> | ||
<title>Duplicate name lookup order</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/dispatcher/dispatcher.js"></script> | ||
<script src="/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js"></script> | ||
|
||
<body> | ||
<script> | ||
|
||
promise_test(async t => { | ||
const rcHelper = new RemoteContextHelper(); | ||
const rcMain = await rcHelper.addWindow(); | ||
|
||
const rcPopupA = await rcHelper.addWindow(undefined, { target: 'A' }); | ||
const rcPopupB = await rcHelper.addWindow(undefined, { target: 'B' }); | ||
const rcPopupC = await rcHelper.addWindow(undefined, { target: 'C' }); | ||
|
||
const rcSiblingA = await rcMain.addIframe(undefined, { name: 'A' }); | ||
const rcSiblingB = await rcMain.addIframe(undefined, { name: 'B' }); | ||
|
||
const rcRequestor = await rcMain.addIframe(); | ||
|
||
const rcChildA = await rcRequestor.addIframe(undefined, { name: 'A' }); | ||
|
||
const windowIdentifiers = { | ||
'Main': rcMain, | ||
'PopupA': rcPopupA, | ||
'PopupB': rcPopupB, | ||
'PopupC': rcPopupC, | ||
'SiblingA': rcSiblingA, | ||
'SiblingB': rcSiblingB, | ||
'Requestor': rcRequestor, | ||
'ChildA': rcChildA, | ||
}; | ||
for (const [windowIdentifier, remote] of Object.entries(windowIdentifiers)) { | ||
await remote.executeScript((windowIdentifier) => { | ||
window.windowIdentifier = windowIdentifier; | ||
}, [windowIdentifier]); | ||
} | ||
|
||
function performLookup(targetName) { | ||
return rcRequestor.executeScript((targetName) => { | ||
return window.open('', targetName).windowIdentifier; | ||
}, [targetName]); | ||
} | ||
|
||
assert_equals(await performLookup('A'), 'ChildA', 'subtree first'); | ||
assert_equals(await performLookup('B'), 'SiblingB', 'then the rest of the tree'); | ||
assert_equals(await performLookup('C'), 'PopupC', 'then other pages'); | ||
}, 'Duplicate name lookup order'); | ||
|
||
</script> | ||
</body> |