Bug 1295556 - Use waitForClipboardPromise from shared-head.js in Inspector tests r=jsnajdr
authorShubheksha Jalan <jshubheksha@gmail.com>
Mon, 12 Sep 2016 22:39:28 +0530
changeset 355099 8921c2b2b569b56c94f0f8f217c5356b9ed79c63
parent 355098 307a8048995a663287d224d0313e4cf49c3d0cdd
child 355100 4c2d01fe1c38a9829008491681f3dd773b760bc4
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjsnajdr
bugs1295556
milestone51.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 1295556 - Use waitForClipboardPromise from shared-head.js in Inspector tests r=jsnajdr MozReview-Commit-ID: 5fB7Wz1jLGe
devtools/client/inspector/computed/test/browser_computed_search-filter_context-menu.js
devtools/client/inspector/computed/test/browser_computed_select-and-copy-styles.js
devtools/client/inspector/rules/test/browser_rules_copy_styles.js
devtools/client/inspector/rules/test/browser_rules_search-filter_context-menu.js
devtools/client/inspector/rules/test/browser_rules_select-and-copy-styles.js
devtools/client/inspector/shared/test/browser_styleinspector_context-menu-copy-color_02.js
devtools/client/inspector/shared/test/browser_styleinspector_context-menu-copy-urls.js
devtools/client/inspector/test/browser_inspector_highlighter-eyedropper-clipboard.js
devtools/client/inspector/test/browser_inspector_keyboard-shortcuts-copy-outerhtml.js
devtools/client/inspector/test/browser_inspector_menu-02-copy-items.js
devtools/client/inspector/test/browser_inspector_search-filter_context-menu.js
devtools/client/inspector/test/head.js
--- a/devtools/client/inspector/computed/test/browser_computed_search-filter_context-menu.js
+++ b/devtools/client/inspector/computed/test/browser_computed_search-filter_context-menu.js
@@ -47,17 +47,17 @@ add_task(function* () {
   yield onContextMenuHidden;
 
   info("Copy text in search field using the context menu");
   searchField.value = TEST_INPUT;
   searchField.select();
   EventUtils.synthesizeMouse(searchField, 2, 2,
     {type: "contextmenu", button: 2}, win);
   yield onContextMenuPopup;
-  yield waitForClipboard(() => cmdCopy.click(), TEST_INPUT);
+  yield waitForClipboardPromise(() => cmdCopy.click(), TEST_INPUT);
   searchContextMenu.hidePopup();
   yield onContextMenuHidden;
 
   info("Reopen context menu and check command properties");
   EventUtils.synthesizeMouse(searchField, 2, 2,
     {type: "contextmenu", button: 2}, win);
   yield onContextMenuPopup;
 
--- a/devtools/client/inspector/computed/test/browser_computed_select-and-copy-styles.js
+++ b/devtools/client/inspector/computed/test/browser_computed_select-and-copy-styles.js
@@ -57,17 +57,17 @@ function* checkCopySelection(view) {
   info("Checking that cssHtmlTree.siBoundCopy() returns the correct " +
     "clipboard value");
 
   let expectedPattern = "font-family: helvetica,sans-serif;[\\r\\n]+" +
                         "font-size: 16px;[\\r\\n]+" +
                         "font-variant-caps: small-caps;[\\r\\n]*";
 
   try {
-    yield waitForClipboard(() => fireCopyEvent(props[0]),
+    yield waitForClipboardPromise(() => fireCopyEvent(props[0]),
                            () => checkClipboardData(expectedPattern));
   } catch (e) {
     failedClipboard(expectedPattern);
   }
 }
 
 function* checkSelectAll(view) {
   info("Testing select-all copy");
@@ -79,17 +79,17 @@ function* checkSelectAll(view) {
     "clipboard value");
   view._contextmenu._onSelectAll();
   let expectedPattern = "color: rgb\\(255, 255, 0\\);[\\r\\n]+" +
                         "font-family: helvetica,sans-serif;[\\r\\n]+" +
                         "font-size: 16px;[\\r\\n]+" +
                         "font-variant-caps: small-caps;[\\r\\n]*";
 
   try {
-    yield waitForClipboard(() => fireCopyEvent(prop),
+    yield waitForClipboardPromise(() => fireCopyEvent(prop),
                            () => checkClipboardData(expectedPattern));
   } catch (e) {
     failedClipboard(expectedPattern);
   }
 }
 
 function checkClipboardData(expectedPattern) {
   let actual = SpecialPowers.getClipboardData("text/unicode");
--- a/devtools/client/inspector/rules/test/browser_rules_copy_styles.js
+++ b/devtools/client/inspector/rules/test/browser_rules_copy_styles.js
@@ -262,17 +262,17 @@ function* checkCopyStyle(view, node, men
      visible.copySelector);
 
   is(menuitemCopyRule.visible,
      visible.copyRule,
      "Copy Rule visible attribute is as expected: " +
      visible.copyRule);
 
   try {
-    yield waitForClipboard(() => menuItem.click(),
+    yield waitForClipboardPromise(() => menuItem.click(),
       () => checkClipboardData(expectedPattern));
   } catch (e) {
     failedClipboard(expectedPattern);
   }
 }
 
 function* disableProperty(view, index) {
   let ruleEditor = getRuleViewRuleEditor(view, 1);
--- a/devtools/client/inspector/rules/test/browser_rules_search-filter_context-menu.js
+++ b/devtools/client/inspector/rules/test/browser_rules_search-filter_context-menu.js
@@ -46,17 +46,17 @@ add_task(function* () {
   yield onContextMenuHidden;
 
   info("Copy text in search field using the context menu");
   searchField.value = TEST_INPUT;
   searchField.select();
   EventUtils.synthesizeMouse(searchField, 2, 2,
     {type: "contextmenu", button: 2}, win);
   yield onContextMenuPopup;
-  yield waitForClipboard(() => cmdCopy.click(), TEST_INPUT);
+  yield waitForClipboardPromise(() => cmdCopy.click(), TEST_INPUT);
   searchContextMenu.hidePopup();
   yield onContextMenuHidden;
 
   info("Reopen context menu and check command properties");
   EventUtils.synthesizeMouse(searchField, 2, 2,
     {type: "contextmenu", button: 2}, win);
   yield onContextMenuPopup;
 
--- a/devtools/client/inspector/rules/test/browser_rules_select-and-copy-styles.js
+++ b/devtools/client/inspector/rules/test/browser_rules_select-and-copy-styles.js
@@ -70,17 +70,17 @@ function* checkCopySelection(view) {
   let allMenuItems = openStyleContextMenuAndGetAllItems(view, prop);
   let menuitemCopy = allMenuItems.find(item => item.label ===
     STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.copy"));
 
   ok(menuitemCopy.visible,
     "Copy menu item is displayed as expected");
 
   try {
-    yield waitForClipboard(() => menuitemCopy.click(),
+    yield waitForClipboardPromise(() => menuitemCopy.click(),
       () => checkClipboardData(expectedPattern));
   } catch (e) {
     failedClipboard(expectedPattern);
   }
 }
 
 function* checkSelectAll(view) {
   info("Testing select-all copy");
@@ -104,17 +104,17 @@ function* checkSelectAll(view) {
   let allMenuItems = openStyleContextMenuAndGetAllItems(view, prop);
   let menuitemCopy = allMenuItems.find(item => item.label ===
     STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.copy"));
 
   ok(menuitemCopy.visible,
     "Copy menu item is displayed as expected");
 
   try {
-    yield waitForClipboard(() => menuitemCopy.click(),
+    yield waitForClipboardPromise(() => menuitemCopy.click(),
       () => checkClipboardData(expectedPattern));
   } catch (e) {
     failedClipboard(expectedPattern);
   }
 }
 
 function* checkCopyEditorValue(view) {
   info("Testing CSS property editor value copy");
@@ -132,17 +132,17 @@ function* checkCopyEditorValue(view) {
   let allMenuItems = openStyleContextMenuAndGetAllItems(view, editor.input);
   let menuitemCopy = allMenuItems.find(item => item.label ===
     STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.copy"));
 
   ok(menuitemCopy.visible,
     "Copy menu item is displayed as expected");
 
   try {
-    yield waitForClipboard(() => menuitemCopy.click(),
+    yield waitForClipboardPromise(() => menuitemCopy.click(),
       () => checkClipboardData(expectedPattern));
   } catch (e) {
     failedClipboard(expectedPattern);
   }
 }
 
 function checkClipboardData(expectedPattern) {
   let actual = SpecialPowers.getClipboardData("text/unicode");
--- a/devtools/client/inspector/shared/test/browser_styleinspector_context-menu-copy-color_02.js
+++ b/devtools/client/inspector/shared/test/browser_styleinspector_context-menu-copy-color_02.js
@@ -34,17 +34,17 @@ function* testCopyToClipboard(inspector,
     .querySelector(".ruleview-colorswatch");
 
   let allMenuItems = openStyleContextMenuAndGetAllItems(view, element);
   let menuitemCopyColor = allMenuItems.find(item => item.label ===
     STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.copyColor"));
 
   ok(menuitemCopyColor.visible, "Copy color is visible");
 
-  yield waitForClipboard(() => menuitemCopyColor.click(),
+  yield waitForClipboardPromise(() => menuitemCopyColor.click(),
     "#123ABC");
 
   EventUtils.synthesizeKey("VK_ESCAPE", { });
 }
 
 function* testManualEdit(inspector, view) {
   info("Testing manually edited colors");
   yield selectNode("div", inspector);
--- a/devtools/client/inspector/shared/test/browser_styleinspector_context-menu-copy-urls.js
+++ b/devtools/client/inspector/shared/test/browser_styleinspector_context-menu-copy-urls.js
@@ -82,22 +82,22 @@ function* testCopyUrlToClipboard({view, 
   info("Context menu is displayed");
   ok(menuitemCopyUrl.visible,
      "\"Copy URL\" menu entry is displayed");
   ok(menuitemCopyImageDataUrl.visible,
      "\"Copy Image Data-URL\" menu entry is displayed");
 
   if (type == "data-uri") {
     info("Click Copy Data URI and wait for clipboard");
-    yield waitForClipboard(() => {
+    yield waitForClipboardPromise(() => {
       return menuitemCopyImageDataUrl.click();
     }, expected);
   } else {
     info("Click Copy URL and wait for clipboard");
-    yield waitForClipboard(() => {
+    yield waitForClipboardPromise(() => {
       return menuitemCopyUrl.click();
     }, expected);
   }
 
   info("Hide context menu");
 }
 
 function getBackgroundImageProperty(view, selector) {
--- a/devtools/client/inspector/test/browser_inspector_highlighter-eyedropper-clipboard.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-eyedropper-clipboard.js
@@ -18,17 +18,17 @@ add_task(function* () {
        waitForElementAttributeSet, waitForElementAttributeRemoved} = helper;
 
   info("Show the eyedropper with the copyOnSelect option");
   yield show("html", {copyOnSelect: true});
 
   info("Make sure to wait until the eyedropper is done taking a screenshot of the page");
   yield waitForElementAttributeSet("root", "drawn", helper);
 
-  yield waitForClipboard(() => {
+  yield waitForClipboardPromise(() => {
     info("Activate the eyedropper so the background color is copied");
     EventUtils.synthesizeKey("VK_RETURN", {});
   }, "#FF0000");
 
   ok(true, "The clipboard contains the right value");
 
   yield waitForElementAttributeRemoved("root", "drawn", helper);
   yield waitForElementAttributeSet("root", "hidden", helper);
--- a/devtools/client/inspector/test/browser_inspector_keyboard-shortcuts-copy-outerhtml.js
+++ b/devtools/client/inspector/test/browser_inspector_keyboard-shortcuts-copy-outerhtml.js
@@ -29,17 +29,17 @@ add_task(function* () {
 function* setSelectionNodeFront(node, inspector) {
   let updated = inspector.once("inspector-updated");
   inspector.selection.setNodeFront(node);
   yield updated;
 }
 
 function* checkClipboard(expectedText, node) {
   try {
-    yield waitForClipboard(() => fireCopyEvent(node), expectedText);
+    yield waitForClipboardPromise(() => fireCopyEvent(node), expectedText);
     ok(true, "Clipboard successfully filled with : " + expectedText);
   } catch (e) {
     ok(false, "Clipboard could not be filled with the expected text : " +
               expectedText);
   }
 }
 
 function getElementByType(inspector, type) {
--- a/devtools/client/inspector/test/browser_inspector_menu-02-copy-items.js
+++ b/devtools/client/inspector/test/browser_inspector_menu-02-copy-items.js
@@ -39,11 +39,11 @@ add_task(function* () {
   for (let {desc, id, selector, text} of COPY_ITEMS_TEST_DATA) {
     info("Testing " + desc);
     yield selectNode(selector, inspector);
 
     let allMenuItems = openContextMenuAndGetAllItems(inspector);
     let item = allMenuItems.find(i => i.id === id);
     ok(item, "The popup has a " + desc + " menu item.");
 
-    yield waitForClipboard(() => item.click(), text);
+    yield waitForClipboardPromise(() => item.click(), text);
   }
 });
--- a/devtools/client/inspector/test/browser_inspector_search-filter_context-menu.js
+++ b/devtools/client/inspector/test/browser_inspector_search-filter_context-menu.js
@@ -45,17 +45,17 @@ add_task(function* () {
   yield onContextMenuHidden;
 
   info("Copy text in search field using the context menu");
   searchBox.value = TEST_INPUT;
   searchBox.select();
   EventUtils.synthesizeMouse(searchBox, 2, 2,
     {type: "contextmenu", button: 2}, win);
   yield onContextMenuPopup;
-  yield waitForClipboard(() => cmdCopy.click(), TEST_INPUT);
+  yield waitForClipboardPromise(() => cmdCopy.click(), TEST_INPUT);
   searchContextMenu.hidePopup();
   yield onContextMenuHidden;
 
   info("Reopen context menu and check command properties");
   EventUtils.synthesizeMouse(searchBox, 2, 2,
     {type: "contextmenu", button: 2}, win);
   yield onContextMenuPopup;
 
--- a/devtools/client/inspector/test/head.js
+++ b/devtools/client/inspector/test/head.js
@@ -614,33 +614,16 @@ function waitForStyleEditor(toolbox, hre
       panel.UI.on("editor-selected", gotEditor);
     }
   });
 
   return def.promise;
 }
 
 /**
- * @see SimpleTest.waitForClipboard
- *
- * @param {Function} setup
- *        Function to execute before checking for the
- *        clipboard content
- * @param {String|Function} expected
- *        An expected string or validator function
- * @return a promise that resolves when the expected string has been found or
- * the validator function has returned true, rejects otherwise.
- */
-function waitForClipboard(setup, expected) {
-  let def = defer();
-  SimpleTest.waitForClipboard(expected, setup, def.resolve, def.reject);
-  return def.promise;
-}
-
-/**
  * Checks if document's active element is within the given element.
  * @param  {HTMLDocument}  doc document with active element in question
  * @param  {DOMNode}       container element tested on focus containment
  * @return {Boolean}
  */
 function containsFocus(doc, container) {
   let elm = doc.activeElement;
   while (elm) {