forked from WebKit/WebKit-http
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restrict browsing context lookup by name to frames that are related t…
…o one another https://bugs.webkit.org/show_bug.cgi?id=190475 Reviewed by Alex Christensen. Source/WebCore: Update our frame lookup by name logic to take in the active / requesting frame and only a return a frame that is related to it. By related to it, I mean: - Ancestor <-> Descendant relationship - Opener <-> Openee relationship Being able to look up unrelated frames makes process swapping difficult so we need to be stricter. This change is being discussed at: - whatwg/html#313 Tests: http/tests/dom/new-window-can-target-opener.html http/tests/dom/noopener-window-cannot-target-opener.html http/tests/dom/noopener-window-not-targetable.html http/tests/dom/noopener-window-not-targetable2.html http/tests/dom/noreferrer-window-not-targetable.html http/tests/dom/opened-window-not-targetable-after-disowning-opener.html * loader/FrameLoader.cpp: (WebCore::FrameLoader::findFrameForNavigation): * page/FrameTree.cpp: (WebCore::isFrameFamiliarWith): (WebCore::FrameTree::find const): * page/FrameTree.h: * rendering/HitTestResult.cpp: (WebCore::HitTestResult::targetFrame const): Source/WebKit: * WebProcess/Plugins/PluginView.cpp: (WebKit::PluginView::performJavaScriptURLRequest): Source/WebKitLegacy/mac: * WebView/WebFrame.mm: (-[WebFrame findFrameNamed:]): LayoutTests: * http/tests/dom/new-window-can-target-opener-expected.txt: Added. * http/tests/dom/new-window-can-target-opener.html: Added. * http/tests/dom/noopener-window-cannot-target-opener-expected.txt: Added. * http/tests/dom/noopener-window-cannot-target-opener.html: Added. * http/tests/dom/noopener-window-not-targetable-expected.txt: Added. * http/tests/dom/noopener-window-not-targetable.html: Added. * http/tests/dom/noopener-window-not-targetable2-expected.txt: Added. * http/tests/dom/noopener-window-not-targetable2.html: Added. * http/tests/dom/noreferrer-window-not-targetable-expected.txt: Added. * http/tests/dom/noreferrer-window-not-targetable.html: Added. * http/tests/dom/opened-window-not-targetable-after-disowning-opener-expected.txt: Added. * http/tests/dom/opened-window-not-targetable-after-disowning-opener.html: Added. * http/tests/dom/resources/new-window-can-target-opener-win.html: Added. * http/tests/dom/resources/noopener-window-cannot-target-opener-win.html: Added. Add layout test coverage. * fast/dom/Window/a-rel-noopener-expected.txt: * fast/dom/Window/area-rel-noopener-expected.txt: * fast/dom/Window/resources/rel-noopener.js: * http/tests/navigation/no-referrer-target-blank-expected.txt: * http/tests/navigation/resources/no-referrer-helper.php: * platform/mac-wk1/imported/w3c/web-platform-tests/html/browsers/windows/noreferrer-window-name-expected.txt: * platform/wk2/imported/w3c/web-platform-tests/html/browsers/windows/noreferrer-window-name-expected.txt: Update / rebaseline existing tests to reflect behavior change. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@237112 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
cdumez@apple.com
committed
Oct 15, 2018
1 parent
1a33581
commit 6cb3eff
Showing
34 changed files
with
417 additions
and
36 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
CONSOLE MESSAGE: line 11: PASS: window.opener is null | ||
Test that window.opener is null when a new window is opened from an anchor element with rel='noopener'. | ||
|
||
PASS: window.opener is null | ||
|
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
CONSOLE MESSAGE: line 11: PASS: window.opener is null | ||
Test that window.opener is null when a new window is opened from an area element with rel='noopener'. | ||
|
||
|
||
PASS: window.opener is null | ||
|
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
9 changes: 9 additions & 0 deletions
9
LayoutTests/http/tests/dom/new-window-can-target-opener-expected.txt
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,9 @@ | ||
CONSOLE MESSAGE: line 15: PASS: New window should have an opener | ||
CONSOLE MESSAGE: line 21: PASS: New window should be able to look up opener by name | ||
CONSOLE MESSAGE: line 27: PASS: New window should have URL 'http://127.0.0.1:8000/dom/new-window-can-target-opener.html' | ||
Make sure that windows opened via window.open can target their opener | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
|
20 changes: 20 additions & 0 deletions
20
LayoutTests/http/tests/dom/new-window-can-target-opener.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,20 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
description("Make sure that windows opened via window.open can target their opener"); | ||
jsTestIsAsync = true; | ||
|
||
if (window.testRunner) | ||
testRunner.setCanOpenWindows(); | ||
|
||
onload = function() { | ||
window.name = "opener"; | ||
w = open("resources/new-window-can-target-opener-win.html", ""); | ||
} | ||
</script> | ||
</body> | ||
</html> |
9 changes: 9 additions & 0 deletions
9
LayoutTests/http/tests/dom/noopener-window-cannot-target-opener-expected.txt
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,9 @@ | ||
CONSOLE MESSAGE: line 17: PASS: New window should not have an opener | ||
CONSOLE MESSAGE: line 21: PASS: New window should have URL 'about:blank' | ||
Make sure that windows opened with 'noopener' via window.open cannot target their opener. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS w is null | ||
|
21 changes: 21 additions & 0 deletions
21
LayoutTests/http/tests/dom/noopener-window-cannot-target-opener.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,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
description("Make sure that windows opened with 'noopener' via window.open cannot target their opener."); | ||
jsTestIsAsync = true; | ||
|
||
if (window.testRunner) | ||
testRunner.setCanOpenWindows(); | ||
|
||
onload = function() { | ||
window.name = "opener"; | ||
w = open("resources/noopener-window-cannot-target-opener-win.html", "", "noopener"); | ||
shouldBeNull("w"); | ||
} | ||
</script> | ||
</body> | ||
</html> |
11 changes: 11 additions & 0 deletions
11
LayoutTests/http/tests/dom/noopener-window-not-targetable-expected.txt
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 @@ | ||
Make sure that windows opened with 'noopener' via an anchor are not targetable. If testing manually, you should see 2 tabs open. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS w.location.href is "about:blank" | ||
PASS testRunner.windowCount() is 3 | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
30 changes: 30 additions & 0 deletions
30
LayoutTests/http/tests/dom/noopener-window-not-targetable.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,30 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
<a id="testLink" target="foo" rel="noopener" href="/navigation/resources/otherpage.html"></a> | ||
<script> | ||
description("Make sure that windows opened with 'noopener' via an anchor are not targetable. If testing manually, you should see 2 tabs open."); | ||
jsTestIsAsync = true; | ||
|
||
if (window.testRunner) | ||
testRunner.setCanOpenWindows(); | ||
|
||
onload = function() { | ||
testLink.click(); | ||
|
||
setTimeout(function() { | ||
w = open("/navigation/resources/otherpage.html", "foo"); // Should create a new window. | ||
shouldBeEqualToString("w.location.href", "about:blank"); | ||
w.onload = function() { | ||
if (window.testRunner) | ||
shouldBe("testRunner.windowCount()", "3"); | ||
finishJSTest(); | ||
} | ||
}, 100); | ||
} | ||
</script> | ||
</body> | ||
</html> |
12 changes: 12 additions & 0 deletions
12
LayoutTests/http/tests/dom/noopener-window-not-targetable2-expected.txt
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,12 @@ | ||
Make sure that windows opened with 'noopener' via window.open are not targetable. If testing manually, you should see 2 tabs open. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS w is null | ||
PASS w.location.href is "about:blank" | ||
PASS testRunner.windowCount() is 3 | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
30 changes: 30 additions & 0 deletions
30
LayoutTests/http/tests/dom/noopener-window-not-targetable2.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,30 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
description("Make sure that windows opened with 'noopener' via window.open are not targetable. If testing manually, you should see 2 tabs open."); | ||
jsTestIsAsync = true; | ||
|
||
if (window.testRunner) | ||
testRunner.setCanOpenWindows(); | ||
|
||
onload = function() { | ||
w = window.open("/navigation/resources/otherpage.html", "foo", "noopener"); | ||
shouldBeNull("w"); | ||
|
||
setTimeout(function() { | ||
w = open("/navigation/resources/otherpage.html", "foo"); // Should create a new window. | ||
shouldBeEqualToString("w.location.href", "about:blank"); | ||
w.onload = function() { | ||
if (window.testRunner) | ||
shouldBe("testRunner.windowCount()", "3"); | ||
finishJSTest(); | ||
} | ||
}, 100); | ||
} | ||
</script> | ||
</body> | ||
</html> |
11 changes: 11 additions & 0 deletions
11
LayoutTests/http/tests/dom/noreferrer-window-not-targetable-expected.txt
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 @@ | ||
Make sure that windows opened with 'noreferrer' are not targetable. If testing manually, you should see 2 tabs open. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS w.location.href is "about:blank" | ||
PASS testRunner.windowCount() is 3 | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
29 changes: 29 additions & 0 deletions
29
LayoutTests/http/tests/dom/noreferrer-window-not-targetable.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,29 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
<a id="testLink" target="foo" rel="noreferrer" href="/navigation/resources/otherpage.html"></a> | ||
<script> | ||
description("Make sure that windows opened with 'noreferrer' are not targetable. If testing manually, you should see 2 tabs open."); | ||
jsTestIsAsync = true; | ||
|
||
if (window.testRunner) | ||
testRunner.setCanOpenWindows(); | ||
|
||
onload = function() { | ||
testLink.click(); | ||
setTimeout(function() { | ||
w = open("/navigation/resources/otherpage.html", "foo"); // Should create a new window. | ||
shouldBeEqualToString("w.location.href", "about:blank"); | ||
w.onload = function() { | ||
if (window.testRunner) | ||
shouldBe("testRunner.windowCount()", "3"); | ||
finishJSTest(); | ||
} | ||
}, 100); | ||
} | ||
</script> | ||
</body> | ||
</html> |
11 changes: 11 additions & 0 deletions
11
LayoutTests/http/tests/dom/opened-window-not-targetable-after-disowning-opener-expected.txt
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 @@ | ||
Make sure that windows opened via window.open are not targetable by their opener after it is disowned. If testing manually, you should see 2 tabs open. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS w.location.href is "about:blank" | ||
PASS testRunner.windowCount() is 3 | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
30 changes: 30 additions & 0 deletions
30
LayoutTests/http/tests/dom/opened-window-not-targetable-after-disowning-opener.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,30 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
description("Make sure that windows opened via window.open are not targetable by their opener after it is disowned. If testing manually, you should see 2 tabs open."); | ||
jsTestIsAsync = true; | ||
|
||
if (window.testRunner) | ||
testRunner.setCanOpenWindows(); | ||
|
||
onload = function() { | ||
w = window.open("/navigation/resources/otherpage.html", "foo"); | ||
w.opener = null; | ||
|
||
setTimeout(function() { | ||
w = open("/navigation/resources/otherpage.html", "foo"); // Should create a new window. | ||
shouldBeEqualToString("w.location.href", "about:blank"); | ||
w.onload = function() { | ||
if (window.testRunner) | ||
shouldBe("testRunner.windowCount()", "3"); | ||
finishJSTest(); | ||
} | ||
}, 100); | ||
} | ||
</script> | ||
</body> | ||
</html> |
35 changes: 35 additions & 0 deletions
35
LayoutTests/http/tests/dom/resources/new-window-can-target-opener-win.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> | ||
<html> | ||
<head> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
jsTestIsAsync = true; | ||
|
||
if (window.testRunner) | ||
testRunner.setCanOpenWindows(); | ||
|
||
onload = function() { | ||
if (window.opener) | ||
console.log("PASS: New window should have an opener"); | ||
else | ||
console.log("FAIL: New window should have an opener"); | ||
|
||
openerByName = open("", "opener"); // Should return the opener. | ||
if (openerByName === opener) | ||
console.log("PASS: New window should be able to look up opener by name"); | ||
else | ||
console.log("FAIL: New window should be able to look up opener by name"); | ||
|
||
const expectedOpenerURL = "http://127.0.0.1:8000/dom/new-window-can-target-opener.html"; | ||
if (openerByName.location.href == expectedOpenerURL) | ||
console.log("PASS: New window should have URL '" + expectedOpenerURL + "'"); | ||
else | ||
console.log("FAIL: New window should have URL '" + expectedOpenerURL + "' but got '" + openerByName.location.href + "'"); | ||
|
||
finishJSTest(); | ||
}; | ||
</script> | ||
</body> | ||
</html> |
29 changes: 29 additions & 0 deletions
29
LayoutTests/http/tests/dom/resources/noopener-window-cannot-target-opener-win.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,29 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
jsTestIsAsync = true; | ||
|
||
if (window.testRunner) | ||
testRunner.setCanOpenWindows(); | ||
|
||
onload = function() { | ||
if (window.opener) | ||
console.log("FAIL: New window should not have an opener"); | ||
else | ||
console.log("PASS: New window should not have an opener"); | ||
|
||
opener = open("", "opener"); // Should open a new window. | ||
if (opener.location.href == "about:blank") | ||
console.log("PASS: New window should have URL 'about:blank'"); | ||
else | ||
console.log("FAIL: New window should have URL 'about:blank' but got '" + opener.location.href + "'"); | ||
|
||
finishJSTest(); | ||
}; | ||
</script> | ||
</body> | ||
</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
5 changes: 3 additions & 2 deletions
5
LayoutTests/http/tests/navigation/no-referrer-subframe-expected.txt
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
CONSOLE MESSAGE: line 15: Referrer: | ||
CONSOLE MESSAGE: line 16: window.opener: | ||
This tests behavior of "noreferrer" links in subframes. A referrer should not be sent and window.opener should remain null. | ||
Load subframe | ||
Referrer: | ||
window.opener: | ||
|
5 changes: 3 additions & 2 deletions
5
LayoutTests/http/tests/navigation/no-referrer-target-blank-expected.txt
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
CONSOLE MESSAGE: line 15: Referrer: | ||
CONSOLE MESSAGE: line 16: window.opener: | ||
This tests the functionality of the "noreferrer" link relation on anchor tags. The link below should not send an http referrer, and the resulting window should have its opener attribute set to null. The values of the referrer and window.opener should be empty below. | ||
Start no referrer test | ||
Referrer: | ||
window.opener: | ||
|
Oops, something went wrong.