Bug 1495342 - Add 'Reload and Record Tab' menu item and functionality, r=jlast.
authorBrian Hackett <bhackett1024@gmail.com>
Mon, 01 Oct 2018 09:42:50 -1000
changeset 494827 caabdeb2d3d4a8a13bc19abad0ef1a1a292bbe88
parent 494826 a14e1d156c61ce3534ef13f6741fc9f84cf125a6
child 494828 1d68c706356c4da6d5c50770d08c6d2cccf38c49
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlast
bugs1495342
milestone64.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 1495342 - Add 'Reload and Record Tab' menu item and functionality, r=jlast.
browser/base/content/tabbrowser.js
devtools/client/locales/en-US/menus.properties
devtools/client/webreplay/menu.js
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -1549,16 +1549,17 @@ window._gBrowser = {
     }
   },
 
   updateBrowserRemoteness(aBrowser, aShouldBeRemote, {
     newFrameloader,
     opener,
     remoteType,
     sameProcessAsFrameLoader,
+    recordExecution,
   } = {}) {
     let isRemote = aBrowser.getAttribute("remote") == "true";
 
     if (!gMultiProcessBrowser && aShouldBeRemote) {
       throw new Error("Cannot switch to remote browser in a window " +
         "without the remote tabs load context.");
     }
 
@@ -1622,16 +1623,24 @@ window._gBrowser = {
     if (aShouldBeRemote) {
       aBrowser.setAttribute("remote", "true");
       aBrowser.setAttribute("remoteType", remoteType);
     } else {
       aBrowser.setAttribute("remote", "false");
       aBrowser.removeAttribute("remoteType");
     }
 
+    if (recordExecution) {
+      aBrowser.setAttribute("recordExecution", recordExecution);
+
+      // Web Replay middleman processes need the default URL to be loaded in
+      // order to set up their rendering state.
+      aBrowser.setAttribute("nodefaultsrc", "false");
+    }
+
     // NB: This works with the hack in the browser constructor that
     // turns this normal property into a field.
     if (sameProcessAsFrameLoader) {
       // Always set sameProcessAsFrameLoader when passed in explicitly.
       aBrowser.sameProcessAsFrameLoader = sameProcessAsFrameLoader;
     } else if (!aShouldBeRemote || oldRemoteType == remoteType) {
       // Only copy existing sameProcessAsFrameLoader when not switching
       // remote type otherwise it would stop the switch.
--- a/devtools/client/locales/en-US/menus.properties
+++ b/devtools/client/locales/en-US/menus.properties
@@ -41,16 +41,17 @@ browserToolboxMenu.accesskey = e
 browserContentToolboxMenu.label = Browser Content Toolbox
 browserContentToolboxMenu.accesskey = x
 
 webide.label = WebIDE
 webide.accesskey = W
 
 devtoolsWebReplay.label = Web Replay
 devtoolsRecordNewTab.label = Open New Recording Tab
+devtoolsReloadAndRecordTab.label = Reload and Record Tab
 devtoolsSaveRecording.label = Save Recording
 devtoolsReplayNewTab.label = Load Recording in New Tab
 
 devToolboxMenuItem.label = Toggle Tools
 devToolboxMenuItem.accesskey = T
 
 getMoreDevtoolsCmd.label = Get More Tools
 getMoreDevtoolsCmd.accesskey = M
--- a/devtools/client/webreplay/menu.js
+++ b/devtools/client/webreplay/menu.js
@@ -18,16 +18,26 @@ const ChromeUtils = require("ChromeUtils
 ChromeUtils.defineModuleGetter(this, "Services",
                                "resource://gre/modules/Services.jsm");
 
 function RecordNewTab() {
   const { gBrowser } = Services.wm.getMostRecentWindow("navigator:browser");
   gBrowser.selectedTab = gBrowser.addWebTab("about:blank", { recordExecution: "*" });
 }
 
+function ReloadAndRecordTab() {
+  const { gBrowser } = Services.wm.getMostRecentWindow("navigator:browser");
+  const url = gBrowser.currentURI.spec;
+  gBrowser.updateBrowserRemoteness(gBrowser.selectedBrowser, true,
+                                   { recordExecution: "*", newFrameloader: true });
+  gBrowser.loadURI(url, {
+    triggeringPrincipal: gBrowser.selectedBrowser.contentPrincipal,
+  });
+}
+
 function SaveRecording() {
   const { gBrowser } = Services.wm.getMostRecentWindow("navigator:browser");
   const fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
   const window = gBrowser.ownerGlobal;
   fp.init(window, null, Ci.nsIFilePicker.modeSave);
   fp.open(rv => {
     if (rv == Ci.nsIFilePicker.returnOK || rv == Ci.nsIFilePicker.returnReplace) {
       const tabParent = gBrowser.selectedTab.linkedBrowser.frameLoader.tabParent;
@@ -47,16 +57,17 @@ function ReplayNewTab() {
     if (rv == Ci.nsIFilePicker.returnOK || rv == Ci.nsIFilePicker.returnReplace) {
       gBrowser.selectedTab = gBrowser.addWebTab(null, { replayExecution: fp.file.path });
     }
   });
 }
 
 const menuItems = [
   { id: "devtoolsRecordNewTab", command: RecordNewTab },
+  { id: "devtoolsReloadAndRecordTab", command: ReloadAndRecordTab },
   { id: "devtoolsSaveRecording", command: SaveRecording },
   { id: "devtoolsReplayNewTab", command: ReplayNewTab },
 ];
 
 exports.addWebReplayMenu = function(doc) {
   const menu = doc.createXULElement("menu");
   menu.id = "menu_webreplay";
   menu.setAttribute("label", l10n("devtoolsWebReplay.label"));