Skip to content

Commit 2026041

Browse files
mfreed7chromium-wpt-export-bot
authored andcommitted
Add "true" to truthy values list for windowFeatures
Prior to this CL, window.open(url, '', 'noopener=true') would treat 'noopener=true' as if noopener is false. This is currently per-spec [1] but there is a desire [2][3] to change that. The I2S is here: https://groups.google.com/a/chromium.org/g/blink-dev/c/ePJ4GE6VzVc/m/urs3-4rHDAAJ [1] https://html.spec.whatwg.org/multipage/window-object.html#concept-window-open-features-parse-boolean [2] whatwg/html#7425 [3] whatwg/html#7399 Fixed: 1277613 Change-Id: I5b3a7e985a9bb392c2150846b50369cfcd9b05fa Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3495659 Reviewed-by: Joey Arhar <jarhar@chromium.org> Commit-Queue: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#977722}
1 parent 6d14c7a commit 2026041

File tree

4 files changed

+112
-0
lines changed

4 files changed

+112
-0
lines changed

html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/open-features-is-popup-condition.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,48 +26,59 @@
2626
// The explicit popup feature.
2727
["popup", false],
2828
["popup=1", false],
29+
["popup=true", false],
2930
["popup=0", true],
3031

3132
// Other feature alone results in popup.
3233
["location", false],
3334
["location=yes", false],
35+
["location=true", false],
3436
["location=no", false],
3537

3638
["toolbar", false],
3739
["toolbar=yes", false],
40+
["toolbar=true", false],
3841
["toolbar=no", false],
3942

4043
["menubar", false],
4144
["menubar=yes", false],
45+
["menubar=true", false],
4246
["menubar=no", false],
4347

4448
["resizable", false],
4549
["resizable=yes", false],
50+
["resizable=true", false],
4651
["resizable=no", false],
4752
],
4853
"single-2": [
4954
["scrollbars", false],
5055
["scrollbars=yes", false],
56+
["scrollbars=true", false],
5157
["scrollbars=no", false],
5258

5359
["status", false],
5460
["status=yes", false],
61+
["status=true", false],
5562
["status=no", false],
5663

5764
["titlebar", false],
5865
["titlebar=yes", false],
66+
["titlebar=true", false],
5967
["titlebar=no", false],
6068

6169
["close", false],
6270
["close=yes", false],
71+
["close=true", false],
6372
["close=no", false],
6473

6574
["minimizable", false],
6675
["minimizable=yes", false],
76+
["minimizable=true", false],
6777
["minimizable=no", false],
6878

6979
["personalbar", false],
7080
["personalbar=yes", false],
81+
["personalbar=true", false],
7182
["personalbar=no", false],
7283
],
7384
"position": [
@@ -113,6 +124,8 @@
113124

114125
// The explicit popup feature has priority than others.
115126
["popup=1,location,toolbar,menubar,resizable,scrollbars,status", false],
127+
["popup=yes,location,toolbar,menubar,resizable,scrollbars,status", false],
128+
["popup=true,location,toolbar,menubar,resizable,scrollbars,status", false],
116129
["popup=0,location,toolbar,menubar,resizable,scrollbars", true],
117130
],
118131
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<script>
2+
const channelName = location.search.substr(1),
3+
channel = new BroadcastChannel(channelName);
4+
5+
const haveOpener = window.opener !== null;
6+
const haveReferrer = document.referrer !== null && document.referrer !== "";
7+
const allBarProps = [
8+
window.locationbar.visible,
9+
window.menubar.visible,
10+
window.personalbar.visible,
11+
window.scrollbars.visible,
12+
window.statusbar.visible,
13+
window.toolbar.visible
14+
];
15+
const isPopup = allBarProps.every(x=>!x);
16+
17+
channel.postMessage({haveOpener, haveReferrer, isPopup});
18+
19+
// Because messages are not delivered synchronously and because closing a
20+
// browsing context prompts the eventual clearing of all task sources, this
21+
// document should not be closed until the opener document has confirmed
22+
// receipt.
23+
channel.onmessage = () => window.close();
24+
</script>

