Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(741)

Unified Diff: LayoutTests/fast/forms/form-associated-element.html

Issue 106423005: Only 'form associated' elements have a potential form owner. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use 'error' instead of 'click' events when testing form ownership Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/forms/form-associated-element-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/forms/form-associated-element.html
diff --git a/LayoutTests/fast/forms/form-associated-element.html b/LayoutTests/fast/forms/form-associated-element.html
new file mode 100644
index 0000000000000000000000000000000000000000..882929589834ec86c98c9ad0af24c22bb5789256
--- /dev/null
+++ b/LayoutTests/fast/forms/form-associated-element.html
@@ -0,0 +1,70 @@
+<!doctype html>
+<html>
+<head>
+<script src="../../resources/js-test.js"></script>
+<script type="text/javascript">
+var formOwner;
+function hasFormOwner(shouldHaveOwner, haveIt, event)
+{
+ formOwner = haveIt || "not defined";
+ debug("Testing " + event.target.tagName);
+ if (shouldHaveOwner)
+ shouldBeEqualToString("formOwner", "defined");
+ else
+ shouldBeEqualToString("formOwner", "not defined");
+}
+</script>
+</head>
+<body>
+<div style="display: none;">
+<form id=topForm>
+<label form=topForm onerror="" onclick="hasFormOwner(true, typeof canary !== 'undefined' && canary, event);"><input type="button"/></label>
+<!-- Form-associated elements per http://whatwg.org/specs/web-apps/current-work/#form-associated-element -->
+<button onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, event);"></button>
+<fieldset onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, event);"></fieldset>
+<input type=radio onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, event);"/>
+<input type=number onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, event);"/>
+<keygen keytype=rsa onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, event);"></keygen>
+<label onerror="" onclick="hasFormOwner(true, typeof canary !== 'undefined' && canary, event);"><input type="button"/></label>
+<object onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, event);"></object>
+<select onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, event);"></select>
+<textarea onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, event);"></textarea>
+<img onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, event);"></img>
+
+<!-- Elements that aren't associated. -->
+<option onerror="hasFormOwner(false, typeof canary !== 'undefined' && canary, event);"></option>
+<div onerror="hasFormOwner(false, typeof canary !== 'undefined' && canary, event);"></div>
+<a onerror="hasFormOwner(false, typeof canary !== 'undefined' && canary, event);"></a>
+<p onerror="hasFormOwner(false, typeof canary !== 'undefined' && canary, event);"></p>
+</form>
+
+<!-- Elements that associated by 'form' reference rather than ancestor. -->
+<input form=topForm type="number" onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, event);"/>
+<keygen form=topForm keytype=rsa onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, event);"></keygen>
+<object form=topForm onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, event);"></object>
+<select form=topForm onerror="hasFormOwner(true, typeof canary !== 'undefined' && canary, event);"></select>
+<pre form=topForm onerror="hasFormOwner(false, typeof canary !== 'undefined' && canary, event);"></pre>
+<span form=topForm onerror="hasFormOwner(false, typeof canary !== 'undefined' && canary, event);"></span>
+<img form=topForm onerror="hasFormOwner(false, typeof canary !== 'undefined' && canary, event);"></img>
+</div>
+<script>
+description("Verify that only elements that are 'form associatable' get a form owner.");
+
+var elements;
+function testFormAssociation()
+{
+ document.forms[0].canary = "defined";
+ elements = document.querySelectorAll("*[onerror]");
+ shouldBeTrue("elements.length > 0");
+ for (var i = 0; i < elements.length; ++i) {
+ // <label/> won't handle 'error', use 'click'.
+ var eventType = (elements[i] instanceof HTMLLabelElement) ? "click" : "error";
+ elements[i].dispatchEvent(new Event(eventType));
+ }
+}
+testFormAssociation();
+if (window.testRunner)
+ testRunner.dumpAsText();
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/fast/forms/form-associated-element-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698