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

Unified Diff: LayoutTests/fast/dom/shadow/shadowdom-for-input-checkbox.html

Issue 21165005: Support author Shadow DOM for INPUT elements (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Test should work on Windows and Linux. Created 7 years, 3 months 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
Index: LayoutTests/fast/dom/shadow/shadowdom-for-input-checkbox.html
diff --git a/LayoutTests/fast/dom/shadow/shadowdom-for-input-checkbox.html b/LayoutTests/fast/dom/shadow/shadowdom-for-input-checkbox.html
new file mode 100644
index 0000000000000000000000000000000000000000..2253ba18d7ff0bfe446873f9e1722c07091475e6
--- /dev/null
+++ b/LayoutTests/fast/dom/shadow/shadowdom-for-input-checkbox.html
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<body>
+
+<form>
+<input type="checkbox" name="foo" id="cb1" value="Shadow">
+<input type="submit">
+</form>
+
+<style>
+#cb1 {
+ -webkit-appearance: none;
+ border: outset;
+ padding: 2px;
+ font-family: monospace;
+ font-size: 20px;
+ white-space: pre;
+ width: 30px;
+ height: 30px;
+ margin: 0;
+}
+
+#cb1:focus {
+ outline: none;
+}
+</style>
+<script>
+cb1.updateAppearance_ = function() {
+ if (this.checked)
+ this.root_.innerHTML = '<span style="color:red;">&#x2714;</span>';
+ else
+ this.root_.innerHTML = '<span> </span>';
+};
+
+cb1.init = function() {
+ this.root_ = this.createShadowRoot();
+ this.checked_ = this.hasAttribute('checked');
+ this.updateAppearance_();
+
+ this.addEventListener('DOMActivate', function() {
+ this.checked = !cb1.checked;
+ this.dispatchEvent(new CustomEvent('change', true, false));
+ }, false);
+
+ this.__defineSetter__('checked', function(value) {
+ this.checked_ = !!value;
+ this.updateAppearance_();
+ // FIXME: We'd like to update HTMLInputElement.prototype.checked, but it
+ // seems there are no ways to do it. Updating 'checked' HTML attribute
+ // (the default value) works for form submission because the checkbox is
+ // never dirty.
+ if (this.checked_)
+ this.setAttribute('checked', '');
+ else
+ this.removeAttribute('checked', '');
+ });
+
+ this.__defineGetter__('checked', function() { return this.checked_; });
+};
+
+cb1.init();
+
+window.onload = function() {
+ if (!window.eventSender)
+ return;
+ eventSender.mouseMoveTo(cb1.offsetLeft + 10, cb1.offsetTop + 10);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+};
+</script>
+</body>

Powered by Google App Engine
This is Rietveld 408576698