html/browsers/the-window-object/window-open-noopener.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
{ testDescription: "noopener=1 means the same as noopener",
1919
secondWindowFeatureString: "noopener=1",
2020
shouldReturnWindow: false },
21+
{ testDescription: "noopener=true means the same as noopener",
22+
secondWindowFeatureString: "noopener=true",
23+
shouldReturnWindow: false },
2124
{ testDescription: "noopener=0 means lack of noopener",
2225
secondWindowFeatureString: "noopener=0",
2326
shouldReturnWindow: true },
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<!doctype html>
2+
<meta charset=utf-8>
3+
<meta name="timeout" content="long">
4+
<title>window.open() windowFeature value parsing</title>
5+
<link rel="author" href="mailto:masonf@chromium.org">
6+
<link rel="help" href="https://html.spec.whatwg.org/multipage/window-object.html#concept-window-open-features-parse-boolean">
7+
<script src="/resources/testharness.js"></script>
8+
<script src="/resources/testharnessreport.js"></script>
9+
<script>
10+
function testValueGeneric(val, expectTrue, property, testFn) {
11+
const windowFeatureStr = val === "" ? property : `${property}=${val}`;
12+
async_test(t => {
13+
const windowName = '' + Math.round(Math.random()*1e12);
14+
const channel = new BroadcastChannel(windowName);
15+
channel.onmessage = t.step_func_done(e => {
16+
// Send message first so if asserts throw the popup is still closed
17+
channel.postMessage(null);
18+
testFn(e.data);
19+
});
20+
window.open("support/windowFeature-values-target.html?" + windowName, windowName, windowFeatureStr);
21+
},`Test ${windowFeatureStr}, expected interpretation is ${expectTrue ? 'true' : 'false'}`);
22+
}
23+
24+
function testValueForNoReferrer(val, expectTrue) {
25+
testValueGeneric(val, expectTrue, "noreferrer", (data) => {
26+
if (expectTrue) {
27+
assert_false(data.haveReferrer);
28+
assert_false(data.haveOpener);
29+
} else {
30+
assert_true(data.haveReferrer);
31+
assert_true(data.haveOpener);
32+
}
33+
});
34+
}
35+
36+
function testValueForNoOpener(val, expectTrue) {
37+
testValueGeneric(val, expectTrue, "noopener", (data) => {
38+
assert_equals(data.haveOpener, !expectTrue);
39+
});
40+
}
41+
42+
function testValueForPopup(val, expectTrue) {
43+
testValueGeneric(val, expectTrue, "popup", (data) => {
44+
assert_equals(data.isPopup, expectTrue);
45+
});
46+
}
47+
48+
function testValue(val, expectTrue) {
49+
const quotes = val === "" ? [''] : ['','"',"'"];
50+
let noQuotes = true;
51+
for (const quote of quotes) {
52+
const thisExpectTrue = expectTrue && noQuotes;
53+
const thisVal = quote + val + quote;
54+
testValueForNoReferrer(thisVal, thisExpectTrue);
55+
testValueForNoOpener(thisVal, thisExpectTrue);
56+
testValueForPopup(thisVal, thisExpectTrue);
57+
noQuotes = false;
58+
}
59+
}
60+
61+
testValue('',true); // Just the parameter means true
62+
testValue('yes',true); // Yes means true
63+
testValue('true',true); // True means true
64+
testValue('foo',false); // If parsing as an integer is an error, false
65+
testValue('0',false); // 0 is false
66+
testValue('00',false); // 0 is false
67+
testValue('1',true); // Non-zero is true
68+
testValue('99999',true); // Non-zero is true
69+
testValue('-1',true); // Non-zero is true
70+
testValue('1foo',true); // This parses to 1
71+
testValue('0foo',false); // This parses to 0
72+
</script>

0 commit comments

Comments
 (0)