Bug 1155493 - Part 4: Add test for mozbrowsercaretstatechanged. r=kchen
☠☠ backed out by cb33de12c0b5 ☠ ☠
authorMorris Tseng <mtseng@mozilla.com>
Tue, 19 May 2015 21:00:00 -0400
changeset 245486 3bd7adb9f591c5eb7b234085537a7f82ecd361f2
parent 245485 0380b1684e6b9f0c0cc20c27e30c32e0bd62657d
child 245487 5b10bbf31fe5bcbe96f1a5009654ad441caa1879
push id28806
push userphilringnalda@gmail.com
push dateTue, 26 May 2015 02:10:16 +0000
treeherdermozilla-central@4362d9251296 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskchen
bugs1155493
milestone41.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 1155493 - Part 4: Add test for mozbrowsercaretstatechanged. r=kchen
dom/browser-element/mochitest/browserElementTestHelpers.js
dom/browser-element/mochitest/browserElement_CopyPaste.js
--- a/dom/browser-element/mochitest/browserElementTestHelpers.js
+++ b/dom/browser-element/mochitest/browserElementTestHelpers.js
@@ -60,16 +60,20 @@ const browserElementTestHelpers = {
   setEnabledPref: function(value) {
     this._setPref('dom.mozBrowserFramesEnabled', value);
   },
 
   setSelectionChangeEnabledPref: function(value) {
     this._setPref('selectioncaret.enabled', value);
   },
 
+  setAccessibleCaretEnabledPref: function(value) {
+    this._setPref('layout.accessiblecaret.enabled', value);
+  },
+
   getOOPByDefaultPref: function() {
     return this._getBoolPref("dom.ipc.browser_frames.oop_by_default");
   },
 
   addPermission: function() {
     this.lockTestReady();
     SpecialPowers.pushPermissions(
       [{'type': "browser", 'allow': 1, 'context': document}],
--- a/dom/browser-element/mochitest/browserElement_CopyPaste.js
+++ b/dom/browser-element/mochitest/browserElement_CopyPaste.js
@@ -16,16 +16,17 @@ var mm;
 var iframeOuter;
 var iframeInner;
 var state = 0;
 var stateMeaning;
 var defaultData;
 var pasteData;
 var focusScript;
 var createEmbededFrame = false;
+var testAccessibleCaret = false;
 
 function copyToClipboard(str) {
   gTextarea.value = str;
   SpecialPowers.wrap(gTextarea).editor.selectAll();
   SpecialPowers.wrap(gTextarea).editor.copy();
 }
 
 function getScriptForGetContent() {
@@ -155,47 +156,58 @@ function dispatchTest(e) {
                    "</body>" +
                    "<script>document.designMode='on';</script>" +
                    "</html>";
       stateMeaning = " (test: normal div with designMode:on)";
       focusScript = "var elt=content.document.getElementById('text');elt.focus();";
       break;
     default:
       if (createEmbededFrame || browserElementTestHelpers.getOOPByDefaultPref()) {
-        SimpleTest.finish();
+        if (testAccessibleCaret) {
+          SimpleTest.finish();
+          return;
+        } else {
+          testAccessibleCaret = true;
+          createEmbededFrame = false;
+          browserElementTestHelpers.setSelectionChangeEnabledPref(false);
+          browserElementTestHelpers.setAccessibleCaretEnabledPref(true);
+        }
       } else {
         createEmbededFrame = true;
+      }
 
-        // clean up and run test again.
-        document.body.removeChild(iframeOuter);
-        document.body.removeChild(gTextarea);
-        state = 0;
-        runTest();
-      }
+      // clean up and run test again.
+      document.body.removeChild(iframeOuter);
+      document.body.removeChild(gTextarea);
+      state = 0;
+      runTest();
       break;
   }
 }
 
 function isChildProcess() {
   return SpecialPowers.Cc["@mozilla.org/xre/app-info;1"]
                          .getService(SpecialPowers.Ci.nsIXULRuntime)
                          .processType != SpecialPowers.Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
 }
 
 function testSelectAll(e) {
   // Skip mozbrowser test if we're at child process.
   if (!isChildProcess()) {
-    iframeOuter.addEventListener("mozbrowserselectionstatechanged", function selectchangeforselectall(e) {
-      if (e.detail.states.indexOf('selectall') == 0) {
-        iframeOuter.removeEventListener("mozbrowserselectionstatechanged", selectchangeforselectall, true);
+    let eventName = testAccessibleCaret ? "mozbrowsercaretstatechanged" : "mozbrowserselectionstatechanged";
+    iframeOuter.addEventListener(eventName, function selectchangeforselectall(e) {
+      if (!e.detail.states || e.detail.states.indexOf('selectall') == 0) {
+        iframeOuter.removeEventListener(eventName, selectchangeforselectall, true);
         ok(true, "got mozbrowserselectionstatechanged event." + stateMeaning);
         ok(e.detail, "event.detail is not null." + stateMeaning);
         ok(e.detail.width != 0, "event.detail.width is not zero" + stateMeaning);
         ok(e.detail.height != 0, "event.detail.height is not zero" + stateMeaning);
-        ok(e.detail.states, "event.detail.state " + e.detail.states);
+        if (!testAccessibleCaret) {
+          ok(e.detail.states, "event.detail.state " + e.detail.states);
+        }
         SimpleTest.executeSoon(function() { testCopy1(e); });
       }
     }, true);
   }
 
   mm.addMessageListener('content-focus', function messageforfocus(msg) {
     mm.removeMessageListener('content-focus', messageforfocus);
     // test selectall command, after calling this the selectionstatechanged event should be fired.