Loading services/sync/tests/tps/test_privbrw_tabs.js +1 −3 Original line number Diff line number Diff line Loading @@ -58,7 +58,6 @@ var tabs3 = [ } ]; /* * Test phases */ Loading @@ -77,7 +76,7 @@ Phase('phase2', [ Phase('phase3', [ [Sync], [SetPrivateBrowsing, true], [Windows.add, { private: true }], [Tabs.add, tabs3], [Sync] ]); Loading @@ -86,4 +85,3 @@ Phase('phase4', [ [Sync], [Tabs.verifyNot, tabs3] ]); services/sync/tps/extensions/tps/modules/tps.jsm +21 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ CU.import("resource://tps/history.jsm"); CU.import("resource://tps/forms.jsm"); CU.import("resource://tps/prefs.jsm"); CU.import("resource://tps/tabs.jsm"); CU.import("resource://tps/windows.jsm"); var hh = CC["@mozilla.org/network/protocol;1?name=http"] .getService(CI.nsIHttpProtocolHandler); Loading Loading @@ -163,6 +164,20 @@ let TPS = { this.goQuitApplication(); }, HandleWindows: function (aWindow, action) { Logger.logInfo("executing action " + action.toUpperCase() + " on window " + JSON.stringify(aWindow)); switch(action) { case ACTION_ADD: BrowserWindows.Add(aWindow.private, function(win) { Logger.logInfo("window finished loading"); this.FinishAsyncOperation(); }.bind(this)); break; } Logger.logPass("executing action " + action.toUpperCase() + " on windows"); }, HandleTabs: function (tabs, action) { this._tabsAdded = tabs.length; this._tabsFinished = 0; Loading Loading @@ -927,3 +942,9 @@ var Tabs = { } }; var Windows = { add: function Window__add(aWindow) { TPS.StartAsyncOperation(); TPS.HandleWindows(aWindow, ACTION_ADD); }, }; services/sync/tps/extensions/tps/modules/windows.jsm 0 → 100644 +36 −0 Original line number Diff line number Diff line /* 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/. */ "use strict"; /* This is a JavaScript module (JSM) to be imported via Components.utils.import() and acts as a singleton. Only the following listed symbols will exposed on import, and only when and where imported. */ const EXPORTED_SYMBOLS = ["BrowserWindows"]; const {classes: Cc, interfaces: Ci, utils: Cu} = Components; Cu.import("resource://services-sync/main.js"); let BrowserWindows = { /** * Add * * Opens a new window. Throws on error. * * @param aPrivate The private option. * @return nothing */ Add: function(aPrivate, fn) { let wm = Cc["@mozilla.org/appshell/window-mediator;1"] .getService(Ci.nsIWindowMediator); let mainWindow = wm.getMostRecentWindow("navigator:browser"); let win = mainWindow.OpenBrowserWindow({private: aPrivate}); win.addEventListener("load", function onLoad() { win.removeEventListener("load", onLoad, false); fn.call(win); }, false); } }; Loading
services/sync/tests/tps/test_privbrw_tabs.js +1 −3 Original line number Diff line number Diff line Loading @@ -58,7 +58,6 @@ var tabs3 = [ } ]; /* * Test phases */ Loading @@ -77,7 +76,7 @@ Phase('phase2', [ Phase('phase3', [ [Sync], [SetPrivateBrowsing, true], [Windows.add, { private: true }], [Tabs.add, tabs3], [Sync] ]); Loading @@ -86,4 +85,3 @@ Phase('phase4', [ [Sync], [Tabs.verifyNot, tabs3] ]);
services/sync/tps/extensions/tps/modules/tps.jsm +21 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ CU.import("resource://tps/history.jsm"); CU.import("resource://tps/forms.jsm"); CU.import("resource://tps/prefs.jsm"); CU.import("resource://tps/tabs.jsm"); CU.import("resource://tps/windows.jsm"); var hh = CC["@mozilla.org/network/protocol;1?name=http"] .getService(CI.nsIHttpProtocolHandler); Loading Loading @@ -163,6 +164,20 @@ let TPS = { this.goQuitApplication(); }, HandleWindows: function (aWindow, action) { Logger.logInfo("executing action " + action.toUpperCase() + " on window " + JSON.stringify(aWindow)); switch(action) { case ACTION_ADD: BrowserWindows.Add(aWindow.private, function(win) { Logger.logInfo("window finished loading"); this.FinishAsyncOperation(); }.bind(this)); break; } Logger.logPass("executing action " + action.toUpperCase() + " on windows"); }, HandleTabs: function (tabs, action) { this._tabsAdded = tabs.length; this._tabsFinished = 0; Loading Loading @@ -927,3 +942,9 @@ var Tabs = { } }; var Windows = { add: function Window__add(aWindow) { TPS.StartAsyncOperation(); TPS.HandleWindows(aWindow, ACTION_ADD); }, };
services/sync/tps/extensions/tps/modules/windows.jsm 0 → 100644 +36 −0 Original line number Diff line number Diff line /* 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/. */ "use strict"; /* This is a JavaScript module (JSM) to be imported via Components.utils.import() and acts as a singleton. Only the following listed symbols will exposed on import, and only when and where imported. */ const EXPORTED_SYMBOLS = ["BrowserWindows"]; const {classes: Cc, interfaces: Ci, utils: Cu} = Components; Cu.import("resource://services-sync/main.js"); let BrowserWindows = { /** * Add * * Opens a new window. Throws on error. * * @param aPrivate The private option. * @return nothing */ Add: function(aPrivate, fn) { let wm = Cc["@mozilla.org/appshell/window-mediator;1"] .getService(Ci.nsIWindowMediator); let mainWindow = wm.getMostRecentWindow("navigator:browser"); let win = mainWindow.OpenBrowserWindow({private: aPrivate}); win.addEventListener("load", function onLoad() { win.removeEventListener("load", onLoad, false); fn.call(win); }, false); } };