Bug 1348960 - Expose openLinkIn for RDM tabs. r=ochameau
authorJ. Ryan Stinnett <jryans@gmail.com>
Tue, 03 Oct 2017 22:34:07 -0700
changeset 427125 891602480e23b5ab1ae61458d3b7111ba8c3928f
parent 427124 72af2f1919fe2b279e54c094e918faa1fbbeebb7
child 427126 71267c7616d7590ade25ccb693f5c5f6fe0f1554
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
reviewersochameau
bugs1348960
milestone58.0a1
Bug 1348960 - Expose openLinkIn for RDM tabs. r=ochameau MozReview-Commit-ID: 2EzZfBsNIrf
devtools/client/responsive.html/browser/tunnel.js
devtools/client/responsive.html/test/browser/browser.ini
devtools/client/responsive.html/test/browser/browser_cmd_click.js
devtools/client/responsive.html/test/browser/browser_target_blank.js
--- a/devtools/client/responsive.html/browser/tunnel.js
+++ b/devtools/client/responsive.html/browser/tunnel.js
@@ -46,19 +46,20 @@ const SWAPPED_BROWSER_STATE = [
  * When RDM is enabled, these bits of code instead reach the RDM tool's window instead of
  * the browser window, which won't have the properties they are looking for. At the
  * moment, we address this by exposing them from the browser window on RDM's window as
  * needed.
  */
 const PROPERTIES_FROM_BROWSER_WINDOW = [
   // This is used by PermissionUI.jsm for permission doorhangers.
   "PopupNotifications",
-  // This is used by ContentClick.jsm when opening links in ways other than just
-  // navigating the viewport.
+  // These are used by ContentClick.jsm when opening links in ways other than just
+  // navigating the viewport, such as a new tab by pressing Cmd-Click.
   "whereToOpenLink",
+  "openLinkIn",
   // This is used by various event handlers, typically to call `getTabForBrowser` to map
   // a browser back to a tab.
   "gBrowser",
 ];
 
 /**
  * This module takes an "outer" <xul:browser> from a browser tab as described by
  * Firefox's tabbrowser.xml and wires it up to an "inner" <iframe mozbrowser>
--- a/devtools/client/responsive.html/test/browser/browser.ini
+++ b/devtools/client/responsive.html/test/browser/browser.ini
@@ -12,16 +12,17 @@ support-files =
   touch.html
   !/devtools/client/commandline/test/helpers.js
   !/devtools/client/framework/test/shared-head.js
   !/devtools/client/framework/test/shared-redux-head.js
   !/devtools/client/inspector/test/shared-head.js
   !/devtools/client/shared/test/test-actor.js
   !/devtools/client/shared/test/test-actor-registry.js
 
+[browser_cmd_click.js]
 [browser_device_change.js]
 [browser_device_custom.js]
 [browser_device_modal_error.js]
 [browser_device_modal_exit.js]
 [browser_device_modal_submit.js]
 [browser_device_width.js]
 [browser_dpr_change.js]
 [browser_exit_button.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/responsive.html/test/browser/browser_cmd_click.js
@@ -0,0 +1,29 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Ensure Cmd/Ctrl-clicking link opens a new tab
+
+const TAB_URL = "http://example.com/";
+const TEST_URL =
+  `data:text/html,<a href="${TAB_URL}">Click me</a>`
+  .replace(/ /g, "%20");
+
+addRDMTask(TEST_URL, function* ({ ui }) {
+  let store = ui.toolWindow.store;
+
+  // Wait until the viewport has been added
+  yield waitUntilState(store, state => state.viewports.length == 1);
+
+  // Cmd-click the link and wait for a new tab
+  yield waitForFrameLoad(ui, TEST_URL);
+  let newTabPromise = BrowserTestUtils.waitForNewTab(gBrowser, TAB_URL);
+  BrowserTestUtils.synthesizeMouseAtCenter("a", {
+    ctrlKey: true,
+    metaKey: true,
+  }, ui.getViewportBrowser());
+  let newTab = yield newTabPromise;
+  ok(newTab, "New tab opened from link");
+  yield removeTab(newTab);
+});
--- a/devtools/client/responsive.html/test/browser/browser_target_blank.js
+++ b/devtools/client/responsive.html/test/browser/browser_target_blank.js
@@ -13,14 +13,16 @@ const TEST_URL =
 addRDMTask(TEST_URL, function* ({ ui }) {
   let store = ui.toolWindow.store;
 
   // Wait until the viewport has been added
   yield waitUntilState(store, state => state.viewports.length == 1);
 
   // Click the target="_blank" link and wait for a new tab
   yield waitForFrameLoad(ui, TEST_URL);
-  let newTab = BrowserTestUtils.waitForNewTab(gBrowser, TAB_URL);
+  let newTabPromise = BrowserTestUtils.waitForNewTab(gBrowser, TAB_URL);
   spawnViewportTask(ui, {}, function* () {
     content.document.querySelector("a").click(); // eslint-disable-line
   });
-  ok(yield newTab, "New tab opened from link");
+  let newTab = yield newTabPromise;
+  ok(newTab, "New tab opened from link");
+  yield removeTab(newTab);
 });