[mq]: debugSession draft
authorAlastor Wu <alwu@mozilla.com>
Wed, 17 May 2017 17:29:20 +0800
changeset 579404 08ca5fe8aabf1d8d0628dcce26a83d1be11a08c6
parent 579403 bc0612caf63489c0502d3444268248a2f24ece16
child 579405 acf6604aa09e9f808a576a4e01d659c65f819acd
push id59241
push useralwu@mozilla.com
push dateWed, 17 May 2017 09:37:57 +0000
milestone55.0a1
[mq]: debugSession MozReview-Commit-ID: DEnKiDNMkhk
browser/base/content/tabbrowser.xml
browser/components/extensions/test/browser/browser_ext_sessions_restore.js
browser/components/sessionstore/SessionStore.jsm
toolkit/content/widgets/browser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -2064,17 +2064,17 @@
         "goHome", "homePage", "gotoIndex", "currentURI", "documentURI",
         "preferences", "imageDocument", "isRemoteBrowser", "messageManager",
         "getTabBrowser", "finder", "fastFind", "sessionHistory", "contentTitle",
         "characterSet", "fullZoom", "textZoom", "webProgress",
         "addProgressListener", "removeProgressListener", "audioPlaybackStarted",
         "audioPlaybackStopped", "pauseMedia", "stopMedia",
         "blockMedia", "resumeMedia", "mute", "unmute", "blockedPopups", "lastURI",
         "purgeSessionHistory", "stopScroll", "startScroll",
-        "userTypedValue", "userTypedClear", "mediaBlocked"
+        "userTypedValue", "userTypedClear", "mediaBlocked", "testOnly"
       ]</field>
 
       <method name="_createLazyBrowser">
         <parameter name="aTab"/>
         <body>
           <![CDATA[
             let browser = aTab.linkedBrowser;
 
@@ -2119,24 +2119,25 @@
                       return { permitUnload: true, timedOut: false };
                     };
                   };
                   break;
                 case "reload":
                 case "reloadWithFlags":
                 case "blockMedia":
                 case "resumeMedia":
