Source/WebCore:
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Feb 2019 21:03:20 +0000 (21:03 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Feb 2019 21:03:20 +0000 (21:03 +0000)
When performing Increment or Decrement on sliders, check to see if the slider is disabled.
https://bugs.webkit.org/show_bug.cgi?id=173497

Patch by Eric Liang <ericliang@apple.com> on 2019-02-04
Reviewed by Chris Fleizach.

Test: accessibility/set-value-not-work-for-disabled-sliders.html

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::alterSliderValue):

LayoutTests:
Check if slider value changed after calling AX Increment or Decrement on disabled sliders.
https://bugs.webkit.org/show_bug.cgi?id=193497

Patch by Eric Liang <ericliang@apple.com> on 2019-02-04
Reviewed by Chris Fleizach.

* accessibility/set-value-not-work-for-disabled-sliders.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240939 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/accessibility/set-value-not-work-for-disabled-sliders-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/set-value-not-work-for-disabled-sliders.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityNodeObject.cpp

index c48cbd5..444bccb 100644 (file)
@@ -1,3 +1,12 @@
+2019-02-04  Eric Liang  <ericliang@apple.com>
+
+        Check if slider value changed after calling AX Increment or Decrement on disabled sliders.
+        https://bugs.webkit.org/show_bug.cgi?id=193497
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/set-value-not-work-for-disabled-sliders.html: Added.
+
 2019-02-04  Frederic Wang  <fwang@igalia.com>
 
         [css-scroll-snap] scroll-snap-align not honored on child with non-visible overflow
diff --git a/LayoutTests/accessibility/set-value-not-work-for-disabled-sliders-expected.txt b/LayoutTests/accessibility/set-value-not-work-for-disabled-sliders-expected.txt
new file mode 100644 (file)
index 0000000..3141f5a
--- /dev/null
@@ -0,0 +1,28 @@
+     
+This tests that disabled sliders can't be incremented or decremented.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS slider.intValue is 50
+PASS slider.intValue is 50
+PASS slider.intValue is 50
+PASS slider.intValue is 50
+PASS slider.intValue is 50
+PASS slider.intValue is 50
+PASS slider.intValue is 50
+PASS slider.intValue is 50
+PASS slider.intValue is 50
+PASS slider.intValue is 50
+PASS slider.intValue is 55
+PASS slider.intValue is 45
+PASS slider.intValue is 50
+PASS slider.intValue is 55
+PASS slider.intValue is 45
+PASS slider.intValue is 50
+PASS slider.intValue is 55
+PASS slider.intValue is 45
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/set-value-not-work-for-disabled-sliders.html b/LayoutTests/accessibility/set-value-not-work-for-disabled-sliders.html
new file mode 100644 (file)
index 0000000..bfe45ee
--- /dev/null
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+<div id="content">
+
+<input id="test0" type='range' should-change="false" disabled>
+<input id="test1" type='range' should-change="false" disabled aria-disabled="true">
+<input id="test2" type='range' should-change="false" disabled aria-disabled="false">
+<input id="test3" type='range' should-change="true" >
+<input id="test4" type='range' should-change="true" aria-disabled="true">
+<input id="test5" type='range' should-change="true" aria-disabled="false">
+
+<p id="description"></p>
+<div id="console"></div>
+
+</div>
+<script>
+    description("This tests that disabled sliders can't be incremented or decremented.");
+
+    if (window.accessibilityController) {
+        var numOfTests = 6;
+        for (var testId = 0; testId < numOfTests; testId++) {
+            var slider = accessibilityController.accessibleElementById("test" + testId);
+            var shouldChange = document.getElementById("test" + testId).getAttribute("should-change") == "true" ? true : false;
+            shouldBe("slider.intValue", "50");
+
+            slider.increment();
+            shouldBe("slider.intValue", shouldChange ? "55" : "50");
+
+            slider.decrement();
+            slider.decrement();
+            shouldBe("slider.intValue", shouldChange ? "45" : "50");
+        }
+    }
+</script>
+
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
index 80acf87..4240d8e 100644 (file)
@@ -1,3 +1,15 @@
+2019-02-04  Eric Liang  <ericliang@apple.com>
+
+        When performing Increment or Decrement on sliders, check to see if the slider is disabled.
+        https://bugs.webkit.org/show_bug.cgi?id=173497
+
+        Reviewed by Chris Fleizach.
+
+        Test: accessibility/set-value-not-work-for-disabled-sliders.html
+
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::alterSliderValue):
+
 2019-02-04  Sihui Liu  <sihui_liu@apple.com>
 
         IndexedDB: leak WebIDBConnectionToServer in layout tests
index 8b7d6e6..15bcb02 100644 (file)
@@ -1063,6 +1063,10 @@ void AccessibilityNodeObject::alterSliderValue(bool increase)
 {
     if (roleValue() != AccessibilityRole::Slider)
         return;
+    
+    auto element = this->element();
+    if (!element || element->isDisabledFormControl())
+        return;
 
     if (!getAttribute(stepAttr).isEmpty())
         changeValueByStep(increase);