-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change navigable target names to _blank if they have dangling markup
https://bugs.webkit.org/show_bug.cgi?id=257349 Reviewed by Chris Dumez. whatwg/html#9309 * LayoutTests/imported/w3c/resources/import-expectations.json: * LayoutTests/imported/w3c/web-platform-tests/html/browsers/windows/dangling-markup-window-name.tentative-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/browsers/windows/dangling-markup-window-name.tentative.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/browsers/windows/resources/window-name.sub.html: * LayoutTests/imported/w3c/web-platform-tests/html/browsers/windows/w3c-import.log: * LayoutTests/tests-options.json: * Source/WebCore/dom/Element.cpp: (WebCore::Element::makeTargetBlankIfHasDanglingMarkup const): * Source/WebCore/dom/Element.h: * Source/WebCore/html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::effectiveTarget const): * Source/WebCore/html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::effectiveTarget const): Canonical link: https://commits.webkit.org/267154@main
- Loading branch information
1 parent
b2fab9c
commit 6752480
Showing
10 changed files
with
123 additions
and
4 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
8 changes: 8 additions & 0 deletions
8
...b-platform-tests/html/browsers/windows/dangling-markup-window-name.tentative-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,8 @@ | ||
|
||
PASS Dangling Markup in target is not reset when set by window.open | ||
PASS Dangling Markup with "\n" in target is reset when set by <a> tag | ||
PASS Dangling Markup with "\r" in target is reset when set by <a> tag | ||
PASS Dangling Markup with "\t" in target is reset when set by <a> tag | ||
PASS Dangling Markup in target is reset when set by <form> tag | ||
PASS Dangling Markup in target is reset when set by <base> tag | ||
|
97 changes: 97 additions & 0 deletions
97
...d/w3c/web-platform-tests/html/browsers/windows/dangling-markup-window-name.tentative.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,97 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Dangling Markup in target</title> | ||
<meta name="timeout" content="long"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/utils.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
function anchorClick(target, id) { | ||
const hyperlink = document.body.appendChild(document.createElement('a')); | ||
if (target) { | ||
hyperlink.target = target; | ||
} | ||
hyperlink.href = `resources/window-name.sub.html?report=${id}|close`; | ||
hyperlink.click(); | ||
} | ||
|
||
async function pollResultAndCheck(t, id, expected) { | ||
const stashURL = new URL('resources/window-name-stash.py', location); | ||
stashURL.searchParams.set('id', id); | ||
|
||
let res = 'NONE'; | ||
while (res == 'NONE') { | ||
await new Promise(resolve => { t.step_timeout(resolve, 100); }); | ||
|
||
const response = await fetch(stashURL); | ||
res = await response.text(); | ||
} | ||
if (res !== expected) { | ||
assert_unreached('Stash result does not equal expected result.') | ||
} | ||
} | ||
|
||
promise_test(async t => { | ||
const id = token(); | ||
const value = '\n<' + id; | ||
|
||
window.open(`resources/window-name.sub.html?report=${id}|close`, value); | ||
await pollResultAndCheck(t, id, value); | ||
}, 'Dangling Markup in target is not reset when set by window.open'); | ||
|
||
promise_test(async t => { | ||
const id = token(); | ||
const value = '\n<' + id; | ||
|
||
anchorClick(value, id) | ||
await pollResultAndCheck(t, id, ''); | ||
}, 'Dangling Markup with "\\n" in target is reset when set by <a> tag'); | ||
|
||
promise_test(async t => { | ||
const id = token(); | ||
const value = '\r<' + id; | ||
|
||
anchorClick(value, id) | ||
await pollResultAndCheck(t, id, ''); | ||
}, 'Dangling Markup with "\\r" in target is reset when set by <a> tag'); | ||
|
||
promise_test(async t => { | ||
const id = token(); | ||
const value = '\t<' + id; | ||
|
||
anchorClick(value, id) | ||
await pollResultAndCheck(t, id, ''); | ||
}, 'Dangling Markup with "\\t" in target is reset when set by <a> tag'); | ||
|
||
promise_test(async t => { | ||
const id = token(); | ||
const value = '\n<' + id; | ||
|
||
const form = document.body.appendChild(document.createElement('form')); | ||
form.target = value; | ||
form.method = 'GET'; | ||
form.action = 'resources/window-name.sub.html'; | ||
const input = form.appendChild(document.createElement('input')); | ||
input.type = 'hidden'; | ||
input.name = 'report'; | ||
input.value = `${id}|close`; | ||
form.submit(); | ||
|
||
await pollResultAndCheck(t, id, ''); | ||
}, 'Dangling Markup in target is reset when set by <form> tag'); | ||
|
||
promise_test(async t => { | ||
const id = token(); | ||
const value = '\n<' + id; | ||
const base = document.head.appendChild(document.createElement('base')); | ||
base.target = value; | ||
|
||
anchorClick(null, id) | ||
await pollResultAndCheck(t, id, ''); | ||
}, 'Dangling Markup in target is reset when set by <base> tag'); | ||
</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
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
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
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