merge m-c to fx-team
authorTim Taubert <ttaubert@mozilla.com>
Wed, 22 May 2013 09:04:44 +0200
changeset 132534 c21ef3664c67003596ec57f0c3db51388998a5b1
parent 132525 daf809df7936116ed0b1d9891e5a4b60f6a51801 (current diff)
parent 132533 a0789668bcf2bf358e13d178f802fc804af6af39 (diff)
child 132542 5c9d297e0effc9901dc61b2fd6bed7d7d55ad3f5
child 132629 ba68dd582bc1e874bc54d075bc021516bdf05071
push id24708
push userttaubert@mozilla.com
push dateWed, 22 May 2013 07:05:06 +0000
treeherdermozilla-central@c21ef3664c67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone24.0a1
first release with
nightly linux32
c21ef3664c67 / 24.0a1 / 20130522031027 / files
nightly linux64
c21ef3664c67 / 24.0a1 / 20130522031027 / files
nightly mac
c21ef3664c67 / 24.0a1 / 20130522031027 / files
nightly win32
c21ef3664c67 / 24.0a1 / 20130522031027 / files
nightly win64
c21ef3664c67 / 24.0a1 / 20130522031027 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
merge m-c to fx-team
toolkit/devtools/debugger/Makefile.in
toolkit/devtools/debugger/dbg-client.jsm
toolkit/devtools/debugger/dbg-transport.js
toolkit/devtools/debugger/moz.build
toolkit/devtools/debugger/nsIJSInspector.idl
toolkit/devtools/debugger/nsJSInspector.cpp
toolkit/devtools/debugger/nsJSInspector.h
toolkit/devtools/debugger/server/dbg-browser-actors.js
toolkit/devtools/debugger/server/dbg-profiler-actors.js
toolkit/devtools/debugger/server/dbg-script-actors.js
toolkit/devtools/debugger/server/dbg-server.js
toolkit/devtools/debugger/server/dbg-server.jsm
toolkit/devtools/debugger/tests/mochitest/Makefile.in
toolkit/devtools/debugger/tests/mochitest/moz.build
toolkit/devtools/debugger/tests/mochitest/nonchrome_unsafeDereference.html
toolkit/devtools/debugger/tests/mochitest/test_unsafeDereference.html
toolkit/devtools/debugger/tests/moz.build
toolkit/devtools/debugger/tests/unit/head_dbg.js
toolkit/devtools/debugger/tests/unit/post_init_global_actors.js
toolkit/devtools/debugger/tests/unit/post_init_tab_actors.js
toolkit/devtools/debugger/tests/unit/pre_init_global_actors.js
toolkit/devtools/debugger/tests/unit/pre_init_tab_actors.js
toolkit/devtools/debugger/tests/unit/source-map-data/sourcemapped.coffee
toolkit/devtools/debugger/tests/unit/source-map-data/sourcemapped.map
toolkit/devtools/debugger/tests/unit/sourcemapped.js
toolkit/devtools/debugger/tests/unit/test_add_actors.js
toolkit/devtools/debugger/tests/unit/test_attach.js
toolkit/devtools/debugger/tests/unit/test_breakpoint-01.js
toolkit/devtools/debugger/tests/unit/test_breakpoint-02.js
toolkit/devtools/debugger/tests/unit/test_breakpoint-03.js
toolkit/devtools/debugger/tests/unit/test_breakpoint-04.js
toolkit/devtools/debugger/tests/unit/test_breakpoint-05.js
toolkit/devtools/debugger/tests/unit/test_breakpoint-06.js
toolkit/devtools/debugger/tests/unit/test_breakpoint-07.js
toolkit/devtools/debugger/tests/unit/test_breakpoint-08.js
toolkit/devtools/debugger/tests/unit/test_breakpoint-09.js
toolkit/devtools/debugger/tests/unit/test_breakpoint-10.js
toolkit/devtools/debugger/tests/unit/test_breakpoint-11.js
toolkit/devtools/debugger/tests/unit/test_breakpoint-12.js
toolkit/devtools/debugger/tests/unit/test_breakpointstore.js
toolkit/devtools/debugger/tests/unit/test_dbgactor.js
toolkit/devtools/debugger/tests/unit/test_dbgclient_debuggerstatement.js
toolkit/devtools/debugger/tests/unit/test_dbgglobal.js
toolkit/devtools/debugger/tests/unit/test_dbgsocket.js
toolkit/devtools/debugger/tests/unit/test_eval-01.js
toolkit/devtools/debugger/tests/unit/test_eval-02.js
toolkit/devtools/debugger/tests/unit/test_eval-03.js
toolkit/devtools/debugger/tests/unit/test_eval-04.js
toolkit/devtools/debugger/tests/unit/test_eval-05.js
toolkit/devtools/debugger/tests/unit/test_frameactor-01.js
toolkit/devtools/debugger/tests/unit/test_frameactor-02.js
toolkit/devtools/debugger/tests/unit/test_frameactor-03.js
toolkit/devtools/debugger/tests/unit/test_frameactor-04.js
toolkit/devtools/debugger/tests/unit/test_frameactor-05.js
toolkit/devtools/debugger/tests/unit/test_framearguments-01.js
toolkit/devtools/debugger/tests/unit/test_framebindings-01.js
toolkit/devtools/debugger/tests/unit/test_framebindings-02.js
toolkit/devtools/debugger/tests/unit/test_framebindings-03.js
toolkit/devtools/debugger/tests/unit/test_framebindings-04.js
toolkit/devtools/debugger/tests/unit/test_framebindings-05.js
toolkit/devtools/debugger/tests/unit/test_framebindings-06.js
toolkit/devtools/debugger/tests/unit/test_frameclient-01.js
toolkit/devtools/debugger/tests/unit/test_frameclient-02.js
toolkit/devtools/debugger/tests/unit/test_functiongrips-01.js
toolkit/devtools/debugger/tests/unit/test_getyoungestframe.js
toolkit/devtools/debugger/tests/unit/test_interrupt.js
toolkit/devtools/debugger/tests/unit/test_listsources-01.js
toolkit/devtools/debugger/tests/unit/test_listsources-02.js
toolkit/devtools/debugger/tests/unit/test_listsources-03.js
toolkit/devtools/debugger/tests/unit/test_longstringactor.js
toolkit/devtools/debugger/tests/unit/test_longstringgrips-01.js
toolkit/devtools/debugger/tests/unit/test_longstringgrips-02.js
toolkit/devtools/debugger/tests/unit/test_nativewrappers.js
toolkit/devtools/debugger/tests/unit/test_new_source-01.js
toolkit/devtools/debugger/tests/unit/test_nsjsinspector.js
toolkit/devtools/debugger/tests/unit/test_objectgrips-01.js
toolkit/devtools/debugger/tests/unit/test_objectgrips-02.js
toolkit/devtools/debugger/tests/unit/test_objectgrips-03.js
toolkit/devtools/debugger/tests/unit/test_objectgrips-04.js
toolkit/devtools/debugger/tests/unit/test_pause_exceptions-01.js
toolkit/devtools/debugger/tests/unit/test_pause_exceptions-02.js
toolkit/devtools/debugger/tests/unit/test_pauselifetime-01.js
toolkit/devtools/debugger/tests/unit/test_pauselifetime-02.js
toolkit/devtools/debugger/tests/unit/test_pauselifetime-03.js
toolkit/devtools/debugger/tests/unit/test_pauselifetime-04.js
toolkit/devtools/debugger/tests/unit/test_profiler_actor.js
toolkit/devtools/debugger/tests/unit/test_source-01.js
toolkit/devtools/debugger/tests/unit/test_sourcemaps-01.js
toolkit/devtools/debugger/tests/unit/test_sourcemaps-02.js
toolkit/devtools/debugger/tests/unit/test_sourcemaps-03.js
toolkit/devtools/debugger/tests/unit/test_sourcemaps-04.js
toolkit/devtools/debugger/tests/unit/test_sourcemaps-05.js
toolkit/devtools/debugger/tests/unit/test_sourcemaps-06.js
toolkit/devtools/debugger/tests/unit/test_sourcemaps-07.js
toolkit/devtools/debugger/tests/unit/test_sources_backwards_compat-01.js
toolkit/devtools/debugger/tests/unit/test_sources_backwards_compat-02.js
toolkit/devtools/debugger/tests/unit/test_stepping-01.js
toolkit/devtools/debugger/tests/unit/test_stepping-02.js
toolkit/devtools/debugger/tests/unit/test_stepping-03.js
toolkit/devtools/debugger/tests/unit/test_stepping-04.js
toolkit/devtools/debugger/tests/unit/test_stepping-05.js
toolkit/devtools/debugger/tests/unit/test_threadlifetime-01.js
toolkit/devtools/debugger/tests/unit/test_threadlifetime-02.js
toolkit/devtools/debugger/tests/unit/test_threadlifetime-03.js
toolkit/devtools/debugger/tests/unit/test_threadlifetime-04.js
toolkit/devtools/debugger/tests/unit/test_threadlifetime-05.js
toolkit/devtools/debugger/tests/unit/test_threadlifetime-06.js
toolkit/devtools/debugger/tests/unit/test_unsafeDereference.js
toolkit/devtools/debugger/tests/unit/testactors.js
toolkit/devtools/debugger/tests/unit/testcompatactors.js
toolkit/devtools/debugger/tests/unit/xpcshell.ini
toolkit/devtools/gcli/dbg-gcli-actors.js
toolkit/devtools/jar.mn
toolkit/devtools/styleeditor/Makefile.in
toolkit/devtools/styleeditor/dbg-styleeditor-actors.js
toolkit/devtools/styleeditor/moz.build
toolkit/devtools/webconsole/dbg-webconsole-actors.js
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -999,17 +999,25 @@ let RemoteDebugger = {
     this._promptDone = true;
   },
 
   // Start the debugger server.
   start: function debugger_start() {
     if (!DebuggerServer.initialized) {
       // Ask for remote connections.
       DebuggerServer.init(this.prompt.bind(this));
-      DebuggerServer.addBrowserActors();
+      DebuggerServer.addActors("resource://gre/modules/devtools/server/actors/webbrowser.js");
+#ifndef MOZ_WIDGET_GONK
+      DebuggerServer.addActors("resource://gre/modules/devtools/server/actors/webconsole.js");
+      DebuggerServer.addActors("resource://gre/modules/devtools/server/actors/gcli.js");
+#endif
+      if ("nsIProfiler" in Ci) {
+        DebuggerServer.addActors("resource://gre/modules/devtools/server/actors/profiler.js");
+      }
+      DebuggerServer.addActors("resource://gre/modules/devtools/server/actors/styleeditor.js");
       DebuggerServer.addActors('chrome://browser/content/dbg-browser-actors.js');
       DebuggerServer.addActors('chrome://browser/content/dbg-webapps-actors.js');
     }
 
     let port = Services.prefs.getIntPref('devtools.debugger.remote-port') || 6000;
     try {
       DebuggerServer.openListener(port);
     } catch (e) {
--- a/browser/components/sessionstore/src/SessionStore.jsm
+++ b/browser/components/sessionstore/src/SessionStore.jsm
@@ -11,19 +11,16 @@ const Cr = Components.results;
 
 const STATE_STOPPED = 0;
 const STATE_RUNNING = 1;
 const STATE_QUITTING = -1;
 
 const STATE_STOPPED_STR = "stopped";
 const STATE_RUNNING_STR = "running";
 
-const TAB_STATE_NEEDS_RESTORE = 1;
-const TAB_STATE_RESTORING = 2;
-
 const PRIVACY_NONE = 0;
 const PRIVACY_ENCRYPTED = 1;
 const PRIVACY_FULL = 2;
 
 const NOTIFY_WINDOWS_RESTORED = "sessionstore-windows-restored";
 const NOTIFY_BROWSER_STATE_RESTORED = "sessionstore-browser-state-restored";
 
 // Maximum number of tabs to restore simultaneously. Previously controlled by
@@ -230,16 +227,39 @@ this.SessionStore = {
   },
 
   restoreLastSession: function ss_restoreLastSession() {
     SessionStoreInternal.restoreLastSession();
   },
 
   checkPrivacyLevel: function ss_checkPrivacyLevel(aIsHTTPS, aUseDefaultPref) {
     return SessionStoreInternal.checkPrivacyLevel(aIsHTTPS, aUseDefaultPref);
+  },
+
+  /**
+   * Returns whether a given browser is waiting to be restored. That means its
+   * history and state is ready but we wait until it's higher up in the priority
+   * queue or until it's made visible (if restore_on_demand=true).
+   *
+   * @param aBrowser Browser reference
+   * @returns bool
+   */
+  isTabStateNeedsRestore: function ss_isTabStateNeedsRestore(aBrowser) {
+    return TabRestoreStates.isNeedsRestore(aBrowser);
+  },
+
+  /**
+   * Returns whether a given browser is currently restoring, i.e. we wait for
+   * the actual page to load and will restore form data when it's finished.
+   *
+   * @param aBrowser Browser reference
+   * @returns bool
+   */
+  isTabStateRestoring: function ss_isTabStateRestoring(aBrowser) {
+    return TabRestoreStates.isRestoring(aBrowser);
   }
 };
 
 // Freeze the SessionStore object. We don't want anyone to modify it.
 Object.freeze(SessionStore);
 
 let SessionStoreInternal = {
   QueryInterface: XPCOMUtils.generateQI([
@@ -285,22 +305,16 @@ let SessionStoreInternal = {
   _recentCrashes: 0,
 
   // whether the last window was closed and should be restored
   _restoreLastWindow: false,
 
   // number of tabs currently restoring
   _tabsRestoringCount: 0,
 
-  // overrides MAX_CONCURRENT_TAB_RESTORES and restore_hidden_tabs when true
-  _restoreOnDemand: false,
-
-  // whether to restore app tabs on demand or not, pref controlled.
-  _restorePinnedTabsOnDemand: null,
-
   // The state from the previous session (after restoring pinned tabs). This
   // state is persisted and passed through to the next session during an app
   // restart to make the third party add-on warning not trash the deferred
   // session
   _lastSessionState: null,
 
   // When starting Firefox with a single private window, this is the place
   // where we keep the session we actually wanted to restore in case the user
@@ -366,24 +380,16 @@ let SessionStoreInternal = {
     this._migratePrefs();
 
     this._disabledForMultiProcess = this._prefBranch.getBoolPref("tabs.remote");
 
     // this pref is only read at startup, so no need to observe it
     this._sessionhistory_max_entries =
       this._prefBranch.getIntPref("sessionhistory.max_entries");
 
-    this._restoreOnDemand =
-      this._prefBranch.getBoolPref("sessionstore.restore_on_demand");
-    this._prefBranch.addObserver("sessionstore.restore_on_demand", this, true);
-
-    this._restorePinnedTabsOnDemand =
-      this._prefBranch.getBoolPref("sessionstore.restore_pinned_tabs_on_demand");
-    this._prefBranch.addObserver("sessionstore.restore_pinned_tabs_on_demand", this, true);
-
     gSessionStartup.onceInitialized.then(
       this.initSession.bind(this)
     );
   },
 
   initSession: function ssi_initSession() {
     let ss = gSessionStartup;
     try {
@@ -1050,19 +1056,19 @@ let SessionStoreInternal = {
     // quit-application notification so the browser is about to exit.
     if (this._loadState == STATE_QUITTING)
       return;
     this._lastSessionState = null;
     let openWindows = {};
     this._forEachBrowserWindow(function(aWindow) {
       Array.forEach(aWindow.gBrowser.tabs, aTab => {
         RestoringTabsData.remove(aTab.linkedBrowser);
-        delete aTab.linkedBrowser.__SS_formDataSaved;
+        FormDataCache.remove(aTab.linkedBrowser);
         delete aTab.linkedBrowser.__SS_hostSchemeData;
-        if (aTab.linkedBrowser.__SS_restoreState)
+        if (TabRestoreStates.has(aTab.linkedBrowser))
           this._resetTabRestoringState(aTab);
       });
       openWindows[aWindow.__SSi] = true;
     });
     // also clear all data about closed tabs and windows
     for (let ix in this._windows) {
       if (ix in openWindows) {
         this._windows[ix]._closedTabs = [];
@@ -1182,24 +1188,16 @@ let SessionStoreInternal = {
           this._resume_session_once_on_shutdown = null;
         }
         // either create the file with crash recovery information or remove it
         // (when _loadState is not STATE_RUNNING, that file is used for session resuming instead)
         if (!this._resume_from_crash)
           _SessionFile.wipe();
         this.saveState(true);
         break;
-      case "sessionstore.restore_on_demand":
-        this._restoreOnDemand =
-          this._prefBranch.getBoolPref("sessionstore.restore_on_demand");
-        break;
-      case "sessionstore.restore_pinned_tabs_on_demand":
-        this._restorePinnedTabsOnDemand =
-          this._prefBranch.getBoolPref("sessionstore.restore_pinned_tabs_on_demand");
-        break;
     }
   },
 
   /**
    * On timer callback
    */
   onTimerCallback: function ssi_onTimerCallback() {
     this._saveTimer = null;
@@ -1240,27 +1238,27 @@ let SessionStoreInternal = {
    */
   onTabRemove: function ssi_onTabRemove(aWindow, aTab, aNoNotification) {
     let browser = aTab.linkedBrowser;
     browser.removeEventListener("load", this, true);
 
     let mm = browser.messageManager;
     MESSAGES.forEach(msg => mm.removeMessageListener(msg, this));
 
-    RestoringTabsData.remove(aTab.linkedBrowser);
-    delete browser.__SS_formDataSaved;
+    RestoringTabsData.remove(browser);
+    FormDataCache.remove(browser);
     delete browser.__SS_hostSchemeData;
 
     // If this tab was in the middle of restoring or still needs to be restored,
     // we need to reset that state. If the tab was restoring, we will attempt to
     // restore the next tab.
-    let previousState = browser.__SS_restoreState;
-    if (previousState) {
+    if (TabRestoreStates.has(browser)) {
+      let wasRestoring = TabRestoreStates.isRestoring(browser);
       this._resetTabRestoringState(aTab);
-      if (previousState == TAB_STATE_RESTORING)
+      if (wasRestoring)
         this.restoreNextTab();
     }
 
     if (!aNoNotification) {
       this.saveStateDelayed(aWindow);
     }
   },
 
@@ -1280,17 +1278,17 @@ let SessionStoreInternal = {
 
     // don't update our internal state if we don't have to
     if (this._max_tabs_undo == 0) {
       return;
     }
 
     // make sure that the tab related data is up-to-date
     var tabState = this._collectTabData(aTab);
-    this._updateTextAndScrollDataForTab(aWindow, aTab.linkedBrowser, tabState);
+    this._updateTextAndScrollDataForTab(aTab.linkedBrowser, tabState);
 
     // store closed-tab data for undo
     if (this._shouldSaveTabState(tabState)) {
       let tabTitle = aTab.label;
       let tabbrowser = aWindow.gBrowser;
       tabTitle = this._replaceLoadingTitle(tabTitle, tabbrowser, aTab);
 
       this._windows[aWindow.__SSi]._closedTabs.unshift({
@@ -1312,85 +1310,77 @@ let SessionStoreInternal = {
    * @param aBrowser
    *        Browser reference
    */
   onTabLoad: function ssi_onTabLoad(aWindow, aBrowser) {
     // react on "load" and solitary "pageshow" events (the first "pageshow"
     // following "load" is too late for deleting the data caches)
     // It's possible to get a load event after calling stop on a browser (when
     // overwriting tabs). We want to return early if the tab hasn't been restored yet.
-    if (aBrowser.__SS_restoreState &&
-        aBrowser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE) {
+    if (TabRestoreStates.isNeedsRestore(aBrowser)) {
       return;
     }
 
     RestoringTabsData.remove(aBrowser);
-    delete aBrowser.__SS_formDataSaved;
+    FormDataCache.remove(aBrowser);
     this.saveStateDelayed(aWindow);
 
     // attempt to update the current URL we send in a crash report
     this._updateCrashReportURL(aWindow);
   },
 
   /**
    * Called when a browser sends the "input" notification
    * @param aWindow
    *        Window reference
    * @param aBrowser
    *        Browser reference
    */
   onTabInput: function ssi_onTabInput(aWindow, aBrowser) {
-    // deleting __SS_formDataSaved will cause us to recollect form data
-    delete aBrowser.__SS_formDataSaved;
-
+    FormDataCache.remove(aBrowser);
     this.saveStateDelayed(aWindow, 3000);
   },
 
   /**
    * When a tab is selected, save session data
    * @param aWindow
    *        Window reference
    */
   onTabSelect: function ssi_onTabSelect(aWindow) {
     if (this._loadState == STATE_RUNNING) {
       this._windows[aWindow.__SSi].selected = aWindow.gBrowser.tabContainer.selectedIndex;
 
       let tab = aWindow.gBrowser.selectedTab;
-      // If __SS_restoreState is still on the browser and it is
-      // TAB_STATE_NEEDS_RESTORE, then then we haven't restored
-      // this tab yet. Explicitly call restoreTab to kick off the restore.
-      if (tab.linkedBrowser.__SS_restoreState &&
-          tab.linkedBrowser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE)
+      // Explicitly call restoreTab() to to restore the tab if we need to.
+      if (TabRestoreStates.isNeedsRestore(tab.linkedBrowser))
         this.restoreTab(tab);
 
       // attempt to update the current URL we send in a crash report
       this._updateCrashReportURL(aWindow);
     }
   },
 
   onTabShow: function ssi_onTabShow(aWindow, aTab) {
     // If the tab hasn't been restored yet, move it into the right bucket
-    if (aTab.linkedBrowser.__SS_restoreState &&
-        aTab.linkedBrowser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE) {
+    if (TabRestoreStates.isNeedsRestore(aTab.linkedBrowser)) {
       TabRestoreQueue.hiddenToVisible(aTab);
 
       // let's kick off tab restoration again to ensure this tab gets restored
       // with "restore_hidden_tabs" == false (now that it has become visible)
       this.restoreNextTab();
     }
 
     // Default delay of 2 seconds gives enough time to catch multiple TabShow
     // events due to changing groups in Panorama.
     this.saveStateDelayed(aWindow);
   },
 
   onTabHide: function ssi_onTabHide(aWindow, aTab) {
     // If the tab hasn't been restored yet, move it into the right bucket
-    if (aTab.linkedBrowser.__SS_restoreState &&
-        aTab.linkedBrowser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE) {
+    if (TabRestoreStates.isNeedsRestore(aTab.linkedBrowser)) {
       TabRestoreQueue.visibleToHidden(aTab);
     }
 
     // Default delay of 2 seconds gives enough time to catch multiple TabHide
     // events due to changing groups in Panorama.
     this.saveStateDelayed(aWindow);
   },
 
@@ -1460,20 +1450,17 @@ let SessionStoreInternal = {
     this.restoreWindow(aWindow, aState, aOverwrite);
   },
 
   getTabState: function ssi_getTabState(aTab) {
     if (!aTab.ownerDocument || !aTab.ownerDocument.defaultView.__SSi)
       throw (Components.returnCode = Cr.NS_ERROR_INVALID_ARG);
 
     var tabState = this._collectTabData(aTab);
-
-    var window = aTab.ownerDocument.defaultView;
-    this._updateTextAndScrollDataForTab(window, aTab.linkedBrowser, tabState);
-
+    this._updateTextAndScrollDataForTab(aTab.linkedBrowser, tabState);
     return this._toJSONString(tabState);
   },
 
   setTabState: function ssi_setTabState(aTab, aState) {
     var tabState = JSON.parse(aState);
     if (!tabState.entries || !aTab.ownerDocument || !aTab.ownerDocument.defaultView.__SSi)
       throw (Components.returnCode = Cr.NS_ERROR_INVALID_ARG);
 
@@ -1483,18 +1470,17 @@ let SessionStoreInternal = {
   },
 
   duplicateTab: function ssi_duplicateTab(aWindow, aTab, aDelta) {
     if (!aTab.ownerDocument || !aTab.ownerDocument.defaultView.__SSi ||
         !aWindow.getBrowser)
       throw (Components.returnCode = Cr.NS_ERROR_INVALID_ARG);
 
     var tabState = this._collectTabData(aTab, true);
-    var sourceWindow = aTab.ownerDocument.defaultView;
-    this._updateTextAndScrollDataForTab(sourceWindow, aTab.linkedBrowser, tabState, true);
+    this._updateTextAndScrollDataForTab(aTab.linkedBrowser, tabState, true);
     tabState.index += aDelta;
     tabState.index = Math.max(1, Math.min(tabState.index, tabState.entries.length));
     tabState.pinned = false;
 
     this._setWindowStateBusy(aWindow);
     let newTab = aTab == aWindow.gBrowser.selectedTab ?
       aWindow.gBrowser.addTab(null, {relatedToCurrent: true, ownerTab: aTab}) :
       aWindow.gBrowser.addTab();
@@ -2151,110 +2137,116 @@ let SessionStoreInternal = {
    * and innerHTML content of WYSIWYG editors
    * @param aWindow
    *        Window reference
    */
   _updateTextAndScrollData: function ssi_updateTextAndScrollData(aWindow) {
     var browsers = aWindow.gBrowser.browsers;
     this._windows[aWindow.__SSi].tabs.forEach(function (tabData, i) {
       try {
-        this._updateTextAndScrollDataForTab(aWindow, browsers[i], tabData);
+        this._updateTextAndScrollDataForTab(browsers[i], tabData);
       }
       catch (ex) { debug(ex); } // get as much data as possible, ignore failures (might succeed the next time)
     }, this);
   },
 
   /**
    * go through all frames and store the current scroll positions
    * and innerHTML content of WYSIWYG editors
-   * @param aWindow
-   *        Window reference
    * @param aBrowser
    *        single browser reference
    * @param aTabData
    *        tabData object to add the information to
    * @param aFullData
    *        always return privacy sensitive data (use with care)
    */
   _updateTextAndScrollDataForTab:
-    function ssi_updateTextAndScrollDataForTab(aWindow, aBrowser, aTabData, aFullData) {
+    function ssi_updateTextAndScrollDataForTab(aBrowser, aTabData, aFullData) {
     // we shouldn't update data for incompletely initialized tabs
     if (RestoringTabsData.has(aBrowser))
       return;
 
     var tabIndex = (aTabData.index || aTabData.entries.length) - 1;
     // entry data needn't exist for tabs just initialized with an incomplete session state
     if (!aTabData.entries[tabIndex])
       return;
 
     let selectedPageStyle = aBrowser.markupDocumentViewer.authorStyleDisabled ? "_nostyle" :
                             this._getSelectedPageStyle(aBrowser.contentWindow);
     if (selectedPageStyle)
       aTabData.pageStyle = selectedPageStyle;
     else if (aTabData.pageStyle)
       delete aTabData.pageStyle;
 
-    this._updateTextAndScrollDataForFrame(aWindow, aBrowser.contentWindow,
+    this._updateTextAndScrollDataForFrame(aBrowser, aBrowser.contentWindow,
                                           aTabData.entries[tabIndex],
-                                          !aBrowser.__SS_formDataSaved, aFullData,
-                                          !!aTabData.pinned);
-    aBrowser.__SS_formDataSaved = true;
+                                          aFullData, !!aTabData.pinned);
+
     if (aBrowser.currentURI.spec == "about:config")
       aTabData.entries[tabIndex].formdata = {
         id: {
           "textbox": aBrowser.contentDocument.getElementById("textbox").value
         },
         xpath: {}
       };
   },
 
   /**
    * go through all subframes and store all form data, the current
    * scroll positions and innerHTML content of WYSIWYG editors
-   * @param aWindow
-   *        Window reference
+   * @param aBrowser
+   *        single browser reference
    * @param aContent
    *        frame reference
    * @param aData
    *        part of a tabData object to add the information to
    * @param aUpdateFormData
    *        update all form data for this tab
    * @param aFullData
    *        always return privacy sensitive data (use with care)
    * @param aIsPinned
    *        the tab is pinned and should be treated differently for privacy
    */
   _updateTextAndScrollDataForFrame:
-    function ssi_updateTextAndScrollDataForFrame(aWindow, aContent, aData,
-                                                 aUpdateFormData, aFullData, aIsPinned) {
+    function ssi_updateTextAndScrollDataForFrame(aBrowser, aContent, aData,
+                                                 aFullData, aIsPinned) {
     for (var i = 0; i < aContent.frames.length; i++) {
       if (aData.children && aData.children[i])
-        this._updateTextAndScrollDataForFrame(aWindow, aContent.frames[i],
-                                              aData.children[i], aUpdateFormData,
-                                              aFullData, aIsPinned);
+        this._updateTextAndScrollDataForFrame(aBrowser, aContent.frames[i],
+                                              aData.children[i], aFullData,
+                                              aIsPinned);
     }
     var isHTTPS = this._getURIFromString((aContent.parent || aContent).
                                          document.location.href).schemeIs("https");
     let isAboutSR = aContent.top.document.location.href == "about:sessionrestore";
     if (aFullData || this.checkPrivacyLevel(isHTTPS, aIsPinned) || isAboutSR) {
-      if (aFullData || aUpdateFormData) {
+      if (aFullData || !FormDataCache.has(aBrowser, aContent)) {
         let formData = DocumentUtils.getFormData(aContent.document);
 
         // We want to avoid saving data for about:sessionrestore as a string.
         // Since it's stored in the form as stringified JSON, stringifying further
         // causes an explosion of escape characters. cf. bug 467409
         if (formData && isAboutSR) {
           formData.id["sessionData"] = JSON.parse(formData.id["sessionData"]);
         }
 
         if (Object.keys(formData.id).length ||
             Object.keys(formData.xpath).length) {
-          aData.formdata = formData;
-        } else if (aData.formdata) {
-          delete aData.formdata;
+          aData.formdata = formData
+        } else {
+          formData = null;
+        }
+
+        // Store form data in cache.
+        FormDataCache.set(aBrowser, aContent, formData);
+      } else {
+        // Copy from form data cache.
+        let cached = FormDataCache.get(aBrowser, aContent);
+        if (cached) {
+          aData.formdata = cached;
         }
       }
 
       // designMode is undefined e.g. for XUL documents (as about:config)
       if ((aContent.document.designMode || "") == "on" && aContent.document.body)
         aData.innerHTML = aContent.document.body.innerHTML;
     }
 
@@ -2751,17 +2743,17 @@ let SessionStoreInternal = {
     }
 
     // If overwriting tabs, we want to reset each tab's "restoring" state. Since
     // we're overwriting those tabs, they should no longer be restoring. The
     // tabs will be rebuilt and marked if they need to be restored after loading
     // state (in restoreHistoryPrecursor).
     if (aOverwriteTabs) {
       for (let i = 0; i < tabbrowser.tabs.length; i++) {
-        if (tabbrowser.browsers[i].__SS_restoreState)
+        if (TabRestoreStates.has(tabbrowser.browsers[i]))
           this._resetTabRestoringState(tabbrowser.tabs[i]);
       }
     }
 
     // We want to set up a counter on the window that indicates how many tabs
     // in this window are unrestored. This will be used in restoreNextTab to
     // determine if gRestoreTabsProgressListener should be removed from the window.
     // If we aren't overwriting existing tabs, then we want to add to the existing
@@ -2981,17 +2973,17 @@ let SessionStoreInternal = {
       if ("attributes" in tabData) {
         // Ensure that we persist tab attributes restored from previous sessions.
         Object.keys(tabData.attributes).forEach(a => TabAttributes.persist(a));
       }
 
       // keep the data around to prevent dataloss in case
       // a tab gets closed before it's been properly restored
       RestoringTabsData.set(browser, tabData);
-      browser.__SS_restoreState = TAB_STATE_NEEDS_RESTORE;
+      TabRestoreStates.setNeedsRestore(browser);
       browser.setAttribute("pending", "true");
       tab.setAttribute("pending", "true");
 
       // Make sure that set/getTabValue will set/read the correct data by
       // wiping out any current value in tab.__SS_extdata.
       delete tab.__SS_extdata;
 
       if (!tabData.entries || tabData.entries.length == 0) {
@@ -3171,17 +3163,17 @@ let SessionStoreInternal = {
 
     // Make sure that this tab is removed from the priority queue.
     TabRestoreQueue.remove(aTab);
 
     // Increase our internal count.
     this._tabsRestoringCount++;
 
     // Set this tab's state to restoring
-    browser.__SS_restoreState = TAB_STATE_RESTORING;
+    TabRestoreStates.setIsRestoring(browser);
     browser.removeAttribute("pending");
     aTab.removeAttribute("pending");
 
     // Remove the history listener, since we no longer need it once we start restoring
     this._removeSHistoryListener(aTab);
 
     let activeIndex = (tabData.index || tabData.entries.length) - 1;
     if (activeIndex >= tabData.entries.length)
@@ -3249,20 +3241,18 @@ let SessionStoreInternal = {
    *   if there are no tabs to restore
    *   if we have already reached the limit for number of tabs to restore
    */
   restoreNextTab: function ssi_restoreNextTab() {
     // If we call in here while quitting, we don't actually want to do anything
     if (this._loadState == STATE_QUITTING)
       return;
 
-    // If it's not possible to restore anything, then just bail out.
-    if ((this._restoreOnDemand &&
-        (this._restorePinnedTabsOnDemand || !TabRestoreQueue.hasPriorityTabs)) ||
-        this._tabsRestoringCount >= MAX_CONCURRENT_TAB_RESTORES)
+    // Don't exceed the maximum number of concurrent tab restores.
+    if (this._tabsRestoringCount >= MAX_CONCURRENT_TAB_RESTORES)
       return;
 
     let tab = TabRestoreQueue.shift();
     if (tab) {
       let didStartLoad = this.restoreTab(tab);
       // If we don't start a load in the restored tab (eg, no entries) then we
       // want to attempt to restore the next tab.
       if (!didStartLoad)
@@ -4393,36 +4383,37 @@ let SessionStoreInternal = {
    * @param aTab
    *        The tab that will be "reset"
    */
   _resetTabRestoringState: function ssi_resetTabRestoringState(aTab) {
     let window = aTab.ownerDocument.defaultView;
     let browser = aTab.linkedBrowser;
 
     // Keep the tab's previous state for later in this method
-    let previousState = browser.__SS_restoreState;
+    let wasRestoring = TabRestoreStates.isRestoring(browser);
+    let wasNeedsRestore = TabRestoreStates.isNeedsRestore(browser);
 
     // The browser is no longer in any sort of restoring state.
-    delete browser.__SS_restoreState;
+    TabRestoreStates.remove(browser);
 
     aTab.removeAttribute("pending");
     browser.removeAttribute("pending");
 
     // We want to decrement window.__SS_tabsToRestore here so that we always
     // decrement it AFTER a tab is done restoring or when a tab gets "reset".
     window.__SS_tabsToRestore--;
 
     // Remove the progress listener if we should.
     this._removeTabsProgressListener(window);
 
-    if (previousState == TAB_STATE_RESTORING) {
+    if (wasRestoring) {
       if (this._tabsRestoringCount)
         this._tabsRestoringCount--;
     }
-    else if (previousState == TAB_STATE_NEEDS_RESTORE) {
+    else if (wasNeedsRestore) {
       // Make sure the session history listener is removed. This is normally
       // done in restoreTab, but this tab is being removed before that gets called.
       this._removeSHistoryListener(aTab);
 
       // Make sure that the tab is removed from the list of tabs to restore.
       // Again, this is normally done in restoreTab, but that isn't being called
       // for this tab.
       TabRestoreQueue.remove(aTab);
@@ -4475,30 +4466,57 @@ let SessionStoreInternal = {
  * the tab we should restore next, based on priority rules. We decide between
  * pinned, visible and hidden tabs in that and FIFO order. Hidden tabs are only
  * restored with restore_hidden_tabs=true.
  */
 let TabRestoreQueue = {
   // The separate buckets used to store tabs.
   tabs: {priority: [], visible: [], hidden: []},
 
-  // Returns whether we have any high priority tabs in the queue.
-  get hasPriorityTabs() !!this.tabs.priority.length,
-
-  // Lazy getter that returns whether we should restore hidden tabs.
-  get restoreHiddenTabs() {
-    let updateValue = () => {
-      let value = Services.prefs.getBoolPref(PREF);
-      let definition = {value: value, configurable: true};
-      Object.defineProperty(this, "restoreHiddenTabs", definition);
+  // Preferences used by the TabRestoreQueue to determine which tabs
+  // are restored automatically and which tabs will be on-demand.
+  prefs: {
+    // Lazy getter that returns whether tabs are restored on demand.
+    get restoreOnDemand() {
+      let updateValue = () => {
+        let value = Services.prefs.getBoolPref(PREF);
+        let definition = {value: value, configurable: true};
+        Object.defineProperty(this, "restoreOnDemand", definition);
+      }
+
+      const PREF = "browser.sessionstore.restore_on_demand";
+      Services.prefs.addObserver(PREF, updateValue, false);
+      updateValue();
+    },
+
+    // Lazy getter that returns whether pinned tabs are restored on demand.
+    get restorePinnedTabsOnDemand() {
+      let updateValue = () => {
+        let value = Services.prefs.getBoolPref(PREF);
+        let definition = {value: value, configurable: true};
+        Object.defineProperty(this, "restorePinnedTabsOnDemand", definition);
+      }
+
+      const PREF = "browser.sessionstore.restore_pinned_tabs_on_demand";
+      Services.prefs.addObserver(PREF, updateValue, false);
+      updateValue();
+    },
+
+    // Lazy getter that returns whether we should restore hidden tabs.
+    get restoreHiddenTabs() {
+      let updateValue = () => {
+        let value = Services.prefs.getBoolPref(PREF);
+        let definition = {value: value, configurable: true};
+        Object.defineProperty(this, "restoreHiddenTabs", definition);
+      }
+
+      const PREF = "browser.sessionstore.restore_hidden_tabs";
+      Services.prefs.addObserver(PREF, updateValue, false);
+      updateValue();
     }
-
-    const PREF = "browser.sessionstore.restore_hidden_tabs";
-    Services.prefs.addObserver(PREF, updateValue, false);
-    updateValue();
   },
 
   // Resets the queue and removes all tabs.
   reset: function () {
     this.tabs = {priority: [], visible: [], hidden: []};
   },
 
   // Adds a tab to the queue and determines its priority bucket.
@@ -4533,22 +4551,26 @@ let TabRestoreQueue = {
     }
   },
 
   // Returns and removes the tab with the highest priority.
   shift: function () {
     let set;
     let {priority, hidden, visible} = this.tabs;
 
-    if (priority.length) {
+    let {restoreOnDemand, restorePinnedTabsOnDemand} = this.prefs;
+    let restorePinned = !(restoreOnDemand && restorePinnedTabsOnDemand);
+    if (restorePinned && priority.length) {
       set = priority;
-    } else if (visible.length) {
-      set = visible;
-    } else if (this.restoreHiddenTabs && hidden.length) {
-      set = hidden;
+    } else if (!restoreOnDemand) {
+      if (visible.length) {
+        set = visible;
+      } else if (this.prefs.restoreHiddenTabs && hidden.length) {
+        set = hidden;
+      }
     }
 
     return set && set.shift();
   },
 
   // Moves a given tab from the 'hidden' to the 'visible' bucket.
   hiddenToVisible: function (tab) {
     let {hidden, visible} = this.tabs;
@@ -4665,25 +4687,92 @@ let TabAttributes = {
 
     // Set attributes.
     for (let name in data) {
       tab.setAttribute(name, data[name]);
     }
   }
 };
 
+// A map keeping track of all tab restore states. A tab might be 'needs-restore'
+// if it waits until the restoration process is kicked off. This might start
+// when the tab reaches a higher position in the priority queue or when it's
+// made visible (when restore_on_demand=true). If a tab is 'restoring' we wait
+// for its actual page to load and will then restore form data etc. If has()
+// returns false the tab has not been restored from previous data or it has
+// already finished restoring and is thus now seen as a valid and complete tab.
+let TabRestoreStates = {
+  _states: new WeakMap(),
+
+  has: function (browser) {
+    return this._states.has(browser);
+  },
+
+  isNeedsRestore: function ss_isNeedsRestore(browser) {
+    return this._states.get(browser) === "needs-restore";
+  },
+
+  setNeedsRestore: function (browser) {
+    this._states.set(browser, "needs-restore");
+  },
+
+  isRestoring: function ss_isRestoring(browser) {
+    return this._states.get(browser) === "restoring";
+  },
+
+  setIsRestoring: function (browser) {
+    this._states.set(browser, "restoring");
+  },
+
+  remove: function (browser) {
+    this._states.delete(browser);
+  }
+};
+
+// A map storing cached form data belonging to browsers. Each browser itself
+// has a WeakMap assigned that holds the form data of its main and subframes.
+let FormDataCache = {
+  // Form data is cached using a nested data structure
+  // of type WeakMap<browser, WeakMap<frame, data>>.
+  _cache: new WeakMap(),
+
+  has: function (browser, frame) {
+    return this._cache.has(browser) && this._cache.get(browser).has(frame);
+  },
+
+  get: function (browser, frame) {
+    return this._cache.get(browser).get(frame);
+  },
+
+  set: function (browser, frame, data = {}) {
+    if (!this._cache.has(browser)) {
+      this._cache.set(browser, new WeakMap());
+    }
+
+    // The object is frozen so that clients cannot mutate cached data.
+    if (data && typeof data === "object") {
+      Object.freeze(data);
+    }
+
+    this._cache.get(browser).set(frame, data);
+  },
+
+  remove: function (browser) {
+    this._cache.delete(browser);
+  }
+};
+
 // This is used to help meter the number of restoring tabs. This is the control
 // point for telling the next tab to restore. It gets attached to each gBrowser
 // via gBrowser.addTabsProgressListener
 let gRestoreTabsProgressListener = {
   onStateChange: function(aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) {
     // Ignore state changes on browsers that we've already restored and state
     // changes that aren't applicable.
-    if (aBrowser.__SS_restoreState &&
-        aBrowser.__SS_restoreState == TAB_STATE_RESTORING &&
+    if (TabRestoreStates.isRestoring(aBrowser) &&
         aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
         aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK &&
         aStateFlags & Ci.nsIWebProgressListener.STATE_IS_WINDOW) {
       // We need to reset the tab before starting the next restore.
       let tab = SessionStoreInternal._getTabForBrowser(aBrowser);
       SessionStoreInternal._resetTabRestoringState(tab);
       SessionStoreInternal.restoreNextTab();
     }
--- a/browser/components/sessionstore/test/browser_595601-restore_hidden.js
+++ b/browser/components/sessionstore/test/browser_595601-restore_hidden.js
@@ -68,31 +68,31 @@ let TabsProgressListener = {
     delete this.callback;
   },
 
   setCallback: function (callback) {
     this.callback = callback;
   },
 
   onStateChange: function (aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) {
-    if (this.callback && aBrowser.__SS_restoreState == TAB_STATE_RESTORING &&
+    if (this.callback && SessionStore.isTabStateRestoring(aBrowser) &&
         aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
         aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK &&
         aStateFlags & Ci.nsIWebProgressListener.STATE_IS_WINDOW)
       this.callback.apply(null, [this.window].concat(this.countTabs()));
   },
 
   countTabs: function () {
     let needsRestore = 0, isRestoring = 0;
 
     for (let i = 0; i < this.window.gBrowser.tabs.length; i++) {
       let browser = this.window.gBrowser.tabs[i].linkedBrowser;
-      if (browser.__SS_restoreState == TAB_STATE_RESTORING)
+      if (SessionStore.isTabStateRestoring(browser))
         isRestoring++;
-      else if (browser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE)
+      else if (SessionStore.isTabStateNeedsRestore(browser))
         needsRestore++;
     }
 
     return [needsRestore, isRestoring];
   }
 }
 
 // ----------
--- a/browser/components/sessionstore/test/browser_607016.js
+++ b/browser/components/sessionstore/test/browser_607016.js
@@ -17,40 +17,29 @@ function test() {
   /** Bug 607016 - If a tab is never restored, attributes (eg. hidden) aren't updated correctly **/
   waitForExplicitFinish();
   ignoreAllUncaughtExceptions();
 
   // Set the pref to true so we know exactly how many tabs should be restoring at
   // any given time. This guarantees that a finishing load won't start another.
   Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true);
 
-  // We have our own progress listener for this test, which we'll attach before our state is set
-  let progressListener = {
-    onStateChange: function (aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) {
-      if (aBrowser.__SS_restoreState == TAB_STATE_RESTORING &&
-          aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
-          aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK &&
-          aStateFlags & Ci.nsIWebProgressListener.STATE_IS_WINDOW)
-        progressCallback(aBrowser);
-    }
-  }
-
   let state = { windows: [{ tabs: [
     { entries: [{ url: "http://example.org#1" }], extData: { "uniq": r() } },
     { entries: [{ url: "http://example.org#2" }], extData: { "uniq": r() } }, // overwriting
     { entries: [{ url: "http://example.org#3" }], extData: { "uniq": r() } }, // hiding
     { entries: [{ url: "http://example.org#4" }], extData: { "uniq": r() } }, // adding
     { entries: [{ url: "http://example.org#5" }], extData: { "uniq": r() } }, // deleting
     { entries: [{ url: "http://example.org#6" }] } // creating
   ], selected: 1 }] };
 
-  function progressCallback(aBrowser) {
+  gProgressListener.setCallback(function progressCallback(aBrowser) {
     // We'll remove the progress listener after the first one because we aren't
     // loading any other tabs
-    window.gBrowser.removeTabsProgressListener(progressListener);
+    gProgressListener.unsetCallback();
 
     let curState = JSON.parse(ss.getBrowserState());
     for (let i = 0; i < curState.windows[0].tabs.length; i++) {
       let tabState = state.windows[0].tabs[i];
       let tabCurState = curState.windows[0].tabs[i];
       if (tabState.extData) {
         is(tabCurState.extData["uniq"], tabState.extData["uniq"],
            "sanity check that tab has correct extData");
@@ -104,14 +93,13 @@ function test() {
     let newUniq2 = r();
     ss.setTabValue(gBrowser.tabs[1], "uniq", newUniq2);
     gBrowser.removeTab(gBrowser.tabs[1]);
     closedTabData = (JSON.parse(ss.getClosedTabData(window)))[0];
     is(closedTabData.state.extData.uniq, newUniq2,
        "(creating) new data is stored in extData where there was none");
 
     cleanup();
-  }
+  });
 
-  window.gBrowser.addTabsProgressListener(progressListener);
   ss.setBrowserState(JSON.stringify(state));
 }
 
--- a/browser/components/sessionstore/test/browser_636279.js
+++ b/browser/components/sessionstore/test/browser_636279.js
@@ -13,87 +13,35 @@ let state = {windows:[{tabs:[
   {entries:[{url:"http://example.com#3"}]},
   {entries:[{url:"http://example.com#4"}]},
 ]}]};
 
 function test() {
   waitForExplicitFinish();
 
   registerCleanupFunction(function () {
-    TabsProgressListener.uninit();
     ss.setBrowserState(stateBackup);
   });
 
-
-  TabsProgressListener.init();
-
   window.addEventListener("SSWindowStateReady", function onReady() {
     window.removeEventListener("SSWindowStateReady", onReady, false);
 
     let firstProgress = true;
 
-    TabsProgressListener.setCallback(function (needsRestore, isRestoring) {
+    gProgressListener.setCallback(function (browser, needsRestore, isRestoring) {
       if (firstProgress) {
         firstProgress = false;
         is(isRestoring, 3, "restoring 3 tabs concurrently");
       } else {
         ok(isRestoring <= 3, "restoring max. 2 tabs concurrently");
       }
 
       if (0 == needsRestore) {
-        TabsProgressListener.unsetCallback();
+        gProgressListener.unsetCallback();
         waitForFocus(finish);
       }
     });
 
     ss.setBrowserState(JSON.stringify(state));
   }, false);
 
   ss.setBrowserState(JSON.stringify(statePinned));
 }
-
-function countTabs() {
-  let needsRestore = 0, isRestoring = 0;
-  let windowsEnum = Services.wm.getEnumerator("navigator:browser");
-
-  while (windowsEnum.hasMoreElements()) {
-    let window = windowsEnum.getNext();
-    if (window.closed)
-      continue;
-
-    for (let i = 0; i < window.gBrowser.tabs.length; i++) {
-      let browser = window.gBrowser.tabs[i].linkedBrowser;
-      if (browser.__SS_restoreState == TAB_STATE_RESTORING)
-        isRestoring++;
-      else if (browser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE)
-        needsRestore++;
-    }
-  }
-
-  return [needsRestore, isRestoring];
-}
-
-let TabsProgressListener = {
-  init: function () {
-    gBrowser.addTabsProgressListener(this);
-  },
-
-  uninit: function () {
-    this.unsetCallback();
-    gBrowser.removeTabsProgressListener(this);
- },
-
-  setCallback: function (callback) {
-    this.callback = callback;
-  },
-
-  unsetCallback: function () {
-    delete this.callback;
-  },
-
-  onStateChange: function (aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) {
-    if (this.callback && aBrowser.__SS_restoreState == TAB_STATE_RESTORING &&
-        aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
-        aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK &&
-        aStateFlags & Ci.nsIWebProgressListener.STATE_IS_WINDOW)
-      this.callback.apply(null, countTabs());
-  }
-}
--- a/browser/components/sessionstore/test/browser_739805.js
+++ b/browser/components/sessionstore/test/browser_739805.js
@@ -17,17 +17,17 @@ function test() {
 
   let tab = gBrowser.addTab("about:blank");
   let browser = tab.linkedBrowser;
 
   whenBrowserLoaded(browser, function () {
     isnot(gBrowser.selectedTab, tab, "newly created tab is not selected");
 
     ss.setTabState(tab, JSON.stringify(tabState));
-    is(browser.__SS_restoreState, TAB_STATE_NEEDS_RESTORE, "tab needs restoring");
+    ok(SessionStore.isTabStateNeedsRestore(browser), "tab needs restoring");
 
     let state = JSON.parse(ss.getTabState(tab));
     let formdata = state.entries[0].formdata;
     is(formdata && formdata.id["foo"], "bar", "tab state's formdata is valid");
 
     whenTabRestored(tab, function () {
       let input = browser.contentDocument.getElementById("foo");
       is(input.value, "bar", "formdata has been restored correctly");
--- a/browser/components/sessionstore/test/browser_input.js
+++ b/browser/components/sessionstore/test/browser_input.js
@@ -31,64 +31,70 @@ function runTests() {
   yield forceWriteState();
 
   // Modify the checkbox field's state.
   let chk = browser.contentDocument.getElementById("chk");
   EventUtils.sendMouseEvent({type: "click"}, chk);
   yield waitForInput();
 
   // Check that we'll save the form data state correctly.
-  let state = JSON.parse(ss.getBrowserState());
-  let {formdata} = state.windows[0].tabs[1].entries[0];
+  let {entries: [{formdata}]} = JSON.parse(ss.getTabState(tab));
   is(formdata.id.chk, true, "chk's value is correct");
 
   // Clear dirty state of all windows again.
   yield forceWriteState();
 
   // Modify the text input field's state.
   browser.contentDocument.getElementById("txt").focus();
   EventUtils.synthesizeKey("m", {});
   yield waitForInput();
 
   // Check that we'll save the form data state correctly.
-  let state = JSON.parse(ss.getBrowserState());
-  let {formdata} = state.windows[0].tabs[1].entries[0];
+  let {entries: [{formdata}]} = JSON.parse(ss.getTabState(tab));
   is(formdata.id.chk, true, "chk's value is correct");
   is(formdata.id.txt, "m", "txt's value is correct");
 
+  // Check that the form data cache works properly.
+  let {entries: [{formdata}]} = JSON.parse(ss.getTabState(tab));
+  is(formdata.id.chk, true, "chk's cached value is correct");
+  is(formdata.id.txt, "m", "txt's cached value is correct");
+
   // Clear dirty state of all windows again.
   yield forceWriteState();
 
   // Modify the state of the checkbox contained in the iframe.
   let cdoc = browser.contentDocument.getElementById("ifr").contentDocument;
   EventUtils.sendMouseEvent({type: "click"}, cdoc.getElementById("chk"));
   yield waitForInput();
 
   // Modify the state of text field contained in the iframe.
   cdoc.getElementById("txt").focus();
   EventUtils.synthesizeKey("m", {});
   yield waitForInput();
 
   // Check that we'll save the iframe's form data correctly.
-  let state = JSON.parse(ss.getBrowserState());
-  let {formdata} = state.windows[0].tabs[1].entries[0].children[0];
+  let {entries: [{children: [{formdata}]}]} = JSON.parse(ss.getTabState(tab));
+  is(formdata.id.chk, true, "iframe chk's value is correct");
+  is(formdata.id.txt, "m", "iframe txt's value is correct");
+
+  // Check that the form data cache works properly for subframes.
+  let {entries: [{children: [{formdata}]}]} = JSON.parse(ss.getTabState(tab));
   is(formdata.id.chk, true, "iframe chk's value is correct");
   is(formdata.id.txt, "m", "iframe txt's value is correct");
 
   // Clear dirty state of all windows again.
   yield forceWriteState();
 
   // Modify the content editable's state.
   browser.contentDocument.getElementById("ced").focus();
   EventUtils.synthesizeKey("m", {});
   yield waitForInput();
 
-  // Check the we'll correctly save the content editable's state.
-  let state = JSON.parse(ss.getBrowserState());
-  let {innerHTML} = state.windows[0].tabs[1].entries[0].children[1];
+  // Check that we'll correctly save the content editable's state.
+  let {entries: [{children: [, {innerHTML}]}]} = JSON.parse(ss.getTabState(tab));
   is(innerHTML, "m", "content editable's value is correct");
 
   // Clean up after ourselves.
   gBrowser.removeTab(tab);
   win.close();
 }
 
 function forceWriteState() {
--- a/browser/components/sessionstore/test/head.js
+++ b/browser/components/sessionstore/test/head.js
@@ -1,15 +1,12 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-const TAB_STATE_NEEDS_RESTORE = 1;
-const TAB_STATE_RESTORING = 2;
-
 let tmp = {};
 Cu.import("resource:///modules/sessionstore/SessionStore.jsm", tmp);
 let SessionStore = tmp.SessionStore;
 
 let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
 
 // Some tests here assume that all restored tabs are loaded without waiting for
 // the user to bring them to the foreground. We ensure this by resetting the
@@ -236,34 +233,34 @@ let gProgressListener = {
       window.gBrowser.removeTabsProgressListener(this);
     }
   },
 
   onStateChange:
   function gProgressListener_onStateChange(aBrowser, aWebProgress, aRequest,
                                            aStateFlags, aStatus) {
     if ((!this._checkRestoreState ||
-         aBrowser.__SS_restoreState == TAB_STATE_RESTORING) &&
+         SessionStore.isTabStateRestoring(aBrowser)) &&
         aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
         aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK &&
         aStateFlags & Ci.nsIWebProgressListener.STATE_IS_WINDOW) {
       let args = [aBrowser].concat(this._countTabs());
       this._callback.apply(this, args);
     }
   },
 
   _countTabs: function gProgressListener_countTabs() {
     let needsRestore = 0, isRestoring = 0, wasRestored = 0;
 
     for (let win in BrowserWindowIterator()) {
       for (let i = 0; i < win.gBrowser.tabs.length; i++) {
         let browser = win.gBrowser.tabs[i].linkedBrowser;
-        if (browser.__SS_restoreState == TAB_STATE_RESTORING)
+        if (SessionStore.isTabStateRestoring(browser))
           isRestoring++;
-        else if (browser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE)
+        else if (SessionStore.isTabStateNeedsRestore(browser))
           needsRestore++;
         else
           wasRestored++;
       }
     }
     return [needsRestore, isRestoring, wasRestored];
   }
 };
--- a/browser/components/tabview/test/browser_tabview_bug595601.js
+++ b/browser/components/tabview/test/browser_tabview_bug595601.js
@@ -1,16 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
 
-const TAB_STATE_NEEDS_RESTORE = 1;
-const TAB_STATE_RESTORING = 2;
-
 let stateBackup = ss.getBrowserState();
 
 let state = {windows:[{tabs:[
   // first group
   {entries:[{url:"http://example.com#1"}],extData:{"tabview-tab":"{\"bounds\":{\"left\":20,\"top\":20,\"width\":20,\"height\":20},\"url\":\"http://example.com#1\",\"groupID\":2}"}},
   {entries:[{url:"http://example.com#2"}],extData:{"tabview-tab":"{\"bounds\":{\"left\":20,\"top\":20,\"width\":20,\"height\":20},\"url\":\"http://example.com#2\",\"groupID\":2}"}},
   {entries:[{url:"http://example.com#3"}],extData:{"tabview-tab":"{\"bounds\":{\"left\":20,\"top\":20,\"width\":20,\"height\":20},\"url\":\"http://example.com#3\",\"groupID\":2}"}},
   {entries:[{url:"http://example.com#4"}],extData:{"tabview-tab":"{\"bounds\":{\"left\":20,\"top\":20,\"width\":20,\"height\":20},\"url\":\"http://example.com#4\",\"groupID\":2}"}},
@@ -120,19 +117,19 @@ function countTabs() {
 
   while (windowsEnum.hasMoreElements()) {
     let window = windowsEnum.getNext();
     if (window.closed)
       continue;
 
     for (let i = 0; i < window.gBrowser.tabs.length; i++) {
       let browser = window.gBrowser.tabs[i].linkedBrowser;
-      if (browser.__SS_restoreState == TAB_STATE_RESTORING)
+      if (SessionStore.isTabStateRestoring(browser))
         isRestoring++;
-      else if (browser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE)
+      else if (SessionStore.isTabStateNeedsRestore(browser))
         needsRestore++;
     }
   }
 
   return [needsRestore, isRestoring];
 }
 
 let TabsProgressListener = {
@@ -163,18 +160,19 @@ let TabsProgressListener = {
     let self = this;
     let finalize = function () {
       if (wasRestoring)
         delete aBrowser.__wasRestoring;
 
       self.callback.apply(null, countTabs());
     };
 
-    let isRestoring = aBrowser.__SS_restoreState == TAB_STATE_RESTORING;
-    let wasRestoring = !aBrowser.__SS_restoreState && aBrowser.__wasRestoring;
+    let isRestoring = SessionStore.isTabStateRestoring(aBrowser);
+    let needsRestore = SessionStore.isTabStateNeedsRestore(aBrowser);
+    let wasRestoring = !isRestoring && !needsRestore && aBrowser.__wasRestoring;
     let hasStopped = aStateFlags & Ci.nsIWebProgressListener.STATE_STOP;
 
     if (isRestoring && !hasStopped)
       aBrowser.__wasRestoring = true;
 
     if (hasStopped && (isRestoring || wasRestoring))
       finalize();
   }
--- a/browser/components/tabview/test/head.js
+++ b/browser/components/tabview/test/head.js
@@ -1,11 +1,15 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+let tmp = {};
+Cu.import("resource:///modules/sessionstore/SessionStore.jsm", tmp);
+let SessionStore = tmp.SessionStore;
+
 // Some tests here assume that all restored tabs are loaded without waiting for
 // the user to bring them to the foreground. We ensure this by resetting the
 // related preference (see the "firefox.js" defaults file for details).
 Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", false);
 registerCleanupFunction(function () {
   Services.prefs.clearUserPref("browser.sessionstore.restore_on_demand");
 });
 
@@ -112,18 +116,16 @@ function newWindowWithTabView(shownCallb
 
   whenDelayedStartupFinished(win, function () {
     showTabView(function () shownCallback(win), win);
   });
 }
 
 // ----------
 function afterAllTabsLoaded(callback, win) {
-  const TAB_STATE_NEEDS_RESTORE = 1;
-
   win = win || window;
 
   let stillToLoad = 0;
   let restoreHiddenTabs = Services.prefs.getBoolPref(
                           "browser.sessionstore.restore_hidden_tabs");
 
   function onLoad() {
     this.removeEventListener("load", onLoad, true);
@@ -132,18 +134,17 @@ function afterAllTabsLoaded(callback, wi
       executeSoon(callback);
   }
 
   for (let a = 0; a < win.gBrowser.tabs.length; a++) {
     let tab = win.gBrowser.tabs[a];
     let browser = tab.linkedBrowser;
 
     let isRestorable = !(tab.hidden && !restoreHiddenTabs &&
-                         browser.__SS_restoreState &&
-                         browser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE);
+                         SessionStore.isTabStateNeedsRestore(browser));
 
     if (isRestorable && browser.contentDocument.readyState != "complete" ||
         browser.webProgress.isLoadingDocument) {
       stillToLoad++;
       browser.addEventListener("load", onLoad, true);
     }
   }
 
--- a/testing/xpcshell/xpcshell.ini
+++ b/testing/xpcshell/xpcshell.ini
@@ -25,17 +25,17 @@
 [include:dom/tests/unit/xpcshell.ini]
 [include:dom/indexedDB/test/unit/xpcshell.ini]
 [include:docshell/test/unit/xpcshell.ini]
 [include:docshell/test/unit_ipc/xpcshell.ini]
 [include:embedding/tests/unit/xpcshell.ini]
 [include:toolkit/components/commandlines/test/unit/xpcshell.ini]
 [include:toolkit/components/contentprefs/tests/unit/xpcshell.ini]
 [include:toolkit/components/contentprefs/tests/unit_cps2/xpcshell.ini]
-[include:toolkit/devtools/debugger/tests/unit/xpcshell.ini]
+[include:toolkit/devtools/server/tests/unit/xpcshell.ini]
 [include:toolkit/devtools/sourcemap/tests/unit/xpcshell.ini]
 [include:toolkit/components/passwordmgr/test/unit/xpcshell.ini]
 # Bug 676989: tests hang on Android
 skip-if = os == "android"
 [include:toolkit/components/places/tests/migration/xpcshell.ini]
 [include:toolkit/components/places/tests/autocomplete/xpcshell.ini]
 [include:toolkit/components/places/tests/inline/xpcshell.ini]
 [include:toolkit/components/places/tests/expiration/xpcshell.ini]
--- a/toolkit/devtools/Loader.jsm
+++ b/toolkit/devtools/Loader.jsm
@@ -71,19 +71,17 @@ var SrcdirProvider = {
         "": "resource://gre/modules/commonjs/",
         "devtools/server": "file://" + serverDir,
         "devtools": "file://" + devtoolsDir,
         "main": "file://" + devtoolsDir + "/main.js"
       },
       globals: loaderGlobals
     });
 
-    return this._writeManifest(devtoolsDir).then((data) => {
-      this._writeManifest(toolkitDir);
-    }).then(null, Cu.reportError);
+    return this._writeManifest(devtoolsDir).then(null, Cu.reportError);
   },
 
   unload: function(reason) {
     loader.unload(this.loader, reason);
     delete this.loader;
   },
 
   _readFile: function(filename) {
--- a/toolkit/devtools/Makefile.in
+++ b/toolkit/devtools/Makefile.in
@@ -7,9 +7,9 @@ topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
 include $(topsrcdir)/config/config.mk
 
 include $(topsrcdir)/config/rules.mk
 
 libs::
-	$(NSINSTALL) $(srcdir)/*.jsm $(FINAL_TARGET)/modules/devtools
+	$(NSINSTALL) $(IFLAGS1) $(srcdir)/*.jsm $(FINAL_TARGET)/modules/devtools
rename from toolkit/devtools/debugger/Makefile.in
rename to toolkit/devtools/client/Makefile.in
--- a/toolkit/devtools/debugger/Makefile.in
+++ b/toolkit/devtools/client/Makefile.in
@@ -4,29 +4,12 @@
 
 DEPTH = @DEPTH@
 topsrcdir = @top_srcdir@
 srcdir = @srcdir@
 VPATH = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-MODULE_NAME = jsinspector
-
-LIBRARY_NAME = jsinspector
-LIBXUL_LIBRARY = 1
-EXPORT_LIBRARY = 1
-IS_COMPONENT = 1
-
-CPPSRCS = \
-    nsJSInspector.cpp \
-    $(NULL)
-
-EXTRA_DSO_LDOPTS += \
-    $(MOZ_COMPONENT_LIBS) \
-    $(MOZ_JS_LIBS) \
-    $(NULL)
-
 include $(topsrcdir)/config/rules.mk
 
 libs::
 	$(INSTALL) $(IFLAGS1) $(srcdir)/*.jsm $(FINAL_TARGET)/modules/devtools
-	$(INSTALL) $(IFLAGS1) $(srcdir)/server/*.jsm $(FINAL_TARGET)/modules/devtools
rename from toolkit/devtools/debugger/dbg-client.jsm
rename to toolkit/devtools/client/dbg-client.jsm
--- a/toolkit/devtools/debugger/dbg-client.jsm
+++ b/toolkit/devtools/client/dbg-client.jsm
@@ -35,17 +35,17 @@ function dumpn(str)
 {
   if (wantLogging) {
     dump("DBG-CLIENT: " + str + "\n");
   }
 }
 
 let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
   .getService(Ci.mozIJSSubScriptLoader);
-loader.loadSubScript("chrome://global/content/devtools/dbg-transport.js", this);
+loader.loadSubScript("resource://gre/modules/devtools/server/transport.js", this);
 
 /**
  * Add simple event notification to a prototype object. Any object that has
  * some use for event notifications or the observer pattern in general can be
  * augmented with the necessary facilities by passing its prototype to this
  * function.
  *
  * @param aProto object
rename from toolkit/devtools/debugger/moz.build
rename to toolkit/devtools/client/moz.build
--- a/toolkit/devtools/debugger/moz.build
+++ b/toolkit/devtools/client/moz.build
@@ -1,14 +1,7 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-TEST_DIRS += ['tests']
 
-XPIDL_SOURCES += [
-    'nsIJSInspector.idl',
-]
-
-MODULE = 'jsinspector'
-
deleted file mode 100644
--- a/toolkit/devtools/jar.mn
+++ /dev/null
@@ -1,13 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-toolkit.jar:
-  content/global/devtools/dbg-transport.js        (debugger/dbg-transport.js)
-* content/global/devtools/dbg-server.js           (debugger/server/dbg-server.js)
-  content/global/devtools/dbg-script-actors.js    (debugger/server/dbg-script-actors.js)
-  content/global/devtools/dbg-browser-actors.js   (debugger/server/dbg-browser-actors.js)
-  content/global/devtools/dbg-gcli-actors.js      (gcli/dbg-gcli-actors.js)
-  content/global/devtools/dbg-webconsole-actors.js (webconsole/dbg-webconsole-actors.js)
-  content/global/devtools/dbg-profiler-actors.js  (debugger/server/dbg-profiler-actors.js)
-  content/global/devtools/dbg-styleeditor-actors.js  (styleeditor/dbg-styleeditor-actors.js)
--- a/toolkit/devtools/moz.build
+++ b/toolkit/devtools/moz.build
@@ -1,13 +1,13 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 PARALLEL_DIRS += [
-    'debugger',
+    'server',
+    'client',
     'gcli',
     'sourcemap',
-    'webconsole',
-    'styleeditor'
+    'webconsole'
 ]
copy from toolkit/devtools/debugger/Makefile.in
copy to toolkit/devtools/server/Makefile.in
--- a/toolkit/devtools/debugger/Makefile.in
+++ b/toolkit/devtools/server/Makefile.in
@@ -24,9 +24,10 @@ EXTRA_DSO_LDOPTS += \
     $(MOZ_COMPONENT_LIBS) \
     $(MOZ_JS_LIBS) \
     $(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 libs::
 	$(INSTALL) $(IFLAGS1) $(srcdir)/*.jsm $(FINAL_TARGET)/modules/devtools
-	$(INSTALL) $(IFLAGS1) $(srcdir)/server/*.jsm $(FINAL_TARGET)/modules/devtools
+	$(INSTALL) $(IFLAGS1) $(srcdir)/*.js $(FINAL_TARGET)/modules/devtools/server
+	$(INSTALL) $(IFLAGS1) $(srcdir)/actors/*.js $(FINAL_TARGET)/modules/devtools/server/actors
rename from toolkit/devtools/gcli/dbg-gcli-actors.js
rename to toolkit/devtools/server/actors/gcli.js
--- a/toolkit/devtools/gcli/dbg-gcli-actors.js
+++ b/toolkit/devtools/server/actors/gcli.js
@@ -65,8 +65,11 @@ GcliActor.prototype.execute = function(r
     error: output.error
   };
 };
 
 GcliActor.prototype.requestTypes = {
   getCommandSpecs: GcliActor.prototype.getCommandSpecs,
   execute: GcliActor.prototype.execute,
 };
+
+addTabActor(GcliActor, "gcliActor");
+addGlobalActor(GcliActor, "gcliActor");
rename from toolkit/devtools/debugger/server/dbg-profiler-actors.js
rename to toolkit/devtools/server/actors/profiler.js
rename from toolkit/devtools/debugger/server/dbg-script-actors.js
rename to toolkit/devtools/server/actors/script.js
rename from toolkit/devtools/styleeditor/dbg-styleeditor-actors.js
rename to toolkit/devtools/server/actors/styleeditor.js
--- a/toolkit/devtools/styleeditor/dbg-styleeditor-actors.js
+++ b/toolkit/devtools/server/actors/styleeditor.js
@@ -728,12 +728,13 @@ StyleSheetActor.prototype = {
 }
 
 StyleSheetActor.prototype.requestTypes = {
   "toggleDisabled": StyleSheetActor.prototype.onToggleDisabled,
   "fetchSource": StyleSheetActor.prototype.onFetchSource,
   "update": StyleSheetActor.prototype.onUpdate
 };
 
+DebuggerServer.addTabActor(StyleEditorActor, "styleEditorActor");
 
 XPCOMUtils.defineLazyGetter(this, "DOMUtils", function () {
   return Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
 });
rename from toolkit/devtools/debugger/server/dbg-browser-actors.js
rename to toolkit/devtools/server/actors/webbrowser.js
rename from toolkit/devtools/webconsole/dbg-webconsole-actors.js
rename to toolkit/devtools/server/actors/webconsole.js
--- a/toolkit/devtools/webconsole/dbg-webconsole-actors.js
+++ b/toolkit/devtools/server/actors/webconsole.js
@@ -1472,8 +1472,12 @@ NetworkEventActor.prototype.requestTypes
   "getRequestCookies": NetworkEventActor.prototype.onGetRequestCookies,
   "getRequestPostData": NetworkEventActor.prototype.onGetRequestPostData,
   "getResponseHeaders": NetworkEventActor.prototype.onGetResponseHeaders,
   "getResponseCookies": NetworkEventActor.prototype.onGetResponseCookies,
   "getResponseContent": NetworkEventActor.prototype.onGetResponseContent,
   "getEventTimings": NetworkEventActor.prototype.onGetEventTimings,
 };
 
+DebuggerServer.addTabActor(WebConsoleActor, "consoleActor");
+DebuggerServer.addGlobalActor(WebConsoleActor, "consoleActor");
+
+
rename from toolkit/devtools/debugger/server/dbg-server.jsm
rename to toolkit/devtools/server/dbg-server.jsm
--- a/toolkit/devtools/debugger/server/dbg-server.jsm
+++ b/toolkit/devtools/server/dbg-server.jsm
@@ -27,19 +27,17 @@ var loadSubScript =
   "      .getService(Ci.mozIJSSubScriptLoader);\n" +
   "    loader.loadSubScript(aURL, this);\n" +
   "  } catch(e) {\n" +
   "    dump(\"Error loading: \" + aURL + \": \" + e + \" - \" + e.stack + \"\\n\");\n" +
   "    throw e;\n" +
   "  }\n" +
   "}";
 
-Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
-
 // Load the debugging server in a sandbox with its own compartment.
 var systemPrincipal = Cc["@mozilla.org/systemprincipal;1"]
                       .createInstance(Ci.nsIPrincipal);
 
 var gGlobal = Cu.Sandbox(systemPrincipal);
 Cu.evalInSandbox(loadSubScript, gGlobal, "1.8");
-gGlobal.loadSubScript("chrome://global/content/devtools/dbg-server.js");
+gGlobal.loadSubScript("resource://gre/modules/devtools/server/main.js");
 
 this.DebuggerServer = gGlobal.DebuggerServer;
rename from toolkit/devtools/debugger/server/dbg-server.js
rename to toolkit/devtools/server/main.js
--- a/toolkit/devtools/debugger/server/dbg-server.js
+++ b/toolkit/devtools/server/main.js
@@ -36,17 +36,17 @@ function dumpn(str) {
 }
 
 function dbg_assert(cond, e) {
   if (!cond) {
     return e;
   }
 }
 
-loadSubScript.call(this, "chrome://global/content/devtools/dbg-transport.js");
+loadSubScript.call(this, "resource://gre/modules/devtools/server/transport.js");
 
 // XPCOM constructors
 const ServerSocket = CC("@mozilla.org/network/server-socket;1",
                         "nsIServerSocket",
                         "initSpecialConnection");
 
 /***
  * Public API
@@ -109,17 +109,17 @@ var DebuggerServer = {
    */
   init: function DS_init(aAllowConnectionCallback) {
     if (this.initialized) {
       return;
     }
 
     this.xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
     this.initTransport(aAllowConnectionCallback);
-    this.addActors("chrome://global/content/devtools/dbg-script-actors.js");
+    this.addActors("resource://gre/modules/devtools/server/actors/script.js");
 
     this._initialized = true;
   },
 
   /**
    * Initialize the debugger server's transport variables.  This can be
    * in place of init() for cases where the jsdebugger isn't needed.
    *
@@ -172,31 +172,23 @@ var DebuggerServer = {
   addActors: function DS_addActors(aURL) {
     loadSubScript.call(this, aURL);
   },
 
   /**
    * Install Firefox-specific actors.
    */
   addBrowserActors: function DS_addBrowserActors() {
-    this.addActors("chrome://global/content/devtools/dbg-browser-actors.js");
-#ifndef MOZ_WIDGET_GONK
-    this.addActors("chrome://global/content/devtools/dbg-webconsole-actors.js");
-    this.addTabActor(this.WebConsoleActor, "consoleActor");
-    this.addGlobalActor(this.WebConsoleActor, "consoleActor");
+    this.addActors("resource://gre/modules/devtools/server/actors/webbrowser.js");
+    this.addActors("resource://gre/modules/devtools/server/actors/webconsole.js");
+    this.addActors("resource://gre/modules/devtools/server/actors/gcli.js");
+    if ("nsIProfiler" in Ci)
+      this.addActors("resource://gre/modules/devtools/server/actors/profiler.js");
 
-    this.addActors("chrome://global/content/devtools/dbg-gcli-actors.js");
-    this.addTabActor(this.GcliActor, "gcliActor");
-    this.addGlobalActor(this.GcliActor, "gcliActor");
-#endif
-    if ("nsIProfiler" in Ci)
-      this.addActors("chrome://global/content/devtools/dbg-profiler-actors.js");
-
-    this.addActors("chrome://global/content/devtools/dbg-styleeditor-actors.js");
-    this.addTabActor(this.StyleEditorActor, "styleEditorActor");
+    this.addActors("resource://gre/modules/devtools/server/actors/styleeditor.js");
   },
 
   /**
    * Listens on the given port for remote debugger connections.
    *
    * @param aPort int
    *        The port to listen on.
    */
copy from toolkit/devtools/debugger/moz.build
copy to toolkit/devtools/server/moz.build
rename from toolkit/devtools/debugger/nsIJSInspector.idl
rename to toolkit/devtools/server/nsIJSInspector.idl
rename from toolkit/devtools/debugger/nsJSInspector.cpp
rename to toolkit/devtools/server/nsJSInspector.cpp
rename from toolkit/devtools/debugger/nsJSInspector.h
rename to toolkit/devtools/server/nsJSInspector.h
rename from toolkit/devtools/debugger/tests/mochitest/Makefile.in
rename to toolkit/devtools/server/tests/mochitest/Makefile.in
rename from toolkit/devtools/debugger/tests/mochitest/moz.build
rename to toolkit/devtools/server/tests/mochitest/moz.build
rename from toolkit/devtools/debugger/tests/mochitest/nonchrome_unsafeDereference.html
rename to toolkit/devtools/server/tests/mochitest/nonchrome_unsafeDereference.html
rename from toolkit/devtools/debugger/tests/mochitest/test_unsafeDereference.html
rename to toolkit/devtools/server/tests/mochitest/test_unsafeDereference.html
--- a/toolkit/devtools/debugger/tests/mochitest/test_unsafeDereference.html
+++ b/toolkit/devtools/server/tests/mochitest/test_unsafeDereference.html
@@ -19,17 +19,17 @@ xray wrapper.
 
 Components.utils.import("resource://gre/modules/jsdebugger.jsm");
 addDebuggerToGlobal(this);
 
 window.onload = function () {
   SimpleTest.waitForExplicitFinish();
 
   var iframe = document.createElement("iframe");
-  iframe.src = "http://mochi.test:8888/chrome/toolkit/devtools/debugger/tests/mochitest/nonchrome_unsafeDereference.html";
+  iframe.src = "http://mochi.test:8888/chrome/toolkit/devtools/server/tests/mochitest/nonchrome_unsafeDereference.html";
 
   iframe.onload = function () {
     var dbg = new Debugger;
     var contentDO = dbg.addDebuggee(iframe.contentWindow);
     var xhrDesc = contentDO.getOwnPropertyDescriptor('xhr');
 
     isnot(xhrDesc, undefined, "xhr should be visible as property of content global");
     isnot(xhrDesc.value, undefined, "xhr should have a value");
rename from toolkit/devtools/debugger/tests/moz.build
rename to toolkit/devtools/server/tests/moz.build
rename from toolkit/devtools/debugger/tests/unit/head_dbg.js
rename to toolkit/devtools/server/tests/unit/head_dbg.js
--- a/toolkit/devtools/debugger/tests/unit/head_dbg.js
+++ b/toolkit/devtools/server/tests/unit/head_dbg.js
@@ -13,16 +13,24 @@ Cu.import("resource://gre/modules/Servic
 // the output away anyway, unless you give it the --verbose flag.
 Services.prefs.setBoolPref("devtools.debugger.log", true);
 // Enable remote debugging for the relevant tests.
 Services.prefs.setBoolPref("devtools.debugger.remote-enabled", true);
 
 Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
 Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
 
+function testExceptionHook(ex) {
+  try {
+    do_report_unexpected_exception(ex);
+  } catch(ex) {
+    return {throw: ex}
+  }
+}
+
 // Convert an nsIScriptError 'aFlags' value into an appropriate string.
 function scriptErrorFlagsToKind(aFlags) {
   var kind;
   if (aFlags & Ci.nsIScriptError.warningFlag)
     kind = "warning";
   if (aFlags & Ci.nsIScriptError.exceptionFlag)
     kind = "exception";
   else
@@ -150,17 +158,17 @@ function initTestDebuggerServer()
 {
   DebuggerServer.addActors("resource://test/testactors.js");
   // Allow incoming connections.
   DebuggerServer.init(function () { return true; });
 }
 
 function initSourcesBackwardsCompatDebuggerServer()
 {
-  DebuggerServer.addActors("chrome://global/content/devtools/dbg-browser-actors.js");
+  DebuggerServer.addActors("resource://gre/modules/devtools/server/actors/webbrowser.js");
   DebuggerServer.addActors("resource://test/testcompatactors.js");
   DebuggerServer.init(function () { return true; });
 }
 
 function finishClient(aClient)
 {
   aClient.close(function() {
     do_test_finished();
rename from toolkit/devtools/debugger/tests/unit/post_init_global_actors.js
rename to toolkit/devtools/server/tests/unit/post_init_global_actors.js
rename from toolkit/devtools/debugger/tests/unit/post_init_tab_actors.js
rename to toolkit/devtools/server/tests/unit/post_init_tab_actors.js
rename from toolkit/devtools/debugger/tests/unit/pre_init_global_actors.js
rename to toolkit/devtools/server/tests/unit/pre_init_global_actors.js
rename from toolkit/devtools/debugger/tests/unit/pre_init_tab_actors.js
rename to toolkit/devtools/server/tests/unit/pre_init_tab_actors.js
rename from toolkit/devtools/debugger/tests/unit/source-map-data/sourcemapped.coffee
rename to toolkit/devtools/server/tests/unit/source-map-data/sourcemapped.coffee
rename from toolkit/devtools/debugger/tests/unit/source-map-data/sourcemapped.map
rename to toolkit/devtools/server/tests/unit/source-map-data/sourcemapped.map
rename from toolkit/devtools/debugger/tests/unit/sourcemapped.js
rename to toolkit/devtools/server/tests/unit/sourcemapped.js
rename from toolkit/devtools/debugger/tests/unit/test_add_actors.js
rename to toolkit/devtools/server/tests/unit/test_add_actors.js
rename from toolkit/devtools/debugger/tests/unit/test_attach.js
rename to toolkit/devtools/server/tests/unit/test_attach.js
rename from toolkit/devtools/debugger/tests/unit/test_breakpoint-01.js
rename to toolkit/devtools/server/tests/unit/test_breakpoint-01.js
rename from toolkit/devtools/debugger/tests/unit/test_breakpoint-02.js
rename to toolkit/devtools/server/tests/unit/test_breakpoint-02.js
rename from toolkit/devtools/debugger/tests/unit/test_breakpoint-03.js
rename to toolkit/devtools/server/tests/unit/test_breakpoint-03.js
rename from toolkit/devtools/debugger/tests/unit/test_breakpoint-04.js
rename to toolkit/devtools/server/tests/unit/test_breakpoint-04.js
rename from toolkit/devtools/debugger/tests/unit/test_breakpoint-05.js
rename to toolkit/devtools/server/tests/unit/test_breakpoint-05.js
rename from toolkit/devtools/debugger/tests/unit/test_breakpoint-06.js
rename to toolkit/devtools/server/tests/unit/test_breakpoint-06.js
rename from toolkit/devtools/debugger/tests/unit/test_breakpoint-07.js
rename to toolkit/devtools/server/tests/unit/test_breakpoint-07.js
rename from toolkit/devtools/debugger/tests/unit/test_breakpoint-08.js
rename to toolkit/devtools/server/tests/unit/test_breakpoint-08.js
rename from toolkit/devtools/debugger/tests/unit/test_breakpoint-09.js
rename to toolkit/devtools/server/tests/unit/test_breakpoint-09.js
rename from toolkit/devtools/debugger/tests/unit/test_breakpoint-10.js
rename to toolkit/devtools/server/tests/unit/test_breakpoint-10.js
rename from toolkit/devtools/debugger/tests/unit/test_breakpoint-11.js
rename to toolkit/devtools/server/tests/unit/test_breakpoint-11.js
rename from toolkit/devtools/debugger/tests/unit/test_breakpoint-12.js
rename to toolkit/devtools/server/tests/unit/test_breakpoint-12.js
rename from toolkit/devtools/debugger/tests/unit/test_breakpointstore.js
rename to toolkit/devtools/server/tests/unit/test_breakpointstore.js
--- a/toolkit/devtools/debugger/tests/unit/test_breakpointstore.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpointstore.js
@@ -6,16 +6,16 @@
 // ThreadActor._breakpointStore.
 
 function run_test()
 {
   Cu.import("resource://gre/modules/jsdebugger.jsm");
   addDebuggerToGlobal(this);
   let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
     .getService(Components.interfaces.mozIJSSubScriptLoader);
-  loader.loadSubScript("chrome://global/content/devtools/dbg-script-actors.js");
+  loader.loadSubScript("resource://gre/modules/devtools/server/actors/script.js");
 
   let instance1 = new ThreadActor();
   let instance2 = new ThreadActor();
   do_check_eq(instance1._breakpointStore, ThreadActor._breakpointStore);
   do_check_eq(instance2._breakpointStore, ThreadActor._breakpointStore);
   do_check_eq(instance1._breakpointStore, instance2._breakpointStore);
 }
rename from toolkit/devtools/debugger/tests/unit/test_dbgactor.js
rename to toolkit/devtools/server/tests/unit/test_dbgactor.js
rename from toolkit/devtools/debugger/tests/unit/test_dbgclient_debuggerstatement.js
rename to toolkit/devtools/server/tests/unit/test_dbgclient_debuggerstatement.js
rename from toolkit/devtools/debugger/tests/unit/test_dbgglobal.js
rename to toolkit/devtools/server/tests/unit/test_dbgglobal.js
rename from toolkit/devtools/debugger/tests/unit/test_dbgsocket.js
rename to toolkit/devtools/server/tests/unit/test_dbgsocket.js
rename from toolkit/devtools/debugger/tests/unit/test_eval-01.js
rename to toolkit/devtools/server/tests/unit/test_eval-01.js
rename from toolkit/devtools/debugger/tests/unit/test_eval-02.js
rename to toolkit/devtools/server/tests/unit/test_eval-02.js
rename from toolkit/devtools/debugger/tests/unit/test_eval-03.js
rename to toolkit/devtools/server/tests/unit/test_eval-03.js
rename from toolkit/devtools/debugger/tests/unit/test_eval-04.js
rename to toolkit/devtools/server/tests/unit/test_eval-04.js
rename from toolkit/devtools/debugger/tests/unit/test_eval-05.js
rename to toolkit/devtools/server/tests/unit/test_eval-05.js
rename from toolkit/devtools/debugger/tests/unit/test_frameactor-01.js
rename to toolkit/devtools/server/tests/unit/test_frameactor-01.js
rename from toolkit/devtools/debugger/tests/unit/test_frameactor-02.js
rename to toolkit/devtools/server/tests/unit/test_frameactor-02.js
rename from toolkit/devtools/debugger/tests/unit/test_frameactor-03.js
rename to toolkit/devtools/server/tests/unit/test_frameactor-03.js
rename from toolkit/devtools/debugger/tests/unit/test_frameactor-04.js
rename to toolkit/devtools/server/tests/unit/test_frameactor-04.js
rename from toolkit/devtools/debugger/tests/unit/test_frameactor-05.js
rename to toolkit/devtools/server/tests/unit/test_frameactor-05.js
rename from toolkit/devtools/debugger/tests/unit/test_framearguments-01.js
rename to toolkit/devtools/server/tests/unit/test_framearguments-01.js
rename from toolkit/devtools/debugger/tests/unit/test_framebindings-01.js
rename to toolkit/devtools/server/tests/unit/test_framebindings-01.js
rename from toolkit/devtools/debugger/tests/unit/test_framebindings-02.js
rename to toolkit/devtools/server/tests/unit/test_framebindings-02.js
rename from toolkit/devtools/debugger/tests/unit/test_framebindings-03.js
rename to toolkit/devtools/server/tests/unit/test_framebindings-03.js
rename from toolkit/devtools/debugger/tests/unit/test_framebindings-04.js
rename to toolkit/devtools/server/tests/unit/test_framebindings-04.js
rename from toolkit/devtools/debugger/tests/unit/test_framebindings-05.js
rename to toolkit/devtools/server/tests/unit/test_framebindings-05.js
rename from toolkit/devtools/debugger/tests/unit/test_framebindings-06.js
rename to toolkit/devtools/server/tests/unit/test_framebindings-06.js
rename from toolkit/devtools/debugger/tests/unit/test_frameclient-01.js
rename to toolkit/devtools/server/tests/unit/test_frameclient-01.js
rename from toolkit/devtools/debugger/tests/unit/test_frameclient-02.js
rename to toolkit/devtools/server/tests/unit/test_frameclient-02.js
rename from toolkit/devtools/debugger/tests/unit/test_functiongrips-01.js
rename to toolkit/devtools/server/tests/unit/test_functiongrips-01.js
rename from toolkit/devtools/debugger/tests/unit/test_getyoungestframe.js
rename to toolkit/devtools/server/tests/unit/test_getyoungestframe.js
--- a/toolkit/devtools/debugger/tests/unit/test_getyoungestframe.js
+++ b/toolkit/devtools/server/tests/unit/test_getyoungestframe.js
@@ -1,27 +1,30 @@
 function run_test()
 {
   Components.utils.import("resource://gre/modules/jsdebugger.jsm");
   addDebuggerToGlobal(this);
   var xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
   var g = testGlobal("test1");
 
   var dbg = new Debugger();
+  dbg.uncaughtExceptionHook = testExceptionHook;
+
   dbg.addDebuggee(g);
   dbg.onDebuggerStatement = function(aFrame) {
     do_check_true(aFrame === dbg.getNewestFrame());
     // Execute from the nested event loop, dbg.getNewestFrame() won't
     // be working anymore.
+
     do_execute_soon(function() {
       try {
         do_check_true(aFrame === dbg.getNewestFrame());
       } finally {
-        xpcInspector.exitNestedEventLoop();
+        xpcInspector.exitNestedEventLoop("test");
       }
     });
-    xpcInspector.enterNestedEventLoop();
+    xpcInspector.enterNestedEventLoop("test");
   };
 
   g.eval("function debuggerStatement() { debugger; }; debuggerStatement();");
 
   dbg.enabled = false;
 }
rename from toolkit/devtools/debugger/tests/unit/test_interrupt.js
rename to toolkit/devtools/server/tests/unit/test_interrupt.js
rename from toolkit/devtools/debugger/tests/unit/test_listsources-01.js
rename to toolkit/devtools/server/tests/unit/test_listsources-01.js
rename from toolkit/devtools/debugger/tests/unit/test_listsources-02.js
rename to toolkit/devtools/server/tests/unit/test_listsources-02.js
rename from toolkit/devtools/debugger/tests/unit/test_listsources-03.js
rename to toolkit/devtools/server/tests/unit/test_listsources-03.js
rename from toolkit/devtools/debugger/tests/unit/test_longstringactor.js
rename to toolkit/devtools/server/tests/unit/test_longstringactor.js
--- a/toolkit/devtools/debugger/tests/unit/test_longstringactor.js
+++ b/toolkit/devtools/server/tests/unit/test_longstringactor.js
@@ -3,17 +3,17 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function run_test()
 {
   Cu.import("resource://gre/modules/jsdebugger.jsm");
   addDebuggerToGlobal(this);
   let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
     .getService(Components.interfaces.mozIJSSubScriptLoader);
-  loader.loadSubScript("chrome://global/content/devtools/dbg-script-actors.js");
+  loader.loadSubScript("resource://gre/modules/devtools/server/actors/script.js");
 
   test_LSA_disconnect();
   test_LSA_grip();
   test_LSA_onSubstring();
 }
 
 const TEST_STRING = "This is a very long string!";
 
rename from toolkit/devtools/debugger/tests/unit/test_longstringgrips-01.js
rename to toolkit/devtools/server/tests/unit/test_longstringgrips-01.js
rename from toolkit/devtools/debugger/tests/unit/test_longstringgrips-02.js
rename to toolkit/devtools/server/tests/unit/test_longstringgrips-02.js
rename from toolkit/devtools/debugger/tests/unit/test_nativewrappers.js
rename to toolkit/devtools/server/tests/unit/test_nativewrappers.js
rename from toolkit/devtools/debugger/tests/unit/test_new_source-01.js
rename to toolkit/devtools/server/tests/unit/test_new_source-01.js
rename from toolkit/devtools/debugger/tests/unit/test_nsjsinspector.js
rename to toolkit/devtools/server/tests/unit/test_nsjsinspector.js
rename from toolkit/devtools/debugger/tests/unit/test_objectgrips-01.js
rename to toolkit/devtools/server/tests/unit/test_objectgrips-01.js
rename from toolkit/devtools/debugger/tests/unit/test_objectgrips-02.js
rename to toolkit/devtools/server/tests/unit/test_objectgrips-02.js
rename from toolkit/devtools/debugger/tests/unit/test_objectgrips-03.js
rename to toolkit/devtools/server/tests/unit/test_objectgrips-03.js
rename from toolkit/devtools/debugger/tests/unit/test_objectgrips-04.js
rename to toolkit/devtools/server/tests/unit/test_objectgrips-04.js
rename from toolkit/devtools/debugger/tests/unit/test_pause_exceptions-01.js
rename to toolkit/devtools/server/tests/unit/test_pause_exceptions-01.js
rename from toolkit/devtools/debugger/tests/unit/test_pause_exceptions-02.js
rename to toolkit/devtools/server/tests/unit/test_pause_exceptions-02.js
rename from toolkit/devtools/debugger/tests/unit/test_pauselifetime-01.js
rename to toolkit/devtools/server/tests/unit/test_pauselifetime-01.js
rename from toolkit/devtools/debugger/tests/unit/test_pauselifetime-02.js
rename to toolkit/devtools/server/tests/unit/test_pauselifetime-02.js
rename from toolkit/devtools/debugger/tests/unit/test_pauselifetime-03.js
rename to toolkit/devtools/server/tests/unit/test_pauselifetime-03.js
rename from toolkit/devtools/debugger/tests/unit/test_pauselifetime-04.js
rename to toolkit/devtools/server/tests/unit/test_pauselifetime-04.js
rename from toolkit/devtools/debugger/tests/unit/test_profiler_actor.js
rename to toolkit/devtools/server/tests/unit/test_profiler_actor.js
rename from toolkit/devtools/debugger/tests/unit/test_source-01.js
rename to toolkit/devtools/server/tests/unit/test_source-01.js
rename from toolkit/devtools/debugger/tests/unit/test_sourcemaps-01.js
rename to toolkit/devtools/server/tests/unit/test_sourcemaps-01.js
rename from toolkit/devtools/debugger/tests/unit/test_sourcemaps-02.js
rename to toolkit/devtools/server/tests/unit/test_sourcemaps-02.js
rename from toolkit/devtools/debugger/tests/unit/test_sourcemaps-03.js
rename to toolkit/devtools/server/tests/unit/test_sourcemaps-03.js
rename from toolkit/devtools/debugger/tests/unit/test_sourcemaps-04.js
rename to toolkit/devtools/server/tests/unit/test_sourcemaps-04.js
rename from toolkit/devtools/debugger/tests/unit/test_sourcemaps-05.js
rename to toolkit/devtools/server/tests/unit/test_sourcemaps-05.js
rename from toolkit/devtools/debugger/tests/unit/test_sourcemaps-06.js
rename to toolkit/devtools/server/tests/unit/test_sourcemaps-06.js
rename from toolkit/devtools/debugger/tests/unit/test_sourcemaps-07.js
rename to toolkit/devtools/server/tests/unit/test_sourcemaps-07.js
rename from toolkit/devtools/debugger/tests/unit/test_sources_backwards_compat-01.js
rename to toolkit/devtools/server/tests/unit/test_sources_backwards_compat-01.js
rename from toolkit/devtools/debugger/tests/unit/test_sources_backwards_compat-02.js
rename to toolkit/devtools/server/tests/unit/test_sources_backwards_compat-02.js
rename from toolkit/devtools/debugger/tests/unit/test_stepping-01.js
rename to toolkit/devtools/server/tests/unit/test_stepping-01.js
rename from toolkit/devtools/debugger/tests/unit/test_stepping-02.js
rename to toolkit/devtools/server/tests/unit/test_stepping-02.js
rename from toolkit/devtools/debugger/tests/unit/test_stepping-03.js
rename to toolkit/devtools/server/tests/unit/test_stepping-03.js
rename from toolkit/devtools/debugger/tests/unit/test_stepping-04.js
rename to toolkit/devtools/server/tests/unit/test_stepping-04.js
rename from toolkit/devtools/debugger/tests/unit/test_stepping-05.js
rename to toolkit/devtools/server/tests/unit/test_stepping-05.js
rename from toolkit/devtools/debugger/tests/unit/test_threadlifetime-01.js
rename to toolkit/devtools/server/tests/unit/test_threadlifetime-01.js
rename from toolkit/devtools/debugger/tests/unit/test_threadlifetime-02.js
rename to toolkit/devtools/server/tests/unit/test_threadlifetime-02.js
rename from toolkit/devtools/debugger/tests/unit/test_threadlifetime-03.js
rename to toolkit/devtools/server/tests/unit/test_threadlifetime-03.js
rename from toolkit/devtools/debugger/tests/unit/test_threadlifetime-04.js
rename to toolkit/devtools/server/tests/unit/test_threadlifetime-04.js
rename from toolkit/devtools/debugger/tests/unit/test_threadlifetime-05.js
rename to toolkit/devtools/server/tests/unit/test_threadlifetime-05.js
rename from toolkit/devtools/debugger/tests/unit/test_threadlifetime-06.js
rename to toolkit/devtools/server/tests/unit/test_threadlifetime-06.js
rename from toolkit/devtools/debugger/tests/unit/test_unsafeDereference.js
rename to toolkit/devtools/server/tests/unit/test_unsafeDereference.js
rename from toolkit/devtools/debugger/tests/unit/testactors.js
rename to toolkit/devtools/server/tests/unit/testactors.js
rename from toolkit/devtools/debugger/tests/unit/testcompatactors.js
rename to toolkit/devtools/server/tests/unit/testcompatactors.js
rename from toolkit/devtools/debugger/tests/unit/xpcshell.ini
rename to toolkit/devtools/server/tests/unit/xpcshell.ini
rename from toolkit/devtools/debugger/dbg-transport.js
rename to toolkit/devtools/server/transport.js
deleted file mode 100644
--- a/toolkit/devtools/styleeditor/Makefile.in
+++ /dev/null
@@ -1,14 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-DEPTH = ../../..
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-include $(topsrcdir)/config/rules.mk
-
-#libs::
-#  $(INSTALL) $(IFLAGS1) $(srcdir)/*.jsm $(FINAL_TARGET)/modules/devtools
deleted file mode 100644
--- a/toolkit/devtools/styleeditor/moz.build
+++ /dev/null
@@ -1,5 +0,0 @@
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-