forked from mykmelez/gecko
-
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 1616437 [wpt PR 21873] - Don't make anchor clicks cancel form sub…
…mission when href=#, a=testonly Automatic update from web-platform-tests Don't make anchor clicks cancel form submission when href=# In http://crrev.com/c/1922699 I made anchor clicks cancel all form submissions on a page in order to make this test pass: external/wpt/html/browsers/browsing-the-web/navigating-across-documents/006.html The test basically says that anchor navigations should take precedence over form submissions when the form submission is initiated by the onclick handler of the anchor element. However, when the anchor has href="#", form submissions should actually go through, and this has introduced a bug on websites which rely on this behavior. This logic I added to cancel form submissions would not be necessary if we made anchor clicks navigate asynchronously like the spec says to do, so I made a bug to do so and remove this logic: http://crbug.com/1053679 Bug: 1053312 Change-Id: I27bf193cf0d544222cddad932728a1d0f61ba62a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2063265 Reviewed-by: Kent Tamura <tkent@chromium.org> Reviewed-by: Mason Freed <masonfreed@chromium.org> Commit-Queue: Joey Arhar <jarhar@chromium.org> Cr-Commit-Position: refs/heads/master@{#743410} -- wpt-commits: af2a784ca500a061287d26b75f7822cb4cb99b34 wpt-pr: 21873
- Loading branch information
1 parent
f775b34
commit b9765cf
Showing
5 changed files
with
100 additions
and
2 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
...rowsing-the-web/navigating-across-documents/anchor-fragment-form-submit-longfragment.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> | ||
<meta charset="utf-8"> | ||
<link rel="author" title="Joey Arhar" href="mailto:jarhar@chromium.org"> | ||
<link rel="help" href="https://html.spec.whatwg.org/C/#following-hyperlinks"> | ||
<title>Anchor element with onclick form submission and href to fragment</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<!-- When an anchor element has an onclick handler which submits a form, | ||
the anchor's navigation should occur instead of the form's navigation. | ||
However, if the anchor has an href which is just a fragment like "#", | ||
then the form should be submitted. Many sites rely on this behavior. --> | ||
|
||
<iframe name="test"></iframe> | ||
<form target="test" action="form.html"></form> | ||
<a id="anchor" target="test" onclick="document.forms[0].submit()" href="#fragment">Test</a> | ||
|
||
<script> | ||
async_test(t => { | ||
const anchor = document.getElementById('anchor'); | ||
t.step(() => anchor.click()); | ||
window.onmessage = t.step_func(event => { | ||
if (typeof event.data === 'string' && event.data.includes('navigation')) { | ||
assert_equals(event.data, 'form navigation'); | ||
t.done(); | ||
} | ||
}); | ||
}); | ||
</script> |
35 changes: 35 additions & 0 deletions
35
...rs/browsing-the-web/navigating-across-documents/anchor-fragment-form-submit-withpath.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> | ||
<meta charset="utf-8"> | ||
<link rel="author" title="Joey Arhar" href="mailto:jarhar@chromium.org"> | ||
<link rel="help" href="https://html.spec.whatwg.org/C/#following-hyperlinks"> | ||
<title>Anchor element with onclick form submission and href to fragment</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<!-- When an anchor element has an onclick handler which submits a form, | ||
the anchor's navigation should occur instead of the form's navigation. | ||
However, if the anchor has an href which is just a fragment like "#", | ||
then the form should be submitted. Many sites rely on this behavior. --> | ||
|
||
<iframe name="test"></iframe> | ||
<form target="test" action="form.html"></form> | ||
<a id="anchor" target="test" onclick="document.forms[0].submit()">Test</a> | ||
|
||
<script> | ||
async_test(async t => { | ||
const iframe = document.querySelector('iframe'); | ||
const iframeLoadPromise = new Promise(resolve => iframe.onload = resolve); | ||
iframe.src = '/'; | ||
await iframeLoadPromise; | ||
|
||
const anchor = document.getElementById('anchor'); | ||
anchor.href = '/#'; | ||
t.step(() => anchor.click()); | ||
window.onmessage = t.step_func(event => { | ||
if (typeof event.data === 'string' && event.data.includes('navigation')) { | ||
assert_equals(event.data, 'form navigation'); | ||
t.done(); | ||
} | ||
}); | ||
}); | ||
</script> |
29 changes: 29 additions & 0 deletions
29
...ml/browsers/browsing-the-web/navigating-across-documents/anchor-fragment-form-submit.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> | ||
<meta charset="utf-8"> | ||
<link rel="author" title="Joey Arhar" href="mailto:jarhar@chromium.org"> | ||
<link rel="help" href="https://html.spec.whatwg.org/C/#following-hyperlinks"> | ||
<title>Anchor element with onclick form submission and href to fragment</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<!-- When an anchor element has an onclick handler which submits a form, | ||
the anchor's navigation should occur instead of the form's navigation. | ||
However, if the anchor has an href which is just a fragment like "#", | ||
then the form should be submitted. Many sites rely on this behavior. --> | ||
|
||
<iframe name="test"></iframe> | ||
<form target="test" action="form.html"></form> | ||
<a id="anchor" target="test" onclick="document.forms[0].submit()" href="#">Test</a> | ||
|
||
<script> | ||
async_test(t => { | ||
const anchor = document.getElementById('anchor'); | ||
t.step(() => anchor.click()); | ||
window.onmessage = t.step_func(event => { | ||
if (typeof event.data === 'string' && event.data.includes('navigation')) { | ||
assert_equals(event.data, 'form navigation'); | ||
t.done(); | ||
} | ||
}); | ||
}); | ||
</script> |
5 changes: 5 additions & 0 deletions
5
...g/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/form.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,5 @@ | ||
<!DOCTYPE html> | ||
<script> | ||
parent.postMessage("form navigation", "*"); | ||
</script> | ||
form navigation |
4 changes: 2 additions & 2 deletions
4
testing/web-platform/tests/workers/Worker-constructor-proto.any.js
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,7 +1,7 @@ | ||
//META: global=!default, worker | ||
test(() => { | ||
proto = new Number(42) | ||
const proto = {}; | ||
assert_equals(String(Object.getPrototypeOf(WorkerLocation)).replace(/\n/g, " ").replace(/\s\s+/g, " "), "function () { [native code] }"); | ||
WorkerLocation.__proto__ = proto; | ||
assert_object_equals(Object.getPrototypeOf(WorkerLocation), Object(42)); | ||
assert_equals(Object.getPrototypeOf(WorkerLocation), proto); | ||
}, 'Tests that setting the proto of a built in constructor is not reset.'); |