[WK1] Null dereference loading Blink layout test editing/input/text-input-controller...
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Nov 2015 02:47:50 +0000 (02:47 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Nov 2015 02:47:50 +0000 (02:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149484
<rdar://problem/22811338>

Reviewed by Darin Adler.

Source/WebKit/mac:

firstRectForCharacterRange(): don't fall over in an editable-less frame.

* WebView/WebFrame.mm:
(-[WebFrame _convertToDOMRange:]):

LayoutTests:

This test is from Blink r194870:
https://codereview.chromium.org/1122593004

* editing/mac/input/text-input-controller-no-editable-no-crash-expected.txt: Added.
* editing/mac/input/text-input-controller-no-editable-no-crash.html: Added.
* platform/wk2/TestExpectations:

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

LayoutTests/ChangeLog
LayoutTests/editing/mac/input/text-input-controller-no-editable-no-crash-expected.txt [new file with mode: 0644]
LayoutTests/editing/mac/input/text-input-controller-no-editable-no-crash.html [new file with mode: 0644]
LayoutTests/platform/wk2/TestExpectations
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebFrame.mm

index 0eec17bbbad808f3c9c28bdd54aee86dde90c257..6f362829a6f88626491133bcefcf52de42226250 100644 (file)
@@ -1,3 +1,18 @@
+2015-11-03  Jiewen Tan  <jiewen_tan@apple.com>
+
+        [WK1] Null dereference loading Blink layout test editing/input/text-input-controller-no-editable-no-crash.html
+        https://bugs.webkit.org/show_bug.cgi?id=149484
+        <rdar://problem/22811338>
+
+        Reviewed by Darin Adler.
+
+        This test is from Blink r194870:
+        https://codereview.chromium.org/1122593004
+
+        * editing/mac/input/text-input-controller-no-editable-no-crash-expected.txt: Added.
+        * editing/mac/input/text-input-controller-no-editable-no-crash.html: Added.
+        * platform/wk2/TestExpectations:
+
 2015-11-03  Alexey Proskuryakov  <ap@apple.com>
 
         [iOS] Skip the touch tests
diff --git a/LayoutTests/editing/mac/input/text-input-controller-no-editable-no-crash-expected.txt b/LayoutTests/editing/mac/input/text-input-controller-no-editable-no-crash-expected.txt
new file mode 100644 (file)
index 0000000..f758dc8
--- /dev/null
@@ -0,0 +1 @@
+PASS, WebKit didn't crash.
diff --git a/LayoutTests/editing/mac/input/text-input-controller-no-editable-no-crash.html b/LayoutTests/editing/mac/input/text-input-controller-no-editable-no-crash.html
new file mode 100644 (file)
index 0000000..0232a3b
--- /dev/null
@@ -0,0 +1,16 @@
+<html>
+<body onload="runTest();">
+<script>
+    if (window.testRunner)
+        testRunner.dumpAsText();
+
+    function runTest()
+    {
+        document.open();
+        if (window.textInputController)
+            textInputController.firstRectForCharacterRange(0, 0);
+        document.write("PASS, WebKit didn't crash.");
+    }
+</script>
+</body>
+</html>
index 11a6e0e3833ce96fcac58cf0129d9fb0b8f93a39..b33ddb3fc56bfe57ef91a891ebc56551c36e2951 100644 (file)
@@ -101,6 +101,7 @@ editing/mac/input/range-for-empty-document.html
 editing/mac/input/replace-invalid-range.html
 editing/mac/input/secure-input.html
 editing/mac/input/text-input-controller.html
+editing/mac/input/text-input-controller-no-editable-no-crash.html
 editing/mac/input/wrapped-line-char-rect.html
 editing/mac/input/NSBackgroundColor-transparent.html
 editing/mac/pasteboard/paste-and-match-style-selector-event.html
index fb5ef03571f04efafd46ee2c0f38e33ee9ac5275..4e183a479e7397514c2070b4755c6dabbae85afd 100644 (file)
@@ -1,3 +1,16 @@
+2015-11-03  Jiewen Tan  <jiewen_tan@apple.com>
+
+        [WK1] Null dereference loading Blink layout test editing/input/text-input-controller-no-editable-no-crash.html
+        https://bugs.webkit.org/show_bug.cgi?id=149484
+        <rdar://problem/22811338>
+
+        Reviewed by Darin Adler.
+
+        firstRectForCharacterRange(): don't fall over in an editable-less frame.
+
+        * WebView/WebFrame.mm:
+        (-[WebFrame _convertToDOMRange:]):
+
 2015-11-02  Andy Estes  <aestes@apple.com>
 
         [Cocoa] Add tvOS and watchOS to SUPPORTED_PLATFORMS
index d11518f5e7147719866749b8a6e170ea453f21a8..c5c7e7d1ac7ed342ae7868de5e801a652354651d 100644 (file)
@@ -807,7 +807,10 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     // directly in the document DOM, so serialization is problematic. Our solution is
     // to use the root editable element of the selection start as the positional base.
     // That fits with AppKit's idea of an input context.
-    return TextIterator::rangeFromLocationAndLength(_private->coreFrame->selection().rootEditableElementOrDocumentElement(), nsrange.location, nsrange.length);
+    Element* element = _private->coreFrame->selection().rootEditableElementOrDocumentElement();
+    if (!element)
+        return nil;
+    return TextIterator::rangeFromLocationAndLength(element, nsrange.location, nsrange.length);
 }
 
 - (DOMRange *)_convertNSRangeToDOMRange:(NSRange)nsrange