+                case "testOnly":
                   getter = () => {
                     return (params) => {
                       // Wait for load handler to be instantiated before
                       // initializing the reload.
                       aTab.addEventListener("SSTabRestoring", () => {
                         browser[name](params);
                       }, { once: true });
-                      gBrowser._insertBrowser(aTab);
+                      //gBrowser._insertBrowser(aTab);
                     };
                   };
                   break;
                 case "userTypedValue":
                 case "userTypedClear":
                 case "mediaBlocked":
                   getter = () => {
                     return SessionStore.getLazyTabValue(aTab, name);
@@ -7421,19 +7422,21 @@
         <body>
         <![CDATA[
           let tabContainer = this.parentNode;
           let browser = this.linkedBrowser;
 
           let modifiedAttrs = [];
           if (aBlock) {
             this.setAttribute("media-blocked", true);
+            browser.testOnly();
             browser.blockMedia();
           } else {
             this.removeAttribute("media-blocked");
+            browser.testOnly();
             browser.resumeMedia();
           }
           modifiedAttrs.push("media-blocked");
           tabContainer.tabbrowser._tabAttrModified(this, modifiedAttrs);
         ]]>
         </body>
       </method>
 
--- a/browser/components/extensions/test/browser/browser_ext_sessions_restore.js
+++ b/browser/components/extensions/test/browser/browser_ext_sessions_restore.js
@@ -76,49 +76,54 @@ add_task(async function test_sessions_re
 
   extension.sendMessage("check-sessions");
   let recentlyClosed = await extension.awaitMessage("recentlyClosed");
 
   // Check that our expected window is the most recently closed.
   is(recentlyClosed[0].window.tabs.length, 3, "most recently closed window has the expected number of tabs");
 
   // Restore the window.
+  info("===== Restore the window");
   extension.sendMessage("restore");
   await assertNotificationCount(2);
   let restored = await extension.awaitMessage("restored");
 
   is(restored.window.tabs.length, 3, "restore returned a window with the expected number of tabs");
   checkLocalTab(restored.window.tabs[0], "about:config");
   checkLocalTab(restored.window.tabs[1], "about:robots");
   checkLocalTab(restored.window.tabs[2], "about:mozilla");
 
   // Close the window again.
+  info("===== Close the window again");
   let window = windowTracker.getWindow(restored.window.id);
   await BrowserTestUtils.closeWindow(window);
   await assertNotificationCount(3);
 
   // Restore the window using the sessionId.
+  info("===== Restore the window using the sessionId.");
   extension.sendMessage("check-sessions");
   recentlyClosed = await extension.awaitMessage("recentlyClosed");
   extension.sendMessage("restore", recentlyClosed[0].window.sessionId);
   await assertNotificationCount(4);
   restored = await extension.awaitMessage("restored");
 
   is(restored.window.tabs.length, 3, "restore returned a window with the expected number of tabs");
   checkLocalTab(restored.window.tabs[0], "about:config");
   checkLocalTab(restored.window.tabs[1], "about:robots");
   checkLocalTab(restored.window.tabs[2], "about:mozilla");
 
   // Close the window again.
+  info("===== Close the window again");
   window = windowTracker.getWindow(restored.window.id);
   await BrowserTestUtils.closeWindow(window);
   // notificationCount = yield extension.awaitMessage("notificationCount");
   await assertNotificationCount(5);
 
   // Open and close a tab.
+  info("===== Open and close a tab.");
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:robots");
   await TabStateFlusher.flush(tab.linkedBrowser);
   await BrowserTestUtils.removeTab(tab);
   await assertNotificationCount(6);
 
   // Restore the most recently closed item.
   extension.sendMessage("restore");
   await assertNotificationCount(7);
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -3254,16 +3254,17 @@ var SessionStoreInternal = {
       selectTab = parseInt(winData.selected || 1, 10);
       selectTab = Math.max(selectTab, 1);
       selectTab = Math.min(selectTab, winData.tabs.length);
     }
 
     let tabbrowser = aWindow.gBrowser;
     let tabsToRemove = overwriteTabs ? tabbrowser.browsers.length : 0;
     let newTabCount = winData.tabs.length;
+    dump("DD | newTabCount = " + newTabCount + "\n");
     var tabs = [];
 
     // disable smooth scrolling while adding, moving, removing and selecting tabs
     let tabstrip = tabbrowser.tabContainer.mTabstrip;
     let smoothScroll = tabstrip.smoothScroll;
     tabstrip.smoothScroll = false;
 
     // We need to keep track of the initially open tabs so that they
@@ -3279,26 +3280,29 @@ var SessionStoreInternal = {
     for (var t = 0; t < newTabCount; t++) {
       let tabData = winData.tabs[t];
 
       let userContextId = tabData.userContextId;
       let select = t == selectTab - 1;
       let createLazyBrowser = restoreTabsLazily && !select && !tabData.pinned;
 
       let url = "about:blank";
+      dump("DD | @@@@@@@ createLazyBrowser = " + createLazyBrowser + "\n");
+
       if (createLazyBrowser) {
         // Let tabbrowser know the future URI because progress listeners won't
         // get onLocationChange notification before the browser is inserted.
         let activeIndex = (tabData.index || tabData.entries.length) - 1;
         url = tabData.entries[activeIndex].url;
       }
 
       // Setting noInitialLabel is a perf optimization. Rendering tab labels
       // would make resizing the tabs more expensive as we're adding them.
       // Each tab will get its initial label set in restoreTab.
+      dump("DD | @@@@@@@ url = " + url + "\n");
       let tab = tabbrowser.addTab(url,
                                   { createLazyBrowser,
                                     skipAnimation: true,
                                     noInitialLabel: true,
                                     userContextId,
                                     skipBackgroundNotify: true });
 
       if (select) {
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -829,16 +829,24 @@
               let event = document.createEvent("Events");
               event.initEvent("DOMAudioPlaybackBlockStopped", true, false);
               this.dispatchEvent(event);
             }
           ]]>
         </body>
       </method>
 
+      <method name="testOnly">
+        <body>
+          <![CDATA[
+            return;
+          ]]>
+        </body>
+      </method>
+
       <property name="securityUI">
         <getter>
           <![CDATA[
             if (!this.docShell.securityUI) {
               const SECUREBROWSERUI_CONTRACTID = "@mozilla.org/secure_browser_ui;1";
               if (!this.hasAttribute("disablesecurity") &&
                   SECUREBROWSERUI_CONTRACTID in Components.classes) {
                 var securityUI = Components.classes[SECUREBROWSERUI_CONTRACTID]