mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Merge mozilla-central to fx-team
This commit is contained in:
commit
dd1b1c63d2
@ -259,6 +259,8 @@ SocialUI = {
|
||||
// called on tab/urlbar/location changes and after customization. Update
|
||||
// anything that is tab specific.
|
||||
updateState: function() {
|
||||
if (location == "about:customizing")
|
||||
return;
|
||||
goSetCommandEnabled("Social:PageShareOrMark", this.canShareOrMarkPage(gBrowser.currentURI));
|
||||
if (!SocialUI.enabled)
|
||||
return;
|
||||
|
@ -183,6 +183,9 @@ if (AppConstants.MOZ_SAFE_BROWSING) {
|
||||
"resource://gre/modules/SafeBrowsing.jsm");
|
||||
}
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "gCustomizationTabPreloader",
|
||||
"resource:///modules/CustomizationTabPreloader.jsm", "CustomizationTabPreloader");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
|
||||
"resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
|
||||
@ -4338,7 +4341,7 @@ var XULBrowserWindow = {
|
||||
URLBarSetURI(aLocationURI);
|
||||
|
||||
BookmarkingUI.onLocationChange();
|
||||
SocialUI.updateState();
|
||||
SocialUI.updateState(location);
|
||||
UITour.onLocationChange(location);
|
||||
gTabletModePageCounter.inc();
|
||||
}
|
||||
@ -4386,11 +4389,12 @@ var XULBrowserWindow = {
|
||||
|
||||
// Try not to instantiate gCustomizeMode as much as possible,
|
||||
// so don't use CustomizeMode.jsm to check for URI or customizing.
|
||||
if (location == "about:blank" &&
|
||||
gBrowser.selectedTab.hasAttribute("customizemode")) {
|
||||
let customizingURI = "about:customizing";
|
||||
if (location == customizingURI) {
|
||||
gCustomizeMode.enter();
|
||||
} else if (CustomizationHandler.isEnteringCustomizeMode ||
|
||||
CustomizationHandler.isCustomizing()) {
|
||||
} else if (location != customizingURI &&
|
||||
(CustomizationHandler.isEnteringCustomizeMode ||
|
||||
CustomizationHandler.isCustomizing())) {
|
||||
gCustomizeMode.exit();
|
||||
}
|
||||
}
|
||||
@ -6388,9 +6392,6 @@ function isTabEmpty(aTab) {
|
||||
if (aTab.hasAttribute("busy"))
|
||||
return false;
|
||||
|
||||
if (aTab.hasAttribute("customizemode"))
|
||||
return false;
|
||||
|
||||
let browser = aTab.linkedBrowser;
|
||||
if (!isBlankPageURL(browser.currentURI.spec))
|
||||
return false;
|
||||
@ -7343,6 +7344,7 @@ function switchToTabHavingURI(aURI, aOpenNew, aOpenParams={}) {
|
||||
// window being in private browsing mode:
|
||||
const kPrivateBrowsingWhitelist = new Set([
|
||||
"about:addons",
|
||||
"about:customizing",
|
||||
]);
|
||||
|
||||
let ignoreFragment = aOpenParams.ignoreFragment;
|
||||
|
@ -1398,11 +1398,6 @@
|
||||
|
||||
crop = "center";
|
||||
|
||||
} else if (aTab.hasAttribute("customizemode")) {
|
||||
let brandBundle = document.getElementById("bundle_brand");
|
||||
let brandShortName = brandBundle.getString("brandShortName");
|
||||
title = gNavigatorBundle.getFormattedString("customizeMode.tabTitle",
|
||||
[ brandShortName ]);
|
||||
} else // Still no title? Fall back to our untitled string.
|
||||
title = this.mStringBundle.getString("tabs.emptyTabTitle");
|
||||
}
|
||||
@ -1931,6 +1926,11 @@
|
||||
|
||||
b.droppedLinkHandler = handleDroppedLink;
|
||||
|
||||
// Swap in a preloaded customize tab, if available.
|
||||
if (aURI == "about:customizing") {
|
||||
usingPreloadedContent = gCustomizationTabPreloader.newTab(t);
|
||||
}
|
||||
|
||||
// Dispatch a new tab notification. We do this once we're
|
||||
// entirely done, so that things are in a consistent state
|
||||
// even if the event listener opens or closes tabs.
|
||||
@ -2474,6 +2474,33 @@
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="swapNewTabWithBrowser">
|
||||
<parameter name="aNewTab"/>
|
||||
<parameter name="aBrowser"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
// The browser must be standalone.
|
||||
if (aBrowser.getTabBrowser())
|
||||
throw Cr.NS_ERROR_INVALID_ARG;
|
||||
|
||||
// The tab is definitely not loading.
|
||||
aNewTab.removeAttribute("busy");
|
||||
if (aNewTab.selected) {
|
||||
this.mIsBusy = false;
|
||||
}
|
||||
|
||||
this._swapBrowserDocShells(aNewTab, aBrowser);
|
||||
|
||||
// Update the new tab's title.
|
||||
this.setTabTitle(aNewTab);
|
||||
|
||||
if (aNewTab.selected) {
|
||||
this.updateCurrentBrowser(true);
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="swapBrowsersAndCloseOther">
|
||||
<parameter name="aOurTab"/>
|
||||
<parameter name="aOtherTab"/>
|
||||
|
@ -99,6 +99,8 @@ static RedirEntry kRedirMap[] = {
|
||||
#endif
|
||||
{ "accounts", "chrome://browser/content/aboutaccounts/aboutaccounts.xhtml",
|
||||
nsIAboutModule::ALLOW_SCRIPT },
|
||||
{ "customizing", "chrome://browser/content/customizableui/aboutCustomizing.xul",
|
||||
nsIAboutModule::ALLOW_SCRIPT },
|
||||
{ "loopconversation", "chrome://loop/content/panels/conversation.html",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
|
||||
nsIAboutModule::ALLOW_SCRIPT |
|
||||
|
@ -107,6 +107,7 @@ static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
|
||||
#ifdef MOZ_SERVICES_HEALTHREPORT
|
||||
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "healthreport", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
|
||||
#endif
|
||||
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "customizing", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
|
||||
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "looppanel", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
|
||||
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "loopconversation", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
|
||||
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "reader", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
|
||||
|
@ -11,6 +11,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
const kPrefCustomizationDebug = "browser.uiCustomization.debug";
|
||||
const kPrefCustomizationAnimation = "browser.uiCustomization.disableAnimation";
|
||||
const kPaletteId = "customization-palette";
|
||||
const kAboutURI = "about:customizing";
|
||||
const kDragDataTypePrefix = "text/toolbarwrapper-id/";
|
||||
const kPlaceholderClass = "panel-customization-placeholder";
|
||||
const kSkipSourceNodePref = "browser.uiCustomization.skipSourceNodeCheck";
|
||||
@ -35,8 +36,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "BrowserUITelemetry",
|
||||
"resource:///modules/BrowserUITelemetry.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
|
||||
"resource://gre/modules/LightweightThemeManager.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "SessionStore",
|
||||
"resource:///modules/sessionstore/SessionStore.jsm");
|
||||
|
||||
let gDebug;
|
||||
XPCOMUtils.defineLazyGetter(this, "log", () => {
|
||||
@ -57,23 +56,6 @@ var gDisableAnimation = null;
|
||||
|
||||
var gDraggingInToolbars;
|
||||
|
||||
var gTab;
|
||||
|
||||
function closeGlobalTab() {
|
||||
let win = gTab.ownerGlobal;
|
||||
if (win.gBrowser.browsers.length == 1) {
|
||||
win.BrowserOpenTab();
|
||||
}
|
||||
win.gBrowser.removeTab(gTab);
|
||||
}
|
||||
|
||||
function unregisterGlobalTab() {
|
||||
gTab.removeEventListener("TabClose", unregisterGlobalTab);
|
||||
gTab.ownerGlobal.removeEventListener("unload", unregisterGlobalTab);
|
||||
gTab.removeAttribute("customizemode");
|
||||
gTab = null;
|
||||
}
|
||||
|
||||
function CustomizeMode(aWindow) {
|
||||
if (gDisableAnimation === null) {
|
||||
gDisableAnimation = Services.prefs.getPrefType(kPrefCustomizationAnimation) == Ci.nsIPrefBranch.PREF_BOOL &&
|
||||
@ -158,32 +140,6 @@ CustomizeMode.prototype = {
|
||||
lwthemeIcon.style.backgroundImage = "url(" + imageURL + ")";
|
||||
},
|
||||
|
||||
setTab: function(aTab) {
|
||||
if (gTab) {
|
||||
closeGlobalTab();
|
||||
}
|
||||
|
||||
gTab = aTab;
|
||||
|
||||
gTab.setAttribute("customizemode", "true");
|
||||
SessionStore.persistTabAttribute("customizemode");
|
||||
|
||||
gTab.linkedBrowser.stop();
|
||||
|
||||
let win = gTab.ownerGlobal;
|
||||
|
||||
win.gBrowser.setTabTitle(gTab);
|
||||
win.gBrowser.setIcon(gTab,
|
||||
"chrome://browser/skin/customizableui/customizeFavicon.ico");
|
||||
|
||||
gTab.addEventListener("TabClose", unregisterGlobalTab);
|
||||
win.addEventListener("unload", unregisterGlobalTab);
|
||||
|
||||
if (gTab.selected) {
|
||||
win.gCustomizeMode.enter();
|
||||
}
|
||||
},
|
||||
|
||||
enter: function() {
|
||||
this._wantToBeInCustomizeMode = true;
|
||||
|
||||
@ -198,17 +154,13 @@ CustomizeMode.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gTab) {
|
||||
this.setTab(this.browser.loadOneTab("about:blank",
|
||||
{ inBackground: false,
|
||||
skipAnimation: true }));
|
||||
return;
|
||||
}
|
||||
if (!gTab.selected) {
|
||||
gTab.ownerGlobal.gBrowser.selectedTab = gTab;
|
||||
}
|
||||
gTab.ownerGlobal.focus();
|
||||
if (gTab.ownerDocument != this.document) {
|
||||
|
||||
// We don't need to switch to kAboutURI, or open a new tab at
|
||||
// kAboutURI if we're already on it.
|
||||
if (this.browser.selectedBrowser.currentURI.spec != kAboutURI) {
|
||||
this.window.switchToTabHavingURI(kAboutURI, true, {
|
||||
skipTabAnimation: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@ -361,6 +313,10 @@ CustomizeMode.prototype = {
|
||||
delete this._enableOutlinesTimeout;
|
||||
}, 0);
|
||||
|
||||
// It's possible that we didn't enter customize mode via the menu panel,
|
||||
// meaning we didn't kick off about:customizing preloading. If that's
|
||||
// the case, let's kick it off for the next time we load this mode.
|
||||
window.gCustomizationTabPreloader.ensurePreloading();
|
||||
if (!this._wantToBeInCustomizeMode) {
|
||||
this.exit();
|
||||
}
|
||||
@ -446,14 +402,31 @@ CustomizeMode.prototype = {
|
||||
|
||||
Services.obs.removeObserver(this, "lightweight-theme-window-updated", false);
|
||||
|
||||
if (this.browser.selectedTab == gTab) {
|
||||
if (gTab.linkedBrowser.currentURI.spec == "about:blank") {
|
||||
closeGlobalTab();
|
||||
let browser = document.getElementById("browser");
|
||||
if (this.browser.selectedBrowser.currentURI.spec == kAboutURI) {
|
||||
let custBrowser = this.browser.selectedBrowser;
|
||||
if (custBrowser.canGoBack) {
|
||||
// If there's history to this tab, just go back.
|
||||
// Note that this throws an exception if the previous document has a
|
||||
// problematic URL (e.g. about:idontexist)
|
||||
try {
|
||||
custBrowser.goBack();
|
||||
} catch (ex) {
|
||||
log.error(ex);
|
||||
}
|
||||
} else {
|
||||
unregisterGlobalTab();
|
||||
// If we can't go back, we're removing the about:customization tab.
|
||||
// We only do this if we're the top window for this window (so not
|
||||
// a dialog window, for example).
|
||||
if (window.getTopWin(true) == window) {
|
||||
let customizationTab = this.browser.selectedTab;
|
||||
if (this.browser.browsers.length == 1) {
|
||||
window.BrowserOpenTab();
|
||||
}
|
||||
this.browser.removeTab(customizationTab);
|
||||
}
|
||||
}
|
||||
}
|
||||
let browser = document.getElementById("browser");
|
||||
browser.parentNode.selectedPanel = browser;
|
||||
let customizer = document.getElementById("customization-container");
|
||||
customizer.hidden = true;
|
||||
|
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- 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/. -->
|
||||
|
||||
<!DOCTYPE window [
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
|
||||
%brandDTD;
|
||||
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd">
|
||||
%browserDTD;
|
||||
]>
|
||||
|
||||
<window id="aboutCustomizingWindow"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
title="&customizeMode.tabTitle;">
|
||||
<html:head>
|
||||
<html:link rel="icon" type="image/x-icon"
|
||||
href="chrome://browser/skin/customizableui/customizeFavicon.ico"/>
|
||||
</html:head>
|
||||
</window>
|
@ -3,6 +3,7 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
browser.jar:
|
||||
content/browser/customizableui/aboutCustomizing.xul
|
||||
content/browser/customizableui/panelUI.css
|
||||
content/browser/customizableui/panelUI.js
|
||||
content/browser/customizableui/panelUI.xml
|
||||
|
@ -157,6 +157,10 @@ const PanelUI = {
|
||||
|
||||
this.panel.addEventListener("popupshown", function onPopupShown() {
|
||||
this.removeEventListener("popupshown", onPopupShown);
|
||||
// As an optimization for the customize mode transition, we preload
|
||||
// about:customizing in the background once the menu panel is first
|
||||
// shown.
|
||||
gCustomizationTabPreloader.ensurePreloading();
|
||||
deferred.resolve();
|
||||
});
|
||||
|
||||
|
@ -25,6 +25,7 @@ skip-if = os == "mac"
|
||||
[browser_886323_buildArea_removable_nodes.js]
|
||||
[browser_887438_currentset_shim.js]
|
||||
[browser_888817_currentset_updating.js]
|
||||
[browser_889120_customize_tab_merging.js]
|
||||
[browser_890140_orphaned_placeholders.js]
|
||||
[browser_890262_destroyWidget_after_add_to_panel.js]
|
||||
[browser_892955_isWidgetRemovable_for_removed_widgets.js]
|
||||
|
@ -0,0 +1,44 @@
|
||||
/* 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";
|
||||
|
||||
const kTestToolbarId = "test-empty-drag";
|
||||
|
||||
// Attempting to switch quickly from one tab to another to see whether the state changes
|
||||
// correctly.
|
||||
add_task(function* CheckBasicCustomizeMode() {
|
||||
yield startCustomizing();
|
||||
ok(CustomizationHandler.isCustomizing(), "We should be in customize mode");
|
||||
yield endCustomizing();
|
||||
ok(!CustomizationHandler.isCustomizing(), "We should not be in customize mode");
|
||||
});
|
||||
add_task(function* CheckQuickCustomizeModeSwitch() {
|
||||
let tab1 = gBrowser.addTab("about:newtab");
|
||||
gBrowser.selectedTab = tab1;
|
||||
let tab2 = gBrowser.addTab("about:customizing");
|
||||
let tab3 = gBrowser.addTab("about:newtab");
|
||||
gBrowser.selectedTab = tab2;
|
||||
try {
|
||||
yield waitForCondition(() => CustomizationHandler.isEnteringCustomizeMode);
|
||||
} catch (ex) {
|
||||
Cu.reportError(ex);
|
||||
}
|
||||
ok(CustomizationHandler.isEnteringCustomizeMode, "Should be entering customize mode");
|
||||
gBrowser.selectedTab = tab3;
|
||||
try {
|
||||
yield waitForCondition(() => !CustomizationHandler.isEnteringCustomizeMode && !CustomizationHandler.isCustomizing());
|
||||
} catch (ex) {
|
||||
Cu.reportError(ex);
|
||||
}
|
||||
ok(!CustomizationHandler.isCustomizing(), "Should not be entering customize mode");
|
||||
gBrowser.removeTab(tab1);
|
||||
gBrowser.removeTab(tab2);
|
||||
gBrowser.removeTab(tab3);
|
||||
});
|
||||
|
||||
add_task(function* asyncCleanup() {
|
||||
yield endCustomizing();
|
||||
});
|
||||
|
@ -58,6 +58,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "WebappManager",
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PageThumbs",
|
||||
"resource://gre/modules/PageThumbs.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "CustomizationTabPreloader",
|
||||
"resource:///modules/CustomizationTabPreloader.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PdfJs",
|
||||
"resource://pdf.js/PdfJs.jsm");
|
||||
|
||||
@ -1069,6 +1072,7 @@ BrowserGlue.prototype = {
|
||||
|
||||
SelfSupportBackend.uninit();
|
||||
|
||||
CustomizationTabPreloader.uninit();
|
||||
WebappManager.uninit();
|
||||
|
||||
NewTabPrefsProvider.prefs.uninit();
|
||||
|
@ -801,8 +801,6 @@ var SessionStoreInternal = {
|
||||
tab.label = activePageData.url;
|
||||
tab.crop = "center";
|
||||
}
|
||||
} else if (tab.hasAttribute("customizemode")) {
|
||||
win.gCustomizeMode.setTab(tab);
|
||||
}
|
||||
|
||||
// Restore the tab icon.
|
||||
@ -3301,10 +3299,6 @@ var SessionStoreInternal = {
|
||||
* optional load arguments used for loadURI()
|
||||
*/
|
||||
restoreTabContent: function (aTab, aLoadArguments = null) {
|
||||
if (aTab.hasAttribute("customizemode")) {
|
||||
return;
|
||||
}
|
||||
|
||||
let browser = aTab.linkedBrowser;
|
||||
let window = aTab.ownerDocument.defaultView;
|
||||
let tabbrowser = window.gBrowser;
|
||||
|
@ -844,6 +844,7 @@ you can use these alternative items. Otherwise, their values should be empty. -
|
||||
<!ENTITY social.directory.introText "Click on a service to add it to &brandShortName;.">
|
||||
<!ENTITY social.directory.viewmore.text "View More">
|
||||
|
||||
<!ENTITY customizeMode.tabTitle "Customize &brandShortName;">
|
||||
<!ENTITY customizeMode.menuAndToolbars.header2 "Additional Tools and Features">
|
||||
<!ENTITY customizeMode.menuAndToolbars.empty "Want more tools?">
|
||||
<!ENTITY customizeMode.menuAndToolbars.emptyLink "Choose from thousands of add-ons">
|
||||
|
@ -689,9 +689,6 @@ customizeTips.tip0 = %1$S: You can customize %2$S to work the way you do. Simply
|
||||
customizeTips.tip0.hint = Hint
|
||||
customizeTips.tip0.learnMore = Learn more
|
||||
|
||||
# LOCALIZATION NOTE (customizeMode.tabTitle): %S is brandShortName
|
||||
customizeMode.tabTitle = Customize %S
|
||||
|
||||
# LOCALIZATION NOTE(appmenu.*.description, appmenu.*.label): these are used for
|
||||
# the appmenu labels and buttons that appear when an update is staged for
|
||||
# installation or a background update has failed and a manual download is required.
|
||||
|
173
browser/modules/CustomizationTabPreloader.jsm
Normal file
173
browser/modules/CustomizationTabPreloader.jsm
Normal file
@ -0,0 +1,173 @@
|
||||
/* 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.EXPORTED_SYMBOLS = ["CustomizationTabPreloader"];
|
||||
|
||||
const Cu = Components.utils;
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Promise.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "HiddenFrame",
|
||||
"resource:///modules/HiddenFrame.jsm");
|
||||
|
||||
const HTML_NS = "http://www.w3.org/1999/xhtml";
|
||||
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
const XUL_PAGE = "data:application/vnd.mozilla.xul+xml;charset=utf-8,<window%20id='win'/>";
|
||||
const CUSTOMIZATION_URL = "about:customizing";
|
||||
|
||||
// The interval between swapping in a preload docShell and kicking off the
|
||||
// next preload in the background.
|
||||
const PRELOADER_INTERVAL_MS = 600;
|
||||
|
||||
function createTimer(obj, delay) {
|
||||
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
timer.init(obj, delay, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
return timer;
|
||||
}
|
||||
|
||||
function clearTimer(timer) {
|
||||
if (timer) {
|
||||
timer.cancel();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
this.CustomizationTabPreloader = {
|
||||
uninit: function () {
|
||||
CustomizationTabPreloaderInternal.uninit();
|
||||
},
|
||||
|
||||
newTab: function (aTab) {
|
||||
return CustomizationTabPreloaderInternal.newTab(aTab);
|
||||
},
|
||||
|
||||
/**
|
||||
* ensurePreloading starts the preloading of the about:customizing
|
||||
* content page. This function is idempotent (until a call to uninit),
|
||||
* so multiple calls to it are fine.
|
||||
*/
|
||||
ensurePreloading: function() {
|
||||
CustomizationTabPreloaderInternal.ensurePreloading();
|
||||
},
|
||||
};
|
||||
|
||||
Object.freeze(CustomizationTabPreloader);
|
||||
|
||||
this.CustomizationTabPreloaderInternal = {
|
||||
_browser: null,
|
||||
|
||||
uninit: function () {
|
||||
if (this._browser) {
|
||||
this._browser.destroy();
|
||||
this._browser = null;
|
||||
}
|
||||
},
|
||||
|
||||
newTab: function (aTab) {
|
||||
let win = aTab.ownerDocument.defaultView;
|
||||
if (win.gBrowser && this._browser) {
|
||||
return this._browser.swapWithNewTab(aTab);
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
ensurePreloading: function () {
|
||||
if (!this._browser) {
|
||||
this._browser = new HiddenBrowser();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function HiddenBrowser() {
|
||||
this._createBrowser();
|
||||
}
|
||||
|
||||
HiddenBrowser.prototype = {
|
||||
_timer: null,
|
||||
_hiddenFrame: null,
|
||||
|
||||
get isPreloaded() {
|
||||
return this._browser &&
|
||||
this._browser.contentDocument &&
|
||||
this._browser.contentDocument.readyState === "complete" &&
|
||||
this._browser.currentURI.spec === CUSTOMIZATION_URL;
|
||||
},
|
||||
|
||||
swapWithNewTab: function (aTab) {
|
||||
if (!this.isPreloaded || this._timer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let win = aTab.ownerDocument.defaultView;
|
||||
let tabbrowser = win.gBrowser;
|
||||
|
||||
if (!tabbrowser) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Swap docShells.
|
||||
tabbrowser.swapNewTabWithBrowser(aTab, this._browser);
|
||||
|
||||
// Load all default frame scripts attached to the target window.
|
||||
let mm = aTab.linkedBrowser.messageManager;
|
||||
let scripts = win.getGroupMessageManager("browsers").getDelayedFrameScripts();
|
||||
Array.forEach(scripts, ([script, runGlobal]) => mm.loadFrameScript(script, true, runGlobal));
|
||||
|
||||
// Remove the browser, it will be recreated by a timer.
|
||||
this._removeBrowser();
|
||||
|
||||
// Start a timer that will kick off preloading the next page.
|
||||
this._timer = createTimer(this, PRELOADER_INTERVAL_MS);
|
||||
|
||||
// Signal that we swapped docShells.
|
||||
return true;
|
||||
},
|
||||
|
||||
observe: function () {
|
||||
this._timer = null;
|
||||
|
||||
// Start pre-loading the customization page.
|
||||
this._createBrowser();
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
this._removeBrowser();
|
||||
if (this._hiddenFrame) {
|
||||
this._hiddenFrame.destroy();
|
||||
this._hiddenFrame = null;
|
||||
}
|
||||
this._timer = clearTimer(this._timer);
|
||||
},
|
||||
|
||||
_createBrowser: function () {
|
||||
if (!this._hiddenFrame) {
|
||||
this._hiddenFrame = new HiddenFrame();
|
||||
}
|
||||
|
||||
this._hiddenFrame.get().then(aFrame => {
|
||||
let doc = aFrame.document;
|
||||
this._browser = doc.createElementNS(XUL_NS, "browser");
|
||||
this._browser.permanentKey = {};
|
||||
this._browser.setAttribute("type", "content");
|
||||
this._browser.setAttribute("src", CUSTOMIZATION_URL);
|
||||
this._browser.style.width = "400px";
|
||||
this._browser.style.height = "400px";
|
||||
doc.getElementById("win").appendChild(this._browser);
|
||||
});
|
||||
},
|
||||
|
||||
_removeBrowser: function () {
|
||||
if (this._browser) {
|
||||
this._browser.remove();
|
||||
this._browser = null;
|
||||
}
|
||||
}
|
||||
};
|
@ -22,6 +22,7 @@ EXTRA_JS_MODULES += [
|
||||
'ContentObservers.jsm',
|
||||
'ContentSearch.jsm',
|
||||
'ContentWebRTC.jsm',
|
||||
'CustomizationTabPreloader.jsm',
|
||||
'DirectoryLinksProvider.jsm',
|
||||
'E10SUtils.jsm',
|
||||
'Feeds.jsm',
|
||||
|
@ -39,18 +39,20 @@ function promiseWaitForEvent(object, eventName, capturing = false, chrome = fals
|
||||
|
||||
add_task(function* () {
|
||||
registerCleanupFunction(function () {
|
||||
Services.prefs.clearUserPref("browser.uiCustomization.disableAnimation");
|
||||
window.focus();
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
Services.prefs.setBoolPref("browser.uiCustomization.disableAnimation", true);
|
||||
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
|
||||
|
||||
let pluginTab = gBrowser.selectedTab = gBrowser.addTab();
|
||||
let prefTab = gBrowser.addTab();
|
||||
let customizeTab = gBrowser.addTab();
|
||||
|
||||
yield promiseTabLoad(pluginTab, gTestRoot + "plugin_test.html");
|
||||
yield promiseTabLoad(prefTab, "about:preferences");
|
||||
yield promiseTabLoad(customizeTab, "about:customizing");
|
||||
|
||||
let result = yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() {
|
||||
let doc = content.document;
|
||||
@ -60,8 +62,10 @@ add_task(function* () {
|
||||
|
||||
is(result, true, "plugin is loaded");
|
||||
|
||||
let cpromise = promiseWaitForEvent(window.gNavToolbox, "customizationready");
|
||||
let ppromise = promiseWaitForEvent(window, "MozAfterPaint");
|
||||
gBrowser.selectedTab = prefTab;
|
||||
gBrowser.selectedTab = customizeTab;
|
||||
yield cpromise;
|
||||
yield ppromise;
|
||||
|
||||
// We're going to switch tabs using actual mouse clicks, which helps
|
||||
@ -73,11 +77,13 @@ add_task(function* () {
|
||||
info("-> " + tabStripContainer.firstChild.tagName); // tab
|
||||
info("-> " + tabStripContainer.childNodes[0].label); // test harness tab
|
||||
info("-> " + tabStripContainer.childNodes[1].label); // plugin tab
|
||||
info("-> " + tabStripContainer.childNodes[2].label); // preferences tab
|
||||
info("-> " + tabStripContainer.childNodes[2].label); // customize tab
|
||||
|
||||
for (let iteration = 0; iteration < 5; iteration++) {
|
||||
cpromise = promiseWaitForEvent(window.gNavToolbox, "aftercustomization");
|
||||
ppromise = promiseWaitForEvent(window, "MozAfterPaint");
|
||||
EventUtils.synthesizeMouseAtCenter(tabStripContainer.childNodes[1], {}, window);
|
||||
yield cpromise;
|
||||
yield ppromise;
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
@ -88,8 +94,10 @@ add_task(function* () {
|
||||
|
||||
is(result, true, "plugin is visible");
|
||||
|
||||
cpromise = promiseWaitForEvent(window.gNavToolbox, "customizationready");
|
||||
ppromise = promiseWaitForEvent(window, "MozAfterPaint");
|
||||
EventUtils.synthesizeMouseAtCenter(tabStripContainer.childNodes[2], {}, window);
|
||||
yield cpromise;
|
||||
yield ppromise;
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
@ -100,6 +108,11 @@ add_task(function* () {
|
||||
is(result, false, "plugin is hidden");
|
||||
}
|
||||
|
||||
gBrowser.removeTab(prefTab);
|
||||
// wait for customize view to shutdown cleanly otherwise we get
|
||||
// a ton of error spew on shutdown.
|
||||
cpromise = promiseWaitForEvent(window.gNavToolbox, "aftercustomization");
|
||||
gBrowser.removeTab(customizeTab);
|
||||
yield cpromise;
|
||||
|
||||
gBrowser.removeTab(pluginTab);
|
||||
});
|
||||
|
@ -8,6 +8,9 @@ Cu.import("resource://gre/modules/Task.jsm");
|
||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "CustomizationTabPreloader",
|
||||
"resource:///modules/CustomizationTabPreloader.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ContentSearch",
|
||||
"resource:///modules/ContentSearch.jsm");
|
||||
|
||||
@ -616,6 +619,7 @@ Tester.prototype = {
|
||||
socialSidebar.setAttribute("src", "about:blank");
|
||||
|
||||
SelfSupportBackend.uninit();
|
||||
CustomizationTabPreloader.uninit();
|
||||
SocialFlyout.unload();
|
||||
SocialShare.uninit();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user