Crash when right clicking in input box with -webkit-user-select: none
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Nov 2015 00:44:17 +0000 (00:44 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Nov 2015 00:44:17 +0000 (00:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=145981
<rdar://problem/22441925>

Reviewed by Enrica Casucci.

Source/WebCore:

Test: editing/selection/minimal-user-select-crash.html

* editing/Editor.cpp:
(WebCore::Editor::hasBidiSelection):
Visible position cannot be created because of the style that doesn't allow the selection.

LayoutTests:

* editing/selection/minimal-user-select-crash-expected.txt: Added.
* editing/selection/minimal-user-select-crash.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/editing/selection/minimal-user-select-crash-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/minimal-user-select-crash.html [new file with mode: 0644]
LayoutTests/platform/ios-simulator/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/editing/Editor.cpp

index e28f4f807948bceeba5339a435f155d47f718cea..3ab82ad3cb173455382a71752d1ed56c4a17d43a 100644 (file)
@@ -1,3 +1,14 @@
+2015-11-09  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Crash when right clicking in input box with -webkit-user-select: none
+        https://bugs.webkit.org/show_bug.cgi?id=145981
+        <rdar://problem/22441925>
+
+        Reviewed by Enrica Casucci.
+
+        * editing/selection/minimal-user-select-crash-expected.txt: Added.
+        * editing/selection/minimal-user-select-crash.html: Added.
+
 2015-11-09  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: $0 stops working after navigating to a different domain
diff --git a/LayoutTests/editing/selection/minimal-user-select-crash-expected.txt b/LayoutTests/editing/selection/minimal-user-select-crash-expected.txt
new file mode 100644 (file)
index 0000000..2afa0bf
--- /dev/null
@@ -0,0 +1 @@
+PASS. WebKit didn't crash.
diff --git a/LayoutTests/editing/selection/minimal-user-select-crash.html b/LayoutTests/editing/selection/minimal-user-select-crash.html
new file mode 100644 (file)
index 0000000..ebc1ca8
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    #search-text {
+        -webkit-user-select: none;
+    }
+</style>
+
+<script src="../editing.js"></script>
+
+<script>
+    if (window.testRunner)
+        testRunner.dumpAsText();
+
+    function editingTest() {
+        var element = document.getElementById('search-text');
+        element.focus();
+
+        if (window.eventSender) {
+            eventSender.mouseMoveTo(element.offsetLeft, element.offsetTop);
+            eventSender.contextClick();
+
+            document.write("PASS. WebKit didn't crash.")
+        }
+    }
+</script>
+</head>
+<body onload=editingTest()>
+    <input id="search-text">
+</body>
+</html>
index b83e7d3adae0b6ffa254194c603873d1bf74b4fc..3a2c198a35c49fd5f5d786fa9c76d91d594d452b 100644 (file)
@@ -2466,6 +2466,7 @@ tables/mozilla_expected_failures/other/test4.html [ Failure ]
 editing/selection/extend-selection-home-end.html
 editing/spelling/spellcheck-async.html
 editing/style/style-text-node-without-editable-parent.html
+editing/selection/minimal-user-select-crash.html
 
 # Editing tests that fail:
 editing/deleting/delete-emoji.html [ Failure ]
index f311a3de27d7670a27d5c5afb8ce63af41c2f6a0..61771de60a4ed130b130d3e31c575c30e0179f13 100644 (file)
@@ -1,3 +1,17 @@
+2015-11-09  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Crash when right clicking in input box with -webkit-user-select: none
+        https://bugs.webkit.org/show_bug.cgi?id=145981
+        <rdar://problem/22441925>
+
+        Reviewed by Enrica Casucci.
+
+        Test: editing/selection/minimal-user-select-crash.html
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::hasBidiSelection):
+        Visible position cannot be created because of the style that doesn't allow the selection.
+
 2015-11-09  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: $0 stops working after navigating to a different domain
index d4b0fadb6e5b75543af08966b43e244cfc51c719..af5286dc91eafeeaa0aab6a965f46f7c98250dec 100644 (file)
@@ -708,6 +708,9 @@ bool Editor::hasBidiSelection() const
     } else
         startNode = m_frame.selection().selection().visibleStart().deepEquivalent().deprecatedNode();
 
+    if (!startNode)
+        return false;
+
     auto renderer = startNode->renderer();
     while (renderer && !is<RenderBlockFlow>(*renderer))
         renderer = renderer->parent();