Bug 1114853 - Part 4: Bail out if selections are mismatch. r=roc
authorMorris Tseng <mtseng@mozilla.com>
Mon, 29 Dec 2014 20:02:00 +0100
changeset 247690 0b2e3bcfe0d579ca7b92d95a95ea16b9113d6e45
parent 247689 8576d2d7cdfb13e1297d31e533566ea290a51f15
child 247691 7200cfff578b603b6a29cd59eb43bf95c5653528
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1114853
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1114853 - Part 4: Bail out if selections are mismatch. r=roc
dom/browser-element/mochitest/browserElement_CopyPaste.js
layout/base/SelectionCarets.cpp
--- a/dom/browser-element/mochitest/browserElement_CopyPaste.js
+++ b/dom/browser-element/mochitest/browserElement_CopyPaste.js
@@ -64,16 +64,17 @@ function runTest() {
 function doCommand(cmd) {
   Services.obs.notifyObservers({wrappedJSObject: iframe},
                                'copypaste-docommand', cmd);
 }
 
 function dispatchTest(e) {
   iframe.addEventListener("mozbrowserloadend", function onloadend2(e) {
     iframe.removeEventListener("mozbrowserloadend", onloadend2);
+    iframe.focus();
     SimpleTest.executeSoon(function() { testSelectAll(e); });
   });
 
   switch (state) {
     case 0: // test for textarea
       defaultData = "Test for selection change event";
       pasteData = "from parent ";
       iframe.src = "data:text/html,<html><body>" +
--- a/layout/base/SelectionCarets.cpp
+++ b/layout/base/SelectionCarets.cpp
@@ -1084,16 +1084,22 @@ SelectionCarets::NotifyBlur()
 }
 
 nsresult
 SelectionCarets::NotifySelectionChanged(nsIDOMDocument* aDoc,
                                         nsISelection* aSel,
                                         int16_t aReason)
 {
   SELECTIONCARETS_LOG("aSel (%p), Reason=%d", aSel, aReason);
+
+  if (aSel != GetSelection()) {
+    SELECTIONCARETS_LOG("Return for selection mismatch!");
+    return NS_OK;
+  }
+
   if (!aReason || (aReason & (nsISelectionListener::DRAG_REASON |
                               nsISelectionListener::KEYPRESS_REASON |
                               nsISelectionListener::MOUSEDOWN_REASON))) {
     SetVisibility(false);
   } else {
     UpdateSelectionCarets();
   }