Bug 1461706 - Sync disabled state of number control regardless of appearance. r=jwatt, a=IanN CLOSED TREE DONTBUILD SEAMONKEY_2_49_ESR_RELBRANCH
authorEmilio Cobos Alvarez <emilio@crisal.io>
Tue, 21 Aug 2018 13:06:18 +0200
branchSEAMONKEY_2_49_ESR_RELBRANCH
changeset 357544 d09a499ebaec77cc805be98a8ae3b99f1876e33d
parent 357543 9fa9839606c350c4654b8b9b4a4c67ec24a42fb0
child 357545 d47e78bd1354d920e9ee8344fcad16046aa28fc4
push id7834
push userfrgrahl@gmx.net
push dateSun, 13 Jan 2019 12:17:02 +0000
treeherdermozilla-esr52@6e4ad8a8f2e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt, IanN
bugs1461706, 1478069
milestone52.9.1
Bug 1461706 - Sync disabled state of number control regardless of appearance. r=jwatt, a=IanN CLOSED TREE DONTBUILD mozilla-esr52 SEAMONKEY_2_49_ESR_RELBRANCH I noticed this bug while fixing bug 1478069, but it goes back way earlier.
layout/forms/nsNumberControlFrame.cpp
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/html/input/the-disabled-attribute/number-disabled.html
--- a/layout/forms/nsNumberControlFrame.cpp
+++ b/layout/forms/nsNumberControlFrame.cpp
@@ -425,16 +425,18 @@ nsNumberControlFrame::CreateAnonymousCon
   }
 
   if (mContent->AsElement()->State().HasState(NS_EVENT_STATE_FOCUS)) {
     // We don't want to focus the frame but the text field.
     RefPtr<FocusTextField> focusJob = new FocusTextField(mContent, mTextField);
     nsContentUtils::AddScriptRunner(focusJob);
   }
 
+  SyncDisabledState(); // Sync disabled state of 'mTextField'.
+
   if (StyleDisplay()->mAppearance == NS_THEME_TEXTFIELD) {
     // The author has elected to hide the spinner by setting this
     // -moz-appearance. We will reframe if it changes.
     return rv;
   }
 
   // Create the ::-moz-number-spin-box pseudo-element:
   rv = MakeAnonymousElement(getter_AddRefs(mSpinBox),
@@ -456,18 +458,16 @@ nsNumberControlFrame::CreateAnonymousCon
 
   // Create the ::-moz-number-spin-down pseudo-element:
   rv = MakeAnonymousElement(getter_AddRefs(mSpinDown),
                             spinBoxCI.mChildren,
                             nsGkAtoms::div,
                             CSSPseudoElementType::mozNumberSpinDown,
                             spinBoxCI.mStyleContext);
 
-  SyncDisabledState();
-
   return rv;
 }
 
 nsIAtom*
 nsNumberControlFrame::GetType() const
 {
   return nsGkAtoms::numberControlFrame;
 }
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -19239,16 +19239,20 @@
         "path": "html/infrastructure/urls/terminology-0/document-base-url.html",
         "url": "/html/infrastructure/urls/terminology-0/document-base-url.html"
       },
       {
         "path": "html/infrastructure/urls/terminology-0/multiple-base.sub.html",
         "url": "/html/infrastructure/urls/terminology-0/multiple-base.sub.html"
       },
       {
+        "path": "html/input/the-disabled-attribute/number-disabled.html",
+        "url": "/html/input/the-disabled-attribute/number-disabled.html"
+      },
+      {
         "path": "html/obsolete/requirements-for-implementations/other-elements-attributes-and-apis/document-all.html",
         "url": "/html/obsolete/requirements-for-implementations/other-elements-attributes-and-apis/document-all.html"
       },
       {
         "path": "html/obsolete/requirements-for-implementations/other-elements-attributes-and-apis/document-color-01.html",
         "url": "/html/obsolete/requirements-for-implementations/other-elements-attributes-and-apis/document-color-01.html"
       },
       {
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/input/the-disabled-attribute/number-disabled.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<title>disabled works properly for number inputs</title>
+<link rel="help" href="https://html.spec.whatwg.org/#enabling-and-disabling-form-controls:-the-disabled-attribute">
+<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1461706">
+<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<input type="number" disabled>
+<input type="number" disabled style="-moz-appearance: textfield; -webkit-appearance: textfield">
+<script>
+  test(function() {
+    for (const element of Array.from(document.querySelectorAll('input'))) {
+      element.focus();
+      assert_true(element.disabled);
+      assert_equals(document.activeElement, document.body);
+    }
+  }, "disabled works on number input regardless of appearance");
+</script>