Merge mozilla-central to mozilla-inbound

This commit is contained in:
Carsten "Tomcat" Book 2013-12-17 13:16:00 +01:00
Родитель da391931de a86d34d423
Коммит cd068df067
87 изменённых файлов: 2935 добавлений и 4305 удалений

Просмотреть файл

@ -1,4 +1,4 @@
{
"revision": "fc5f583668adbaecbe060819db0c4ba96ec238d9",
"revision": "79e25f81e1e868ea9903eca5dd7452f2c778c7ce",
"repo_path": "/integration/gaia-central"
}

Просмотреть файл

@ -202,10 +202,9 @@
key="key_gotoHistory"
observes="viewHistorySidebar"
label="&historyButton.label;"/>
<menuitem id="menu_socialSidebar"
type="checkbox"
autocheck="false"
command="Social:ToggleSidebar"/>
<!-- Service providers with sidebars are inserted between these two menuseperators -->
<menuseparator hidden="true"/>
<menuseparator class="social-provider-menu" hidden="true"/>
</menupopup>
</menu>
<menuseparator/>
@ -447,49 +446,6 @@
accesskey="&addons.accesskey;"
key="key_openAddons"
command="Tools:Addons"/>
<menu id="menu_socialAmbientMenu"
observes="socialActiveBroadcaster">
<menupopup id="menu_social-statusarea-popup">
<menuitem class="social-statusarea-user menuitem-iconic" pack="start" align="center"
observes="socialBroadcaster_userDetails"
oncommand="SocialUI.showProfile(); document.getElementById('social-statusarea-popup').hidePopup();">
<image class="social-statusarea-user-portrait"
observes="socialBroadcaster_userDetails"/>
<vbox>
<label class="social-statusarea-loggedInStatus"
observes="socialBroadcaster_userDetails"/>
</vbox>
</menuitem>
#ifndef XP_WIN
<menuseparator class="social-statusarea-separator"/>
#endif
<menuseparator id="socialAmbientMenuSeparator"
hidden="true"/>
<menuitem class="social-toggle-sidebar-menuitem"
type="checkbox"
autocheck="false"
command="Social:ToggleSidebar"
label="&social.toggleSidebar.label;"
accesskey="&social.toggleSidebar.accesskey;"/>
<menuitem class="social-toggle-notifications-menuitem"
type="checkbox"
autocheck="false"
command="Social:ToggleNotifications"
label="&social.toggleNotifications.label;"
accesskey="&social.toggleNotifications.accesskey;"/>
<menuitem id="menu_focusChatBar"
label="&social.chatBar.label;"
accesskey="&social.chatBar.accesskey;"
key="focusChatBar"
command="Social:FocusChat"
class="show-only-for-keyboard"/>
<menuitem class="social-toggle-menuitem" command="Social:Toggle"/>
<menuseparator class="social-statusarea-separator"/>
<menuseparator class="social-provider-menu" hidden="true"/>
<menuitem class="social-addons-menuitem" command="Social:Addons"
label="&social.addons.label;"/>
</menupopup>
</menu>
#ifdef MOZ_SERVICES_SYNC
<!-- only one of sync-setup or sync-menu will be showing at once -->
<menuitem id="sync-setup"

Просмотреть файл

@ -169,7 +169,6 @@
#endif
<broadcaster id="workOfflineMenuitemState"/>
<broadcaster id="socialSidebarBroadcaster" hidden="true"/>
<broadcaster id="socialActiveBroadcaster" hidden="true"/>
<!-- DevTools broadcasters -->
<broadcaster id="devtoolsMenuBroadcaster_DevToolbox"
@ -214,10 +213,6 @@
<broadcaster id="devtoolsMenuBroadcaster_connect"
label="&devtoolsConnect.label;"
command="Tools:DevToolsConnect"/>
<!-- SocialAPI broadcasters -->
<broadcaster id="socialBroadcaster_userDetails"
notLoggedInLabel="&social.notLoggedIn.label;"/>
</broadcasterset>
<keyset id="mainKeyset">

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -729,12 +729,39 @@ toolbarbutton[type="badged"] {
-moz-binding: url("chrome://browser/content/urlbarBindings.xml#toolbarbutton-badged");
}
toolbarpaletteitem[place="palette"] > toolbarbutton[type="badged"] > .toolbarbutton-badge-container {
padding: 5px;
}
toolbarbutton[type="socialmark"] {
-moz-binding: url("chrome://browser/content/socialmarks.xml#toolbarbutton-marks");
}
toolbarbutton[type="badged"] > .toolbarbutton-badge-container > .toolbarbutton-icon,
toolbarbutton[type="socialmark"] > .toolbarbutton-icon {
width: 16px;
height: 16px;
max-width: 16px;
max-height: 16px;
}
toolbarpaletteitem[place="palette"] > toolbarbutton[type="badged"] > .toolbarbutton-badge-container > .toolbarbutton-icon {
max-width: 32px;
max-height: 32px;
}
@media (min-resolution: 2dppx) {
toolbarbutton[type="badged"] > .toolbarbutton-badge-container > .toolbarbutton-icon,
toolbarbutton[type="socialmark"] > .toolbarbutton-icon {
max-width: 32px;
max-height: 32px;
}
toolbarpaletteitem[place="palette"] > toolbarbutton[type="badged"] > .toolbarbutton-badge-container > .toolbarbutton-icon {
max-width: 64px;
max-height: 64px;
}
}
panelview > .social-panel-frame {
width: auto;
height: auto;
}
/* Note the chatbox 'width' values are duplicated in socialchat.xml */

Просмотреть файл

@ -1352,8 +1352,6 @@ var gBrowserInit = {
}
}
SocialUI.nonBrowserWindowInit();
if (PrivateBrowsingUtils.permanentPrivateBrowsing) {
document.getElementById("macDockMenuNewWindow").hidden = true;
}

Просмотреть файл

@ -213,33 +213,6 @@
<box id="UITourHighlight"></box>
</panel>
<panel id="socialActivatedNotification"
type="arrow"
hidden="true"
align="start"
orient="horizontal"
role="alert">
<image id="social-activation-icon" class="popup-notification-icon"/>
<vbox flex="1">
<description id="social-activation-message" class="popup-notification-description">&social.activated.description;</description>
<spacer flex="1"/>
<hbox pack="start" align="center" class="popup-notification-button-container">
<label id="social-undoactivation-button"
class="text-link"
value="&social.activated.undo.label;"
accesskey="&social.activated.undo.accesskey;"
onclick="SocialUI.undoActivation(this);"/>
<spacer flex="1"/>
<button id="social-activation-button"
default="true"
autofocus="autofocus"
label="&social.ok.label;"
accesskey="&social.ok.accesskey;"
oncommand="SocialUI.activationPanel.hidePopup();"/>
</hbox>
</vbox>
</panel>
<panel id="social-share-panel"
class="social-panel"
type="arrow"
@ -828,58 +801,6 @@
tooltiptext="&sharePageCmd.label;"
cui-areatype="toolbar"
command="Social:SharePage"/>
<toolbaritem id="social-toolbar-item"
class="chromeclass-toolbar-additional toolbaritem-with-separator"
removable="false"
title="&socialToolbar.title;"
hidden="true"
overflows="false"
cui-areatype="toolbar"
observes="socialActiveBroadcaster">
<toolbarbutton id="social-notification-icon" class="default-notification-icon toolbarbutton-1 notification-anchor-icon"
oncommand="PopupNotifications._reshowNotifications(this,
document.getElementById('social-sidebar-browser'));"/>
<toolbarbutton id="social-provider-button"
class="toolbarbutton-1"
type="menu">
<menupopup id="social-statusarea-popup">
<menuitem class="social-statusarea-user menuitem-iconic" pack="start" align="center"
observes="socialBroadcaster_userDetails"
oncommand="SocialUI.showProfile(); document.getElementById('social-statusarea-popup').hidePopup();">
<image class="social-statusarea-user-portrait"
observes="socialBroadcaster_userDetails"/>
<vbox>
<label class="social-statusarea-loggedInStatus"
observes="socialBroadcaster_userDetails"/>
</vbox>
</menuitem>
#ifndef XP_WIN
<menuseparator class="social-statusarea-separator"/>
#endif
<menuitem class="social-toggle-sidebar-menuitem"
type="checkbox"
autocheck="false"
command="Social:ToggleSidebar"
label="&social.toggleSidebar.label;"
accesskey="&social.toggleSidebar.accesskey;"/>
<menuitem class="social-toggle-notifications-menuitem"
type="checkbox"
autocheck="false"
command="Social:ToggleNotifications"
label="&social.toggleNotifications.label;"
accesskey="&social.toggleNotifications.accesskey;"/>
<menuitem class="social-toggle-menuitem" command="Social:Toggle"/>
<menuseparator/>
<menuseparator class="social-provider-menu" hidden="true"/>
<menuitem class="social-addons-menuitem" command="Social:Addons"
label="&social.addons.label;"/>
<menuitem label="&social.learnMore.label;"
accesskey="&social.learnMore.accesskey;"
oncommand="SocialUI.showLearnMore();"/>
</menupopup>
</toolbarbutton>
</toolbaritem>
</hbox>
<toolbarbutton id="nav-bar-overflow-button"
@ -1050,6 +971,37 @@
class="chromeclass-extrachrome"
observes="socialSidebarBroadcaster"
persist="width">
<sidebarheader id="social-sidebar-header" class="sidebar-header" align="center">
<image id="social-sidebar-favico"/>
<label id="social-sidebar-title" class="sidebar-title" persist="value" flex="1" crop="end" control="sidebar"/>
<button id="social-sidebar-button"
type="menu">
<menupopup id="social-statusarea-popup" position="after_end">
<menuitem class="social-toggle-sidebar-menuitem"
type="checkbox"
autocheck="false"
command="Social:ToggleSidebar"
label="&social.toggleSidebar.label;"
accesskey="&social.toggleSidebar.accesskey;"/>
<menuitem class="social-toggle-notifications-menuitem"
type="checkbox"
autocheck="false"
command="Social:ToggleNotifications"
label="&social.toggleNotifications.label;"
accesskey="&social.toggleNotifications.accesskey;"/>
<menuitem class="social-toggle-menuitem" command="Social:Toggle"/>
<menuseparator/>
<menuseparator class="social-provider-menu" hidden="true"/>
<menuitem class="social-addons-menuitem" command="Social:Addons"
label="&social.addons.label;"/>
<menuitem label="&social.learnMore.label;"
accesskey="&social.learnMore.accesskey;"
oncommand="SocialUI.showLearnMore();"/>
</menupopup>
</button>
</sidebarheader>
<browser id="social-sidebar-browser"
type="content"
context="contentAreaContextMenu"

Просмотреть файл

@ -915,7 +915,7 @@ nsContextMenu.prototype = {
reload: function(event) {
if (this.onSocial) {
// full reload of social provider
Social.provider.reload();
Social._getProviderFromOrigin(this.browser.getAttribute("origin")).reload();
} else {
BrowserReloadOrDuplicate(event);
}

Просмотреть файл

@ -9,23 +9,52 @@
<binding id="toolbarbutton-marks" display="xul:button"
extends="chrome://global/content/bindings/toolbarbutton.xml#toolbarbutton">
<content disabled="true">
<xul:panel anonid="panel" hidden="true" type="arrow" class="social-panel">
<xul:iframe type="content" flex="1" tooltip="aHTMLTooltip"
class="social-panel-frame" context="contentAreaContextMenu"
xbl:inherits="src,origin"/>
</xul:panel>
<xul:panel anonid="panel" hidden="true" type="arrow" class="social-panel"/>
<xul:image class="toolbarbutton-icon" xbl:inherits="validate,src=image,label"/>
<xul:label class="toolbarbutton-text" crop="right" flex="1"
xbl:inherits="value=label,accesskey,crop"/>
</content>
<implementation implements="nsIDOMEventListener, nsIObserver">
<field name="panel" readonly="true">
document.getAnonymousElementByAttribute(this, "anonid", "panel");
</field>
<field name="inMenuPanel">false</field>
<field name="content" readonly="true">
this.panel.firstChild;
</field>
<property name="panel">
<getter>
let widgetGroup = CustomizableUI.getWidget(this.getAttribute("id"));
let widget = widgetGroup.forWindow(window);
this.inMenuPanel = widgetGroup.areaType == CustomizableUI.TYPE_MENU_PANEL;
if (this.inMenuPanel) {
widget.node.setAttribute("noautoclose", "true");
return document.getElementById("PanelUI-socialapi");
}
return document.getAnonymousElementByAttribute(this, "anonid", "panel");
</getter>
</property>
<property name="content">
<getter><![CDATA[
if (this._frame)
return this._frame;
let notificationFrameId = "social-mark-frame-" + this.getAttribute("origin");
this._frame = SharedFrame.createFrame(
notificationFrameId, /* frame name */
this.panel, /* parent */
{
"type": "content",
"mozbrowser": "true",
"class": "social-panel-frame",
"id": notificationFrameId,
"tooltip": "aHTMLTooltip",
"flex": "1",
"context": "contentAreaContextMenu",
"origin": this.getAttribute("origin"),
"src": "about:blank"
}
);
this._frame.addEventListener("DOMLinkAdded", this);
this.setAttribute("notificationFrameId", notificationFrameId);
return this._frame;
]]></getter>
</property>
<property name="contentWindow">
<getter>
@ -46,16 +75,17 @@
</property>
<property name="isMarked">
<setter>
<setter><![CDATA[
this._isMarked = val;
let provider = this.provider;
// we cannot size the image when we apply it via listStyleImage, so
// use the toolbar image
if (val)
this.setAttribute("image", provider.unmarkedIcon || provider.iconURL);
else
this.setAttribute("image", provider.markedIcon || provider.iconURL);
</setter>
let place = CustomizableUI.getPlaceForItem(this);
val = val && place != "palette";
let icon = val ? provider.markedIcon : provider.unmarkedIcon;
let iconURL = icon || provider.icon32URL || provider.iconURL;
this.setAttribute("image", iconURL);
]]></setter>
<getter>
return this._isMarked;
</getter>
@ -69,12 +99,11 @@
this._dynamicResizer.stop();
this._dynamicResizer = null;
}
this.setAttribute("src", "about:blank");
this.content.setAttribute("src", "about:blank");
// do we have a savable page loaded?
let aURI = gBrowser.currentURI;
this.disabled = !aURI || !(aURI.schemeIs('http') || aURI.schemeIs('https'));
if (this.disabled) {
this.isMarked = false;
} else {
@ -82,11 +111,17 @@
this.isMarked = isMarked;
});
}
this.setAttribute("label", provider.name);
this.setAttribute("tooltiptext", provider.name);
this.setAttribute("origin", provider.origin);
this.panel.hidePopup();
this.panel.hidden = true;
this.content.setAttribute("origin", provider.origin);
if (!this.inMenuPanel) {
let panel = this.panel;
// if customization is currently happening, we may not have a panel
// that we can hide
if (panel.hidePopup) {
panel.hidePopup();
panel.hidden = true;
}
}
this.pageData = null;
]]></body>
</method>
@ -95,21 +130,32 @@
<parameter name="pageData"/>
<body><![CDATA[
let provider = this.provider;
this.panel.hidden = false;
let panel = this.panel;
panel.hidden = false;
// reparent the iframe if we've been customized to a new location
if (this.content.parentNode != panel)
panel.appendChild(this.content);
let URLTemplate = provider.markURL;
this.pageData = pageData || OpenGraphBuilder.getData(gBrowser);
let endpoint = OpenGraphBuilder.generateEndpointURL(URLTemplate, this.pageData);
// setup listeners
this.addEventListener("DOMContentLoaded", function DOMContentLoaded(event) {
let DOMContentLoaded = (event) => {
if (event.target != this.contentDocument)
return;
this._loading = false;
this.removeEventListener("DOMContentLoaded", DOMContentLoaded, true);
this.content.removeEventListener("DOMContentLoaded", DOMContentLoaded, true);
// add our resizer after the dom is ready
let DynamicResizeWatcher = Cu.import("resource:///modules/Social.jsm", {}).DynamicResizeWatcher;
this._dynamicResizer = new DynamicResizeWatcher();
this._dynamicResizer.start(this.panel, this.content);
if (!this.inMenuPanel) {
let DynamicResizeWatcher = Cu.import("resource:///modules/Social.jsm", {}).DynamicResizeWatcher;
this._dynamicResizer = new DynamicResizeWatcher();
this._dynamicResizer.start(this.panel, this.content);
} else if (this._dynamicResizer) {
this._dynamicResizer.stop();
this._dynamicResizer = null;
}
// send the opengraph data
let evt = this.contentDocument.createEvent("CustomEvent");
evt.initCustomEvent("OpenGraphData", true, true, JSON.stringify(this.pageData));
@ -134,24 +180,63 @@
contentWindow.removeEventListener("unload", unload);
contentWindow.removeEventListener("socialMarkUpdate", markUpdate);
});
}, true);
}
this.content.addEventListener("DOMContentLoaded", DOMContentLoaded, true);
this._loading = true;
this.setAttribute("src", endpoint);
this.content.setAttribute("src", endpoint);
]]></body>
</method>
<method name="openPanel">
<parameter name="aResetOnClose"/>
<body><![CDATA[
let panel = this.panel;
let frameId = this.getAttribute("notificationFrameId");
let wasAlive = SharedFrame.isGroupAlive(frameId);
SharedFrame.setOwner(frameId, this.content);
// Clear dimensions on all browsers so the panel size will
// only use the selected browser.
let frameIter = panel.firstElementChild;
while (frameIter) {
frameIter.collapsed = (frameIter != this.content);
frameIter = frameIter.nextElementSibling;
}
// if we're a slice in the hambuger, use that panel instead
let widgetGroup = CustomizableUI.getWidget(this.getAttribute("id"));
let widget = widgetGroup.forWindow(window);
let inMenuPanel = widgetGroup.areaType == CustomizableUI.TYPE_MENU_PANEL;
if (inMenuPanel) {
PanelUI.showSubView("PanelUI-socialapi", widget.node,
CustomizableUI.AREA_PANEL);
} else {
panel.openPopup(this, "bottomcenter topright", 0, 0, false, false);
}
if (aResetOnClose) {
let evName = inMenuPanel ? "ViewHiding": "popuphidden";
panel.addEventListener(evName, function _hidden() {
panel.removeEventListener(evName, _hidden);
this.update();
}.bind(this), false);
}
]]></body>
</method>
<method name="markCurrentPage">
<parameter name="aOpenPanel"/>
<body><![CDATA[
// we always set the src on click if it has not been set for this tab,
// but we only want to open the panel if it was previously annotated.
let openPanel = this.isMarked || aOpenPanel || !this.provider.haveLoggedInUser();
let src = this.getAttribute("src");
let openPanel = this.isMarked || aOpenPanel ||
this.inMenuPanel || !this.provider.haveLoggedInUser();
let src = this.content.getAttribute("src");
if (!src || src == "about:blank") {
this.loadPanel();
}
if (openPanel)
this.panel.openPopup(this, "bottomcenter topright", 0, 0, false, false);
this.openPanel();
]]></body>
</method>
@ -167,13 +252,9 @@
// and show it since the url may not be the browser tab, but an image,
// link, etc. inside the page. We also "update" the iframe to the
// previous url when it is closed.
this.setAttribute("src", "about:blank");
this.content.setAttribute("src", "about:blank");
this.loadPanel({ url: aUrl });
this.panel.openPopup(this, "bottomcenter topright", 0, 0, false, false);
this.panel.addEventListener("popuphidden", function _hidden() {
this.panel.removeEventListener("popuphidden", _hidden);
this.update();
}.bind(this), false);
this.openPanel(true);
]]></body>
</method>
@ -186,23 +267,67 @@
]]></body>
</method>
</implementation>
<handlers>
<handler event="popupshown"><![CDATA[
<method name="onShown">
<body><![CDATA[
// because the panel may be preloaded, we need to size the panel when
// showing as well as after load
let sizeSocialPanelToContent = Cu.import("resource:///modules/Social.jsm", {}).sizeSocialPanelToContent;
if (!this._loading && this.contentDocument.readyState == "complete") {
if (!this._loading && this.contentDocument &&
this.contentDocument.readyState == "complete") {
this.dispatchPanelEvent("socialFrameShow");
sizeSocialPanelToContent(this.panel, this.content);
if (!this.inMenuPanel)
sizeSocialPanelToContent(this.panel, this.content);
} else {
let panelBrowserOnload = () => {
this.content.addEventListener("load", function panelBrowserOnload(e) {
this.content.removeEventListener("load", panelBrowserOnload, true);
this.dispatchPanelEvent("socialFrameShow");
sizeSocialPanelToContent(this.panel, this.content);
};
this.content.addEventListener("load", panelBrowserOnload, true);
if (!this.inMenuPanel)
sizeSocialPanelToContent(this.panel, this.content);
}.bind(this), true);
}
]]></body>
</method>
<method name="handleEvent">
<parameter name="aEvent"/>
<body><![CDATA[
if (aEvent.eventPhase != aEvent.BUBBLING_PHASE)
return;
switch(aEvent.type) {
case "DOMLinkAdded": {
// much of this logic is from DOMLinkHandler in browser.js, this sets
// the presence icon for a chat user, we simply use favicon style
// updating
let link = aEvent.originalTarget;
let rel = link.rel && link.rel.toLowerCase();
if (!link || !link.ownerDocument || !rel || !link.href)
return;
if (link.rel.indexOf("icon") < 0)
return;
let uri = DOMLinkHandler.getLinkIconURI(link);
if (!uri)
return;
// we cannot size the image when we apply it via listStyleImage, so
// use the toolbar image
this.setAttribute("image", uri.spec);
}
break;
case "ViewShowing":
this.onShown();
break;
case "ViewHiding":
this.dispatchPanelEvent("socialFrameHide");
break;
}
]]></body>
</method>
</implementation>
<handlers>
<handler event="popupshown"><![CDATA[
this.onShown();
]]></handler>
<handler event="popuphidden"><![CDATA[
this.dispatchPanelEvent("socialFrameHide");
@ -210,25 +335,6 @@
<handler event="command"><![CDATA[
this.markCurrentPage();
]]></handler>
<handler event="DOMLinkAdded"><![CDATA[
// much of this logic is from DOMLinkHandler in browser.js, this sets
// the presence icon for a chat user, we simply use favicon style
// updating
let link = event.originalTarget;
let rel = link.rel && link.rel.toLowerCase();
if (!link || !link.ownerDocument || !rel || !link.href)
return;
if (link.rel.indexOf("icon") < 0)
return;
let uri = DOMLinkHandler.getLinkIconURI(link);
if (!uri)
return;
// we cannot size the image when we apply it via listStyleImage, so
// use the toolbar image
this.setAttribute("image", uri.spec);
]]></handler>
</handlers>
</binding>

Просмотреть файл

@ -35,12 +35,10 @@ support-files =
[browser_social_flyout.js]
[browser_social_isVisible.js]
[browser_social_marks.js]
[browser_social_mozSocial_API.js]
[browser_social_multiprovider.js]
[browser_social_multiworker.js]
[browser_social_perwindowPB.js]
[browser_social_sidebar.js]
[browser_social_status.js]
[browser_social_toolbar.js]
[browser_social_window.js]
[browser_social_workercrash.js]

Просмотреть файл

@ -209,6 +209,12 @@ var tests = {
testBuiltinInstallWithoutManifest: function(next) {
// send installProvider null for the manifest
AddonManager.addAddonListener(installListener(next, manifest));
let panel = document.getElementById("servicesInstall-notification");
PopupNotifications.panel.addEventListener("popupshown", function onpopupshown() {
PopupNotifications.panel.removeEventListener("popupshown", onpopupshown);
info("servicesInstall-notification panel opened");
panel.button.click();
});
let prefname = getManifestPrefname(manifest);
let activationURL = manifest.origin + "/browser/browser/base/content/test/social/social_activate.html"
@ -229,6 +235,12 @@ var tests = {
testBuiltinInstall: function(next) {
// send installProvider a json object for the manifest
AddonManager.addAddonListener(installListener(next, manifest));
let panel = document.getElementById("servicesInstall-notification");
PopupNotifications.panel.addEventListener("popupshown", function onpopupshown() {
PopupNotifications.panel.removeEventListener("popupshown", onpopupshown);
info("servicesInstall-notification panel opened");
panel.button.click();
});
let prefname = getManifestPrefname(manifest);
let activationURL = manifest.origin + "/browser/browser/base/content/test/social/social_activate.html"
@ -248,6 +260,12 @@ var tests = {
},
testWhitelistInstall: function(next) {
AddonManager.addAddonListener(installListener(next, manifest2));
let panel = document.getElementById("servicesInstall-notification");
PopupNotifications.panel.addEventListener("popupshown", function onpopupshown() {
PopupNotifications.panel.removeEventListener("popupshown", onpopupshown);
info("servicesInstall-notification panel opened");
panel.button.click();
});
let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
addTab(activationURL, function(tab) {
@ -266,6 +284,12 @@ var tests = {
},
testDirectoryInstall: function(next) {
AddonManager.addAddonListener(installListener(next, manifest2));
let panel = document.getElementById("servicesInstall-notification");
PopupNotifications.panel.addEventListener("popupshown", function onpopupshown() {
PopupNotifications.panel.removeEventListener("popupshown", onpopupshown);
info("servicesInstall-notification panel opened");
panel.button.click();
});
let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
addTab(activationURL, function(tab) {
@ -286,6 +310,13 @@ var tests = {
// add the provider, change the pref, add it again. The provider at that
// point should be upgraded
let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
let panel = document.getElementById("servicesInstall-notification");
PopupNotifications.panel.addEventListener("popupshown", function onpopupshown() {
PopupNotifications.panel.removeEventListener("popupshown", onpopupshown);
info("servicesInstall-notification panel opened");
panel.button.click();
});
addTab(activationURL, function(tab) {
let doc = tab.linkedBrowser.contentDocument;
let installFrom = doc.nodePrincipal.origin;

Просмотреть файл

@ -14,7 +14,7 @@ function postTestCleanup(callback) {
tabsToRemove = [];
// theses tests use the notification panel but don't bother waiting for it
// to fully open - the end result is that the panel might stay open
SocialUI.activationPanel.hidePopup();
//SocialUI.activationPanel.hidePopup();
Services.prefs.clearUserPref("social.whitelist");
@ -141,19 +141,27 @@ function clickAddonRemoveButton(tab, aCallback) {
}
function activateOneProvider(manifest, finishActivation, aCallback) {
let panel = document.getElementById("servicesInstall-notification");
PopupNotifications.panel.addEventListener("popupshown", function onpopupshown() {
PopupNotifications.panel.removeEventListener("popupshown", onpopupshown);
info("servicesInstall-notification panel opened");
if (finishActivation)
panel.button.click();
else
panel.closebutton.click();
});
activateProvider(manifest.origin, function() {
waitForProviderLoad(function() {
ok(!SocialUI.activationPanel.hidden, "activation panel is showing");
is(Social.provider.origin, manifest.origin, "new provider is active");
checkSocialUI();
if (finishActivation)
document.getElementById("social-activation-button").click();
else
document.getElementById("social-undoactivation-button").click();
if (!finishActivation) {
ok(panel.hidden, "activation panel is not showing");
executeSoon(aCallback);
});
} else {
waitForProviderLoad(function() {
is(Social.provider.origin, manifest.origin, "new provider is active");
checkSocialUI();
executeSoon(aCallback);
});
}
});
}
@ -194,7 +202,8 @@ var tests = {
Services.prefs.setBoolPref("social.remote-install.enabled", false);
activateProvider(gTestDomains[0], function() {
is(SocialUI.enabled, false, "SocialUI is not enabled");
ok(SocialUI.activationPanel.hidden, "activation panel still hidden");
let panel = document.getElementById("servicesInstall-notification");
ok(panel.hidden, "activation panel still hidden");
checkSocialUI();
Services.prefs.clearUserPref("social.remote-install.enabled");
next();
@ -206,7 +215,8 @@ var tests = {
activateIFrameProvider(gTestDomains[0], function() {
is(SocialUI.enabled, false, "SocialUI is not enabled");
ok(!Social.provider, "provider is not installed");
ok(SocialUI.activationPanel.hidden, "activation panel still hidden");
let panel = document.getElementById("servicesInstall-notification");
ok(panel.hidden, "activation panel still hidden");
checkSocialUI();
Services.prefs.clearUserPref("social.whitelist");
next();
@ -263,38 +273,6 @@ var tests = {
});
},
testRemoveNonCurrentProvider: function(next) {
Services.prefs.setCharPref("social.whitelist", gTestDomains.join(","));
SocialService.addProvider(gProviders[0], function() {
SocialService.addProvider(gProviders[1], function() {
Social.provider = Social.providers[1];
checkSocialUI();
// activate the last provider.
let prefname = addBuiltinManifest(gProviders[2]);
activateProvider(gTestDomains[2], function() {
waitForProviderLoad(function() {
ok(!SocialUI.activationPanel.hidden, "activation panel is showing");
is(Social.provider.origin, gTestDomains[2], "new provider is active");
checkSocialUI();
// A bit contrived, but set a new provider current while the
// activation ui is up.
Social.provider = Social.providers[1];
// hit "undo"
document.getElementById("social-undoactivation-button").click();
executeSoon(function() {
// we deactivated - the same provider should be enabled.
is(Social.provider.origin, Social.providers[1].origin, "original provider still be active");
checkSocialUI();
Services.prefs.clearUserPref("social.whitelist");
resetBuiltinManifestPref(prefname);
next();
});
});
});
});
});
},
testAddonManagerDoubleInstall: function(next) {
Services.prefs.setCharPref("social.whitelist", gTestDomains.join(","));
// Create a new tab and load about:addons

Просмотреть файл

@ -1,87 +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/. */
function test() {
waitForExplicitFinish();
let manifest = { // normal provider
name: "provider 1",
origin: "https://example.com",
sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html",
workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js",
iconURL: "https://example.com/browser/browser/base/content/test/general/moz.png"
};
runSocialTestWithProvider(manifest, function (finishcb) {
runSocialTests(tests, undefined, undefined, finishcb);
});
}
var tests = {
testStatusIcons: function(next) {
let icon = {
name: "testIcon",
iconURL: "chrome://browser/skin/Info.png",
contentPanel: "https://example.com/browser/browser/base/content/test/social/social_panel.html",
counter: 1
};
let iconsReady = false;
let gotSidebarMessage = false;
function checkNext() {
if (iconsReady && gotSidebarMessage)
triggerIconPanel();
}
function triggerIconPanel() {
let pButton = document.getElementById("social-provider-button");
waitForCondition(function() {
// wait for a new button to be inserted inbetween the provider and mark
// button
return !!pButton.nextSibling;
}, function() {
// Click the button to trigger its contentPanel
let statusIcon = pButton.nextSibling;
EventUtils.synthesizeMouseAtCenter(statusIcon, {});
}, "Status icon didn't become non-hidden");
}
let port = Social.provider.getWorkerPort();
ok(port, "provider has a port");
port.onmessage = function (e) {
let topic = e.data.topic;
switch (topic) {
case "test-init-done":
iconsReady = true;
checkNext();
break;
case "got-panel-message":
ok(true, "got panel message");
// Check the panel isn't in our history.
gURLsNotRemembered.push(e.data.location);
break;
case "got-social-panel-visibility":
if (e.data.result == "shown") {
ok(true, "panel shown");
let panel = document.getElementById("social-notification-panel");
panel.hidePopup();
} else if (e.data.result == "hidden") {
ok(true, "panel hidden");
port.close();
next();
}
break;
case "got-sidebar-message":
// The sidebar message will always come first, since it loads by default
ok(true, "got sidebar message");
gotSidebarMessage = true;
// load a status panel
port.postMessage({topic: "test-ambient-notification", data: icon});
checkNext();
break;
}
}
port.postMessage({topic: "test-init"});
}
}

Просмотреть файл

@ -29,8 +29,8 @@ let gProviders = [
var tests = {
testProviderSwitch: function(next) {
let menu = document.getElementById("social-statusarea-popup");
function checkProviderMenu(selectedProvider) {
let menu = document.getElementById("social-statusarea-popup");
let menuProviders = menu.querySelectorAll(".social-provider-menuitem");
is(menuProviders.length, gProviders.length, "correct number of providers listed in the menu");
// Find the selectedProvider's menu item
@ -39,59 +39,44 @@ var tests = {
is(el[0].getAttribute("checked"), "true", "selected provider menu item is checked");
}
checkProviderMenu(gProviders[0]);
// the menu is not populated until onpopupshowing, so wait for popupshown
function theTest() {
checkProviderMenu(gProviders[0]);
// Now wait for the initial provider profile to be set
waitForProviderLoad(function() {
checkUIStateMatchesProvider(gProviders[0]);
// Now wait for the initial provider profile to be set
waitForProviderLoad(function() {
menu.removeEventListener("popupshown", theTest, true);
checkUIStateMatchesProvider(gProviders[0]);
// Now activate "provider 2"
observeProviderSet(function () {
waitForProviderLoad(function() {
checkUIStateMatchesProvider(gProviders[1]);
// disable social, click on the provider menuitem to switch providers
Social.enabled = false;
let menu = document.getElementById("social-statusarea-popup");
let el = menu.getElementsByAttribute("origin", gProviders[0].origin);
is(el.length, 1, "selected provider menu item exists");
el[0].click();
// Now activate "provider 2"
observeProviderSet(function () {
waitForProviderLoad(function() {
checkUIStateMatchesProvider(gProviders[0]);
next();
checkUIStateMatchesProvider(gProviders[1]);
// disable social, click on the provider menuitem to switch providers
Social.enabled = false;
let el = menu.getElementsByAttribute("origin", gProviders[0].origin);
is(el.length, 1, "selected provider menu item exists");
el[0].click();
waitForProviderLoad(function() {
checkUIStateMatchesProvider(gProviders[0]);
next();
});
});
});
Social.activateFromOrigin("https://test1.example.com");
});
Social.activateFromOrigin("https://test1.example.com");
});
};
menu.addEventListener("popupshown", theTest, true);
let button = document.getElementById("social-sidebar-button");
EventUtils.synthesizeMouseAtCenter(button, {});
}
}
function checkUIStateMatchesProvider(provider) {
let profileData = getExpectedProfileData(provider);
// The toolbar
let loginStatus = document.getElementsByClassName("social-statusarea-loggedInStatus");
for (let label of loginStatus) {
is(label.value, profileData.userName, "username name matches provider profile");
}
// Sidebar
is(document.getElementById("social-sidebar-browser").getAttribute("src"), provider.sidebarURL, "side bar URL is set");
}
function getExpectedProfileData(provider) {
// This data is defined in social_worker.js
if (provider.origin == "https://test1.example.com") {
return {
displayName: "Test1 User",
userName: "tester"
};
}
return {
displayName: "Kuma Lisa",
userName: "trickster"
};
}
function observeProviderSet(cb) {
Services.obs.addObserver(function providerSet(subject, topic, data) {
Services.obs.removeObserver(providerSet, "social:provider-set");

Просмотреть файл

@ -21,7 +21,7 @@ function doTest(finishcb) {
let command = document.getElementById("Social:ToggleSidebar");
let sidebar = document.getElementById("social-sidebar-box");
let browser = sidebar.firstChild;
let browser = sidebar.lastChild;
function checkShown(shouldBeShown) {
is(command.getAttribute("checked"), shouldBeShown ? "true" : "false",

Просмотреть файл

@ -41,7 +41,7 @@ function test() {
waitForExplicitFinish();
Services.prefs.setBoolPref("social.allowMultipleWorkers", true);
runSocialTestWithProvider(manifest, function () {
runSocialTestWithProvider(manifest, function (finishcb) {
runSocialTests(tests, undefined, undefined, function () {
Services.prefs.clearUserPref("social.remote-install.enabled");
// just in case the tests failed, clear these here as well
@ -49,7 +49,7 @@ function test() {
Services.prefs.clearUserPref("social.whitelist");
ok(CustomizableUI.inDefaultState, "Should be in the default state when we finish");
CustomizableUI.reset();
finish();
finishcb();
});
});
}
@ -140,7 +140,7 @@ var tests = {
port.close();
waitForCondition(function() { return btn.getAttribute("badge"); },
function() {
is(btn.getAttribute("image"), icon.iconURL, "notification icon updated");
is(btn.style.listStyleImage, "url(\"" + icon.iconURL + "\")", "notification icon updated");
next();
}, "button updated by notification");
}

Просмотреть файл

@ -1,198 +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/. */
let manifests = [{
name: "provider 1",
origin: "https://example.com",
sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar_empty.html",
iconURL: "https://example.com/browser/browser/base/content/test/general/moz.png"
}, { // used for testing install
name: "provider test1",
origin: "https://test1.example.com",
statusURL: "https://test1.example.com/browser/browser/base/content/test/social/social_panel.html",
iconURL: "https://test1.example.com/browser/browser/base/content/test/general/moz.png",
}];
function test() {
waitForExplicitFinish();
// required to test status button in combination with the toolbaritem
Services.prefs.setBoolPref("social.allowMultipleWorkers", true);
runSocialTestWithProvider(manifests, function (finishcb) {
runSocialTests(tests, undefined, undefined, function() {
Services.prefs.clearUserPref("social.allowMultipleWorkers");
finishcb();
});
});
}
var tests = {
testProfileNone: function(next, useNull) {
let profile = useNull ? null : {};
Social.provider.updateUserProfile(profile);
// check dom values
let portrait = document.getElementsByClassName("social-statusarea-user-portrait")[0].getAttribute("src");
// this is the default image for the profile area when not logged in.
ok(!portrait, "portrait is empty");
let userDetailsBroadcaster = document.getElementById("socialBroadcaster_userDetails");
let notLoggedInStatusValue = userDetailsBroadcaster.getAttribute("notLoggedInLabel");
let userButton = document.getElementsByClassName("social-statusarea-loggedInStatus")[0];
ok(!userButton.hidden, "username is visible");
is(userButton.getAttribute("label"), notLoggedInStatusValue, "label reflects not being logged in");
next();
},
testProfileNull: function(next) {
this.testProfileNone(next, true);
},
testProfileSet: function(next) {
let statusIcon = document.getElementById("social-provider-button").style.listStyleImage;
is(statusIcon, "url(\"" + manifests[0].iconURL + "\")", "manifest iconURL is showing");
let profile = {
portrait: "https://example.com/portrait.jpg",
userName: "trickster",
displayName: "Kuma Lisa",
profileURL: "http://example.com/Kuma_Lisa",
iconURL: "https://example.com/browser/browser/base/content/test/general/moz.png"
}
Social.provider.updateUserProfile(profile);
// check dom values
statusIcon = document.getElementById("social-provider-button").style.listStyleImage;
is(statusIcon, "url(\"" + profile.iconURL + "\")", "profile iconURL is showing");
let portrait = document.getElementsByClassName("social-statusarea-user-portrait")[0].getAttribute("src");
is(profile.portrait, portrait, "portrait is set");
let userButton = document.getElementsByClassName("social-statusarea-loggedInStatus")[0];
ok(!userButton.hidden, "username is visible");
is(userButton.value, profile.userName, "username is set");
next();
},
testNoAmbientNotificationsIsNoKeyboardMenu: function(next) {
// The menu bar isn't as easy to instrument on Mac.
if (navigator.platform.contains("Mac")) {
info("Skipping checking the menubar on Mac OS");
next();
return;
}
// Test that keyboard accessible menuitem doesn't exist when no ambient icons specified.
let toolsPopup = document.getElementById("menu_ToolsPopup");
toolsPopup.addEventListener("popupshown", function ontoolspopupshownNoAmbient() {
toolsPopup.removeEventListener("popupshown", ontoolspopupshownNoAmbient);
let socialToggleMore = document.getElementById("menu_socialAmbientMenu");
ok(socialToggleMore, "Keyboard accessible social menu should exist");
is(socialToggleMore.querySelectorAll("menuitem").length, 6, "The minimum number of menuitems is two when there are no ambient notifications.");
is(socialToggleMore.hidden, false, "Menu should be visible since we show some non-ambient notifications in the menu.");
toolsPopup.hidePopup();
next();
}, false);
document.getElementById("menu_ToolsPopup").openPopup();
},
testAmbientNotifications: function(next) {
let ambience = {
name: "testIcon",
iconURL: "https://example.com/browser/browser/base/content/test/general/moz.png",
contentPanel: "about:blank",
counter: 42,
label: "Test Ambient 1 \u2046",
menuURL: "https://example.com/testAmbient1"
};
let ambience2 = {
name: "testIcon2",
iconURL: "https://example.com/browser/browser/base/content/test/general/moz.png",
contentPanel: "about:blank",
counter: 0,
label: "Test Ambient 2",
menuURL: "https://example.com/testAmbient2"
};
let ambience3 = {
name: "testIcon3",
iconURL: "https://example.com/browser/browser/base/content/test/general/moz.png",
contentPanel: "about:blank",
counter: 0,
label: "Test Ambient 3",
menuURL: "https://example.com/testAmbient3"
};
let ambience4 = {
name: "testIcon4",
iconURL: "https://example.com/browser/browser/base/content/test/general/moz.png",
contentPanel: "about:blank",
counter: 0,
label: "Test Ambient 4",
menuURL: "https://example.com/testAmbient4"
};
Social.provider.setAmbientNotification(ambience);
// for Bug 813834. Check preference whether stored data is correct.
is(JSON.parse(Services.prefs.getComplexValue("social.cached.ambientNotificationIcons", Ci.nsISupportsString).data).data.testIcon.label, "Test Ambient 1 \u2046", "label is stored into preference correctly");
Social.provider.setAmbientNotification(ambience2);
Social.provider.setAmbientNotification(ambience3);
try {
Social.provider.setAmbientNotification(ambience4);
} catch(e) {}
let numIcons = Object.keys(Social.provider.ambientNotificationIcons).length;
ok(numIcons == 3, "prevent adding more than 3 ambient notification icons");
let pButton = document.getElementById("social-provider-button");
waitForCondition(function() {
// wait for a new button to be inserted inbetween the provider and mark
// button
return !!pButton.nextSibling;
}, function () {
let statusIcon = pButton.nextSibling;
let badge = statusIcon.getAttribute("badge");
is(badge, "42", "status value is correct");
// If there is a counter, the aria-label should reflect it.
is(statusIcon.getAttribute("aria-label"), "Test Ambient 1 \u2046 (42)");
ambience.counter = 0;
Social.provider.setAmbientNotification(ambience);
statusIcon = pButton.nextSibling;
badge = statusIcon.getAttribute("badge");
is(badge, "", "status value is correct");
// If there is no counter, the aria-label should be the same as the label
is(statusIcon.getAttribute("aria-label"), "Test Ambient 1 \u2046");
// The menu bar isn't as easy to instrument on Mac.
if (navigator.platform.contains("Mac")) {
next();
return;
}
// Test that keyboard accessible menuitem was added.
let toolsPopup = document.getElementById("menu_ToolsPopup");
toolsPopup.addEventListener("popupshown", function ontoolspopupshownAmbient() {
toolsPopup.removeEventListener("popupshown", ontoolspopupshownAmbient);
let socialToggleMore = document.getElementById("menu_socialAmbientMenu");
ok(socialToggleMore, "Keyboard accessible social menu should exist");
is(socialToggleMore.querySelectorAll("menuitem").length, 9, "The number of menuitems is minimum plus three ambient notification menuitems.");
is(socialToggleMore.hidden, false, "Menu is visible when ambient notifications have label & menuURL");
let menuitem = socialToggleMore.querySelector(".ambient-menuitem");
is(menuitem.getAttribute("label"), "Test Ambient 1 \u2046", "Keyboard accessible ambient menuitem should have specified label");
toolsPopup.hidePopup();
next();
}, false);
document.getElementById("menu_ToolsPopup").openPopup();
}, "statusIcon was never found");
},
testMenuitemsExist: function(next) {
let toggleSidebarMenuitems = document.getElementsByClassName("social-toggle-sidebar-menuitem");
is(toggleSidebarMenuitems.length, 2, "Toggle Sidebar menuitems exist");
let toggleDesktopNotificationsMenuitems = document.getElementsByClassName("social-toggle-notifications-menuitem");
is(toggleDesktopNotificationsMenuitems.length, 2, "Toggle notifications menuitems exist");
let toggleSocialMenuitems = document.getElementsByClassName("social-toggle-menuitem");
is(toggleSocialMenuitems.length, 2, "Toggle Social menuitems exist");
next();
},
testToggleNotifications: function(next) {
let enabled = Services.prefs.getBoolPref("social.toast-notifications.enabled");
let cmd = document.getElementById("Social:ToggleNotifications");
is(cmd.getAttribute("checked"), enabled ? "true" : "false");
enabled = !enabled;
Services.prefs.setBoolPref("social.toast-notifications.enabled", enabled);
is(cmd.getAttribute("checked"), enabled ? "true" : "false");
Services.prefs.clearUserPref("social.toast-notifications.enabled");
next();
}
}

Просмотреть файл

@ -242,19 +242,8 @@ function checkSocialUI(win) {
isbool(win.SocialChatBar.isAvailable, enabled, "chatbar available?");
isbool(!win.SocialChatBar.chatbar.hidden, enabled, "chatbar visible?");
isbool(!doc.getElementById("social-toolbar-item").hidden, active, "toolbar items visible?");
if (active) {
if (!enabled || (Social.defaultProvider.statusURL && Social.allowMultipleWorkers)) {
_ok(!win.SocialToolbar.button.style.listStyleImage, "toolbar button is default icon");
} else {
_is(win.SocialToolbar.button.style.listStyleImage, 'url("' + Social.defaultProvider.iconURL + '")', "toolbar button has provider icon");
}
}
// the menus should always have the provider name
if (provider) {
for (let id of ["menu_socialSidebar", "menu_socialAmbientMenu"])
_is(document.getElementById(id).getAttribute("label"), Social.provider.name, "element has the provider name");
let contextMenus = [
{
type: "link",
@ -299,8 +288,6 @@ function checkSocialUI(win) {
isbool(!doc.getElementById("Social:FocusChat").hidden, enabled, "Social:FocusChat visible?");
isbool(doc.getElementById("Social:FocusChat").getAttribute("disabled"), enabled ? "false" : "true", "Social:FocusChat disabled?");
// broadcasters.
isbool(!doc.getElementById("socialActiveBroadcaster").hidden, active, "socialActiveBroadcaster hidden?");
// and report on overall success of failure of the various checks here.
is(numGoodTests, numTests, "The Social UI tests succeeded.")
}

Просмотреть файл

@ -95,6 +95,8 @@
</panelview>
<panelview id="PanelUI-socialapi" flex="1"/>
<panelview id="PanelUI-feeds" flex="1" oncommand="FeedHandler.subscribeToFeed(null, event);"></panelview>
<panelview id="PanelUI-helpView" flex="1">

Просмотреть файл

@ -184,7 +184,6 @@ let CustomizableUIInternal = {
"downloads-button",
"home-button",
"social-share-button",
"social-toolbar-item",
]
});
#ifndef XP_MACOSX

Просмотреть файл

@ -2,90 +2,78 @@
* 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 kToolbarName = "test-specials-toolbar";
let gTests = [
{
desc: "Add a toolbar with two springs and the downloads button.",
run: function() {
// Create the toolbar with a single spring:
createToolbarWithPlacements(kToolbarName, ["spring"]);
ok(document.getElementById(kToolbarName), "Toolbar should be created.");
registerCleanupFunction(removeCustomToolbars);
// Check it's there with a generated ID:
assertAreaPlacements(kToolbarName, [/customizableui-special-spring\d+/]);
let [springId] = getAreaWidgetIds(kToolbarName);
// Add a toolbar with two springs and the downloads button.
add_task(function addToolbarWith2SpringsAndDownloadsButton() {
// Create the toolbar with a single spring:
createToolbarWithPlacements(kToolbarName, ["spring"]);
ok(document.getElementById(kToolbarName), "Toolbar should be created.");
// Add a second spring, check if that's there and doesn't share IDs
CustomizableUI.addWidgetToArea("spring", kToolbarName);
assertAreaPlacements(kToolbarName, [springId,
/customizableui-special-spring\d+/]);
let [, spring2Id] = getAreaWidgetIds(kToolbarName);
// Check it's there with a generated ID:
assertAreaPlacements(kToolbarName, [/customizableui-special-spring\d+/]);
let [springId] = getAreaWidgetIds(kToolbarName);
isnot(springId, spring2Id, "Springs shouldn't have identical IDs.");
// Add a second spring, check if that's there and doesn't share IDs
CustomizableUI.addWidgetToArea("spring", kToolbarName);
assertAreaPlacements(kToolbarName, [springId,
/customizableui-special-spring\d+/]);
let [, spring2Id] = getAreaWidgetIds(kToolbarName);
// Try moving the downloads button to this new toolbar, between the two springs:
CustomizableUI.addWidgetToArea("downloads-button", kToolbarName, 1);
assertAreaPlacements(kToolbarName, [springId, "downloads-button", spring2Id]);
},
teardown: removeCustomToolbars
},
{
desc: "Add separators around the downloads button.",
run: function() {
createToolbarWithPlacements(kToolbarName, ["separator"]);
ok(document.getElementById(kToolbarName), "Toolbar should be created.");
isnot(springId, spring2Id, "Springs shouldn't have identical IDs.");
// Check it's there with a generated ID:
assertAreaPlacements(kToolbarName, [/customizableui-special-separator\d+/]);
let [separatorId] = getAreaWidgetIds(kToolbarName);
// Try moving the downloads button to this new toolbar, between the two springs:
CustomizableUI.addWidgetToArea("downloads-button", kToolbarName, 1);
assertAreaPlacements(kToolbarName, [springId, "downloads-button", spring2Id]);
yield removeCustomToolbars();
});
CustomizableUI.addWidgetToArea("separator", kToolbarName);
assertAreaPlacements(kToolbarName, [separatorId,
/customizableui-special-separator\d+/]);
let [, separator2Id] = getAreaWidgetIds(kToolbarName);
// Add separators around the downloads button.
add_task(function addSeparatorsAroundDownloadsButton() {
createToolbarWithPlacements(kToolbarName, ["separator"]);
ok(document.getElementById(kToolbarName), "Toolbar should be created.");
isnot(separatorId, separator2Id, "Separator ids shouldn't be equal.");
// Check it's there with a generated ID:
assertAreaPlacements(kToolbarName, [/customizableui-special-separator\d+/]);
let [separatorId] = getAreaWidgetIds(kToolbarName);
CustomizableUI.addWidgetToArea("downloads-button", kToolbarName, 1);
assertAreaPlacements(kToolbarName, [separatorId, "downloads-button", separator2Id]);
},
teardown: removeCustomToolbars
},
{
desc: "Add spacers around the downloads button.",
run: function() {
createToolbarWithPlacements(kToolbarName, ["spacer"]);
ok(document.getElementById(kToolbarName), "Toolbar should be created.");
CustomizableUI.addWidgetToArea("separator", kToolbarName);
assertAreaPlacements(kToolbarName, [separatorId,
/customizableui-special-separator\d+/]);
let [, separator2Id] = getAreaWidgetIds(kToolbarName);
// Check it's there with a generated ID:
assertAreaPlacements(kToolbarName, [/customizableui-special-spacer\d+/]);
let [spacerId] = getAreaWidgetIds(kToolbarName);
isnot(separatorId, separator2Id, "Separator ids shouldn't be equal.");
CustomizableUI.addWidgetToArea("spacer", kToolbarName);
assertAreaPlacements(kToolbarName, [spacerId,
/customizableui-special-spacer\d+/]);
let [, spacer2Id] = getAreaWidgetIds(kToolbarName);
CustomizableUI.addWidgetToArea("downloads-button", kToolbarName, 1);
assertAreaPlacements(kToolbarName, [separatorId, "downloads-button", separator2Id]);
yield removeCustomToolbars();
});
isnot(spacerId, spacer2Id, "Spacer ids shouldn't be equal.");
// Add spacers around the downloads button.
add_task(function addSpacersAroundDownloadsButton() {
createToolbarWithPlacements(kToolbarName, ["spacer"]);
ok(document.getElementById(kToolbarName), "Toolbar should be created.");
CustomizableUI.addWidgetToArea("downloads-button", kToolbarName, 1);
assertAreaPlacements(kToolbarName, [spacerId, "downloads-button", spacer2Id]);
},
teardown: removeCustomToolbars
}
];
// Check it's there with a generated ID:
assertAreaPlacements(kToolbarName, [/customizableui-special-spacer\d+/]);
let [spacerId] = getAreaWidgetIds(kToolbarName);
function asyncCleanup() {
CustomizableUI.addWidgetToArea("spacer", kToolbarName);
assertAreaPlacements(kToolbarName, [spacerId,
/customizableui-special-spacer\d+/]);
let [, spacer2Id] = getAreaWidgetIds(kToolbarName);
isnot(spacerId, spacer2Id, "Spacer ids shouldn't be equal.");
CustomizableUI.addWidgetToArea("downloads-button", kToolbarName, 1);
assertAreaPlacements(kToolbarName, [spacerId, "downloads-button", spacer2Id]);
yield removeCustomToolbars();
});
add_task(function asyncCleanup() {
yield resetCustomization();
}
function cleanup() {
removeCustomToolbars();
}
function test() {
waitForExplicitFinish();
registerCleanupFunction(cleanup);
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,6 +2,8 @@
* 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 kXULWidgetId = "sync-button";
const kAPIWidgetId = "feed-button";
const kPanel = CustomizableUI.AREA_PANEL;
@ -40,7 +42,7 @@ let move = {
}
return CustomizableUI.addWidgetToArea(id, target, null);
}
}
};
function isLast(containerId, defaultPlacements, id) {
assertAreaPlacements(containerId, defaultPlacements.concat([id]));
@ -108,47 +110,35 @@ function checkPalette(id, method) {
}
let otherWin;
let gTests = [
{
desc: "Moving widgets in two windows, one with customize mode and one without, should work",
setup: startCustomizing,
run: function() {
otherWin = yield openAndLoadWindow(null, true);
yield otherWin.PanelUI.ensureReady();
ok(CustomizableUI.inDefaultState, "Should start in default state");
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
for (let widgetId of [kXULWidgetId, kAPIWidgetId]) {
for (let method of ["API", "drag", "dragToItem"]) {
info("Moving widget " + widgetId + " using " + method);
checkToolbar(widgetId, method);
checkPanel(widgetId, method);
checkPalette(widgetId, method);
checkPanel(widgetId, method);
checkToolbar(widgetId, method);
checkPalette(widgetId, method);
}
}
// Moving widgets in two windows, one with customize mode and one without, should work.
add_task(function MoveWidgetsInTwoWindows() {
yield startCustomizing();
otherWin = yield openAndLoadWindow(null, true);
yield otherWin.PanelUI.ensureReady();
ok(CustomizableUI.inDefaultState, "Should start in default state");
otherWin.close();
otherWin = null;
},
teardown: function() {
if (otherWin) {
otherWin.close();
}
yield endCustomizing();
for (let widgetId of [kXULWidgetId, kAPIWidgetId]) {
for (let method of ["API", "drag", "dragToItem"]) {
info("Moving widget " + widgetId + " using " + method);
checkToolbar(widgetId, method);
checkPanel(widgetId, method);
checkPalette(widgetId, method);
checkPanel(widgetId, method);
checkToolbar(widgetId, method);
checkPalette(widgetId, method);
}
}
];
otherWin.close();
otherWin = null;
if (otherWin) {
otherWin.close();
}
yield endCustomizing();
});
function asyncCleanup() {
add_task(function asyncCleanup() {
Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck");
yield resetCustomization();
}
function test() {
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,52 +2,49 @@
* 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 kTestWidget1 = "test-customize-mode-create-destroy1";
const kTestWidget2 = "test-customize-mode-create-destroy2";
let gTests = [
{
desc: "Creating and destroying a widget should correctly wrap/unwrap stuff",
setup: startCustomizing,
run: function() {
CustomizableUI.createWidget({id: kTestWidget1, label: 'Pretty label', tooltiptext: 'Pretty tooltip'});
let elem = document.getElementById(kTestWidget1);
let wrapper = document.getElementById("wrapper-" + kTestWidget1);
ok(elem, "There should be an item");
ok(wrapper, "There should be a wrapper");
is(wrapper.firstChild.id, kTestWidget1, "Wrapper should have test widget");
is(wrapper.parentNode.id, "customization-palette", "Wrapper should be in palette");
CustomizableUI.destroyWidget(kTestWidget1);
wrapper = document.getElementById("wrapper-" + kTestWidget1);
ok(!wrapper, "There should be a wrapper");
let item = document.getElementById(kTestWidget1);
ok(!item, "There should no longer be an item");
},
},
{
desc: "Creating and destroying a widget should correctly deal with panel placeholders",
run: function() {
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
is(panel.querySelectorAll(".panel-customization-placeholder").length, isInWin8() ? 2 : 3, "The number of placeholders should be correct.");
CustomizableUI.createWidget({id: kTestWidget2, label: 'Pretty label', tooltiptext: 'Pretty tooltip', defaultArea: CustomizableUI.AREA_PANEL});
let elem = document.getElementById(kTestWidget2);
let wrapper = document.getElementById("wrapper-" + kTestWidget2);
ok(elem, "There should be an item");
ok(wrapper, "There should be a wrapper");
is(wrapper.firstChild.id, kTestWidget2, "Wrapper should have test widget");
is(wrapper.parentNode, panel, "Wrapper should be in panel");
is(panel.querySelectorAll(".panel-customization-placeholder").length, isInWin8() ? 1 : 2, "The number of placeholders should be correct.");
CustomizableUI.destroyWidget(kTestWidget2);
wrapper = document.getElementById("wrapper-" + kTestWidget2);
ok(!wrapper, "There should be a wrapper");
let item = document.getElementById(kTestWidget2);
ok(!item, "There should no longer be an item");
},
teardown: endCustomizing
},
];
// Creating and destroying a widget should correctly wrap/unwrap stuff
add_task(function testWrapUnwrap() {
yield startCustomizing();
CustomizableUI.createWidget({id: kTestWidget1, label: 'Pretty label', tooltiptext: 'Pretty tooltip'});
let elem = document.getElementById(kTestWidget1);
let wrapper = document.getElementById("wrapper-" + kTestWidget1);
ok(elem, "There should be an item");
ok(wrapper, "There should be a wrapper");
is(wrapper.firstChild.id, kTestWidget1, "Wrapper should have test widget");
is(wrapper.parentNode.id, "customization-palette", "Wrapper should be in palette");
CustomizableUI.destroyWidget(kTestWidget1);
wrapper = document.getElementById("wrapper-" + kTestWidget1);
ok(!wrapper, "There should be a wrapper");
let item = document.getElementById(kTestWidget1);
ok(!item, "There should no longer be an item");
});
function asyncCleanup() {
// Creating and destroying a widget should correctly deal with panel placeholders
add_task(function testPanelPlaceholders() {
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
is(panel.querySelectorAll(".panel-customization-placeholder").length, isInWin8() ? 2 : 3, "The number of placeholders should be correct.");
CustomizableUI.createWidget({id: kTestWidget2, label: 'Pretty label', tooltiptext: 'Pretty tooltip', defaultArea: CustomizableUI.AREA_PANEL});
let elem = document.getElementById(kTestWidget2);
let wrapper = document.getElementById("wrapper-" + kTestWidget2);
ok(elem, "There should be an item");
ok(wrapper, "There should be a wrapper");
is(wrapper.firstChild.id, kTestWidget2, "Wrapper should have test widget");
is(wrapper.parentNode, panel, "Wrapper should be in panel");
is(panel.querySelectorAll(".panel-customization-placeholder").length, isInWin8() ? 1 : 2, "The number of placeholders should be correct.");
CustomizableUI.destroyWidget(kTestWidget2);
wrapper = document.getElementById("wrapper-" + kTestWidget2);
ok(!wrapper, "There should be a wrapper");
let item = document.getElementById(kTestWidget2);
ok(!item, "There should no longer be an item");
yield endCustomizing();
});
add_task(function asyncCleanup() {
yield endCustomizing();
try {
CustomizableUI.destroyWidget(kTestWidget1);
@ -56,10 +53,4 @@ function asyncCleanup() {
CustomizableUI.destroyWidget(kTestWidget2);
} catch (ex) {}
yield resetCustomization();
}
function test() {
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,49 +2,40 @@
* 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/. */
let gTests = [
{
desc: "Should be able to add broken view widget",
run: function() {
const kWidgetId = 'test-877006-broken-widget';
let widgetSpec = {
id: kWidgetId,
type: 'view',
viewId: 'idontexist',
/* Empty handler so we try to attach it maybe? */
onViewShowing: function() {
},
};
"use strict";
let noError = true;
try {
CustomizableUI.createWidget(widgetSpec);
CustomizableUI.addWidgetToArea(kWidgetId, CustomizableUI.AREA_NAVBAR);
} catch (ex) {
Cu.reportError(ex);
noError = false;
}
ok(noError, "Should not throw an exception trying to add a broken view widget.");
noError = true;
try {
CustomizableUI.destroyWidget(kWidgetId);
} catch (ex) {
Cu.reportError(ex);
noError = false;
}
ok(noError, "Should not throw an exception trying to remove the broken view widget.");
// Should be able to add broken view widget
add_task(function testAddbrokenViewWidget() {
const kWidgetId = 'test-877006-broken-widget';
let widgetSpec = {
id: kWidgetId,
type: 'view',
viewId: 'idontexist',
/* Empty handler so we try to attach it maybe? */
onViewShowing: function() {
}
};
let noError = true;
try {
CustomizableUI.createWidget(widgetSpec);
CustomizableUI.addWidgetToArea(kWidgetId, CustomizableUI.AREA_NAVBAR);
} catch (ex) {
Cu.reportError(ex);
noError = false;
}
];
ok(noError, "Should not throw an exception trying to add a broken view widget.");
noError = true;
try {
CustomizableUI.destroyWidget(kWidgetId);
} catch (ex) {
Cu.reportError(ex);
noError = false;
}
ok(noError, "Should not throw an exception trying to remove the broken view widget.");
});
function asyncCleanup() {
add_task(function asyncCleanup() {
yield resetCustomization();
}
function test() {
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,63 +2,50 @@
* 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/. */
let gTests = [
{
desc: "Sanity checks",
run: function() {
SimpleTest.doesThrow(function() CustomizableUI.registerArea("@foo"),
"Registering areas with an invalid ID should throw.");
"use strict";
SimpleTest.doesThrow(function() CustomizableUI.registerArea([]),
"Registering areas with an invalid ID should throw.");
registerCleanupFunction(removeCustomToolbars);
SimpleTest.doesThrow(function() CustomizableUI.unregisterArea("@foo"),
"Unregistering areas with an invalid ID should throw.");
// Sanity checks
add_task(function sanityChecks() {
SimpleTest.doesThrow(function() CustomizableUI.registerArea("@foo"),
"Registering areas with an invalid ID should throw.");
SimpleTest.doesThrow(function() CustomizableUI.unregisterArea([]),
"Unregistering areas with an invalid ID should throw.");
SimpleTest.doesThrow(function() CustomizableUI.registerArea([]),
"Registering areas with an invalid ID should throw.");
SimpleTest.doesThrow(function() CustomizableUI.unregisterArea("unknown"),
"Unregistering an area that's not registered should throw.");
}
},
{
desc: "Check areas are loaded with their default placements.",
run: function() {
ok(CustomizableUI.inDefaultState, "Everything should be in its default state.");
}
},
{
desc: "Check registering and unregistering a new area.",
run: function() {
const kToolbarId = "test-registration-toolbar";
const kButtonId = "test-registration-button";
createDummyXULButton(kButtonId);
createToolbarWithPlacements(kToolbarId, ["spring", kButtonId, "spring"]);
assertAreaPlacements(kToolbarId,
[/customizableui-special-spring\d+/,
kButtonId,
/customizableui-special-spring\d+/]);
ok(CustomizableUI.inDefaultState, "With a new toolbar and default placements, " +
"everything should still be in a default state.");
removeCustomToolbars(); // Will call unregisterArea for us
ok(CustomizableUI.inDefaultState, "When the toolbar is unregistered, " +
"everything should still be in a default state.");
}
}
];
SimpleTest.doesThrow(function() CustomizableUI.unregisterArea("@foo"),
"Unregistering areas with an invalid ID should throw.");
function asyncCleanup() {
SimpleTest.doesThrow(function() CustomizableUI.unregisterArea([]),
"Unregistering areas with an invalid ID should throw.");
SimpleTest.doesThrow(function() CustomizableUI.unregisterArea("unknown"),
"Unregistering an area that's not registered should throw.");
});
// Check areas are loaded with their default placements.
add_task(function checkLoadedAres() {
ok(CustomizableUI.inDefaultState, "Everything should be in its default state.");
});
// Check registering and unregistering a new area.
add_task(function checkRegisteringAndUnregistering() {
const kToolbarId = "test-registration-toolbar";
const kButtonId = "test-registration-button";
createDummyXULButton(kButtonId);
createToolbarWithPlacements(kToolbarId, ["spring", kButtonId, "spring"]);
assertAreaPlacements(kToolbarId,
[/customizableui-special-spring\d+/,
kButtonId,
/customizableui-special-spring\d+/]);
ok(CustomizableUI.inDefaultState, "With a new toolbar and default placements, " +
"everything should still be in a default state.");
removeCustomToolbars(); // Will call unregisterArea for us
ok(CustomizableUI.inDefaultState, "When the toolbar is unregistered, " +
"everything should still be in a default state.");
});
add_task(function asyncCleanup() {
yield resetCustomization();
}
function cleanup() {
removeCustomToolbars();
}
function test() {
waitForExplicitFinish();
registerCleanupFunction(cleanup);
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,34 +2,24 @@
* 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/. */
let gTests = [
{
run: function() {
const kButtonId = "look-at-me-disappear-button";
CustomizableUI.reset();
ok(CustomizableUI.inDefaultState, "Should be in the default state.");
let btn = createDummyXULButton(kButtonId, "Gone!");
CustomizableUI.addWidgetToArea(kButtonId, CustomizableUI.AREA_NAVBAR);
ok(!CustomizableUI.inDefaultState, "Should no longer be in the default state.");
is(btn.parentNode.parentNode.id, CustomizableUI.AREA_NAVBAR, "Button should be in navbar");
btn.remove();
is(btn.parentNode, null, "Button is no longer in the navbar");
ok(CustomizableUI.inDefaultState, "Should be back in the default state, " +
"despite unknown button ID in placements.");
}
}
];
"use strict";
function asyncCleanup() {
registerCleanupFunction(removeCustomToolbars);
add_task(function skipMissingIDS() {
const kButtonId = "look-at-me-disappear-button";
CustomizableUI.reset();
ok(CustomizableUI.inDefaultState, "Should be in the default state.");
let btn = createDummyXULButton(kButtonId, "Gone!");
CustomizableUI.addWidgetToArea(kButtonId, CustomizableUI.AREA_NAVBAR);
ok(!CustomizableUI.inDefaultState, "Should no longer be in the default state.");
is(btn.parentNode.parentNode.id, CustomizableUI.AREA_NAVBAR, "Button should be in navbar");
btn.remove();
is(btn.parentNode, null, "Button is no longer in the navbar");
ok(CustomizableUI.inDefaultState, "Should be back in the default state, " +
"despite unknown button ID in placements.");
});
add_task(function asyncCleanup() {
yield resetCustomization();
}
function cleanup() {
removeCustomToolbars();
}
function test() {
waitForExplicitFinish();
registerCleanupFunction(cleanup);
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,79 +2,68 @@
* 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/. */
let gTests = [
{
desc: "Dragging an item from the palette to another button in the panel should work.",
setup: startCustomizing,
run: function() {
let btn = document.getElementById("developer-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
"use strict";
let lastButtonIndex = placements.length - 1;
let lastButton = placements[lastButtonIndex];
let placementsAfterInsert = placements.slice(0, lastButtonIndex).concat(["developer-button", lastButton]);
let lastButtonNode = document.getElementById(lastButton);
simulateItemDrag(btn, lastButtonNode);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
let palette = document.getElementById("customization-palette");
simulateItemDrag(btn, palette);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
},
},
{
desc: "Dragging an item from the palette to the panel itself should also work.",
setup: startCustomizing,
run: function() {
let btn = document.getElementById("developer-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
let placementsAfterAppend = placements.concat(["developer-button"]);
simulateItemDrag(btn, panel);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
let palette = document.getElementById("customization-palette");
simulateItemDrag(btn, palette);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
},
},
{
desc: "Dragging an item from the palette to an empty panel should also work.",
setup: function() {
let widgetIds = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
while (widgetIds.length) {
CustomizableUI.removeWidgetFromArea(widgetIds.shift());
}
return startCustomizing()
},
run: function() {
let btn = document.getElementById("developer-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
// Dragging an item from the palette to another button in the panel should work.
add_task(function() {
yield startCustomizing();
let btn = document.getElementById("developer-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
assertAreaPlacements(panel.id, []);
let lastButtonIndex = placements.length - 1;
let lastButton = placements[lastButtonIndex];
let placementsAfterInsert = placements.slice(0, lastButtonIndex).concat(["developer-button", lastButton]);
let lastButtonNode = document.getElementById(lastButton);
simulateItemDrag(btn, lastButtonNode);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
let palette = document.getElementById("customization-palette");
simulateItemDrag(btn, palette);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
});
let placementsAfterAppend = ["developer-button"];
simulateItemDrag(btn, panel);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
let palette = document.getElementById("customization-palette");
simulateItemDrag(btn, palette);
assertAreaPlacements(panel.id, []);
},
// Dragging an item from the palette to the panel itself should also work.
add_task(function() {
yield startCustomizing();
let btn = document.getElementById("developer-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
let placementsAfterAppend = placements.concat(["developer-button"]);
simulateItemDrag(btn, panel);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
let palette = document.getElementById("customization-palette");
simulateItemDrag(btn, palette);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
});
// Dragging an item from the palette to an empty panel should also work.
add_task(function() {
let widgetIds = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
while (widgetIds.length) {
CustomizableUI.removeWidgetFromArea(widgetIds.shift());
}
];
yield startCustomizing();
let btn = document.getElementById("developer-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
function asyncCleanup() {
assertAreaPlacements(panel.id, []);
let placementsAfterAppend = ["developer-button"];
simulateItemDrag(btn, panel);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
let palette = document.getElementById("customization-palette");
simulateItemDrag(btn, palette);
assertAreaPlacements(panel.id, []);
});
add_task(function asyncCleanup() {
yield endCustomizing();
Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck");
yield resetCustomization();
}
function test() {
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,296 +2,277 @@
* 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";
Cu.import("resource://gre/modules/Promise.jsm");
const isOSX = (Services.appinfo.OS === "Darwin");
let gTests = [
{
desc: "Right-click on the home button should show a context menu with options to move it.",
setup: null,
run: function() {
let contextMenu = document.getElementById("toolbar-context-menu");
let shownPromise = contextMenuShown(contextMenu);
let homeButton = document.getElementById("home-button");
EventUtils.synthesizeMouse(homeButton, 2, 2, {type: "contextmenu", button: 2 });
yield shownPromise;
// Right-click on the home button should
// show a context menu with options to move it.
add_task(function() {
let contextMenu = document.getElementById("toolbar-context-menu");
let shownPromise = contextMenuShown(contextMenu);
let homeButton = document.getElementById("home-button");
EventUtils.synthesizeMouse(homeButton, 2, 2, {type: "contextmenu", button: 2 });
yield shownPromise;
let expectedEntries = [
[".customize-context-addToPanel", true],
[".customize-context-removeFromToolbar", true],
["---"]
];
if (!isOSX) {
expectedEntries.push(["#toggle_toolbar-menubar", true]);
}
expectedEntries.push(
["#toggle_PersonalToolbar", true],
["---"],
[".viewCustomizeToolbar", true]
);
checkContextMenu(contextMenu, expectedEntries);
let hiddenPromise = contextMenuHidden(contextMenu);
contextMenu.hidePopup();
yield hiddenPromise;
},
teardown: null
},
{
desc: "Right-click on the urlbar-container should show a context menu with disabled options to move it.",
setup: null,
run: function() {
let contextMenu = document.getElementById("toolbar-context-menu");
let shownPromise = contextMenuShown(contextMenu);
let urlBarContainer = document.getElementById("urlbar-container");
// Need to make sure not to click within an edit field.
let urlbarRect = urlBarContainer.getBoundingClientRect();
EventUtils.synthesizeMouse(urlBarContainer, 100, urlbarRect.height - 1, {type: "contextmenu", button: 2 });
yield shownPromise;
let expectedEntries = [
[".customize-context-addToPanel", false],
[".customize-context-removeFromToolbar", false],
["---"]
];
if (!isOSX) {
expectedEntries.push(["#toggle_toolbar-menubar", true]);
}
expectedEntries.push(
["#toggle_PersonalToolbar", true],
["---"],
[".viewCustomizeToolbar", true]
);
checkContextMenu(contextMenu, expectedEntries);
let hiddenPromise = contextMenuHidden(contextMenu);
contextMenu.hidePopup();
yield hiddenPromise;
},
teardown: null
},
{
desc: "Right-click on the searchbar and moving it to the menu and back should move the search-container instead.",
run: function() {
let searchbar = document.getElementById("searchbar");
gCustomizeMode.addToPanel(searchbar);
let placement = CustomizableUI.getPlacementOfWidget("search-container");
is(placement.area, CustomizableUI.AREA_PANEL, "Should be in panel");
let shownPanelPromise = promisePanelShown(window);
PanelUI.toggle({type: "command"});
yield shownPanelPromise;
let hiddenPanelPromise = promisePanelHidden(window);
PanelUI.toggle({type: "command"});
yield hiddenPanelPromise;
gCustomizeMode.addToToolbar(searchbar);
placement = CustomizableUI.getPlacementOfWidget("search-container");
is(placement.area, CustomizableUI.AREA_NAVBAR, "Should be in navbar");
gCustomizeMode.removeFromArea(searchbar);
placement = CustomizableUI.getPlacementOfWidget("search-container");
is(placement, null, "Should be in palette");
CustomizableUI.reset();
placement = CustomizableUI.getPlacementOfWidget("search-container");
is(placement.area, CustomizableUI.AREA_NAVBAR, "Should be in navbar");
}
},
{
desc: "Right-click on an item within the menu panel should show a context menu with options to move it.",
setup: null,
run: function() {
let shownPanelPromise = promisePanelShown(window);
PanelUI.toggle({type: "command"});
yield shownPanelPromise;
let contextMenu = document.getElementById("customizationPanelItemContextMenu");
let shownContextPromise = contextMenuShown(contextMenu);
let newWindowButton = document.getElementById("new-window-button");
ok(newWindowButton, "new-window-button was found");
EventUtils.synthesizeMouse(newWindowButton, 2, 2, {type: "contextmenu", button: 2});
yield shownContextPromise;
is(PanelUI.panel.state, "open", "The PanelUI should still be open.");
let expectedEntries = [
[".customize-context-addToToolbar", true],
[".customize-context-removeFromPanel", true],
["---"],
[".viewCustomizeToolbar", true]
];
checkContextMenu(contextMenu, expectedEntries);
let hiddenContextPromise = contextMenuHidden(contextMenu);
contextMenu.hidePopup();
yield hiddenContextPromise;
let hiddenPromise = promisePanelHidden(window);
PanelUI.toggle({type: "command"});
yield hiddenPromise;
},
teardown: null
},
{
desc: "Right-click on the home button while in customization mode should show a context menu with options to move it.",
setup: startCustomizing,
run: function () {
let contextMenu = document.getElementById("toolbar-context-menu");
let shownPromise = contextMenuShown(contextMenu);
let homeButton = document.getElementById("wrapper-home-button");
EventUtils.synthesizeMouse(homeButton, 2, 2, {type: "contextmenu", button: 2});
yield shownPromise;
let expectedEntries = [
[".customize-context-addToPanel", true],
[".customize-context-removeFromToolbar", true],
["---"]
];
if (!isOSX) {
expectedEntries.push(["#toggle_toolbar-menubar", true]);
}
expectedEntries.push(
["#toggle_PersonalToolbar", true],
["---"],
[".viewCustomizeToolbar", false]
);
checkContextMenu(contextMenu, expectedEntries);
let hiddenContextPromise = contextMenuHidden(contextMenu);
contextMenu.hidePopup();
yield hiddenContextPromise;
},
teardown: null
},
{
desc: "Right-click on an item in the palette should show a context menu with options to move it.",
setup: null,
run: function () {
let contextMenu = document.getElementById("customizationPaletteItemContextMenu");
let shownPromise = contextMenuShown(contextMenu);
let openFileButton = document.getElementById("wrapper-open-file-button");
EventUtils.synthesizeMouse(openFileButton, 2, 2, {type: "contextmenu", button: 2});
yield shownPromise;
let expectedEntries = [
[".customize-context-addToToolbar", true],
[".customize-context-addToPanel", true],
];
checkContextMenu(contextMenu, expectedEntries);
let hiddenContextPromise = contextMenuHidden(contextMenu);
contextMenu.hidePopup();
yield hiddenContextPromise;
},
teardown: null
},
{
desc: "Right-click on an item in the panel while in customization mode should show a context menu with options to move it.",
setup: null,
run: function () {
let contextMenu = document.getElementById("customizationPanelItemContextMenu");
let shownPromise = contextMenuShown(contextMenu);
let newWindowButton = document.getElementById("wrapper-new-window-button");
EventUtils.synthesizeMouse(newWindowButton, 2, 2, {type: "contextmenu", button: 2});
yield shownPromise;
let expectedEntries = [
[".customize-context-addToToolbar", true],
[".customize-context-removeFromPanel", true],
["---"],
[".viewCustomizeToolbar", false]
];
checkContextMenu(contextMenu, expectedEntries);
let hiddenContextPromise = contextMenuHidden(contextMenu);
contextMenu.hidePopup();
yield hiddenContextPromise;
},
teardown: endCustomizing
},
{
desc: "Test the toolbarbutton panel context menu in customization mode without opening the panel before customization mode",
setup: null,
run: function() {
this.otherWin = yield openAndLoadWindow(null, true);
yield startCustomizing(this.otherWin);
let contextMenu = this.otherWin.document.getElementById("customizationPanelItemContextMenu");
let shownPromise = contextMenuShown(contextMenu);
let newWindowButton = this.otherWin.document.getElementById("wrapper-new-window-button");
EventUtils.synthesizeMouse(newWindowButton, 2, 2, {type: "contextmenu", button: 2}, this.otherWin);
yield shownPromise;
let expectedEntries = [
[".customize-context-addToToolbar", true],
[".customize-context-removeFromPanel", true],
["---"],
[".viewCustomizeToolbar", false]
];
checkContextMenu(contextMenu, expectedEntries, this.otherWin);
let hiddenContextPromise = contextMenuHidden(contextMenu);
contextMenu.hidePopup();
yield hiddenContextPromise;
},
teardown: function() {
yield endCustomizing(this.otherWin);
this.otherWin.close();
this.otherWin = null;
}
},
{
desc: "Bug 945191 - Combined buttons show wrong context menu options when they are in the toolbar.",
setup: startCustomizing,
run: function () {
let contextMenu = document.getElementById("customizationPanelItemContextMenu");
let shownPromise = contextMenuShown(contextMenu);
let zoomControls = document.getElementById("wrapper-zoom-controls");
EventUtils.synthesizeMouse(zoomControls, 2, 2, {type: "contextmenu", button: 2});
yield shownPromise;
// Execute the command to move the item from the panel to the toolbar.
contextMenu.childNodes[0].doCommand();
let hiddenPromise = contextMenuHidden(contextMenu);
contextMenu.hidePopup();
yield hiddenPromise;
yield endCustomizing();
zoomControls = document.getElementById("zoom-controls");
is(zoomControls.parentNode.id, "nav-bar-customization-target", "Zoom-controls should be on the nav-bar");
contextMenu = document.getElementById("toolbar-context-menu");
shownPromise = contextMenuShown(contextMenu);
EventUtils.synthesizeMouse(zoomControls, 2, 2, {type: "contextmenu", button: 2});
yield shownPromise;
let expectedEntries = [
[".customize-context-addToPanel", true],
[".customize-context-removeFromToolbar", true],
["---"]
];
if (!isOSX) {
expectedEntries.push(["#toggle_toolbar-menubar", true]);
}
expectedEntries.push(
["#toggle_PersonalToolbar", true],
["---"],
[".viewCustomizeToolbar", true]
);
checkContextMenu(contextMenu, expectedEntries);
hiddenPromise = contextMenuHidden(contextMenu);
contextMenu.hidePopup();
yield hiddenPromise;
},
teardown: resetCustomization,
let expectedEntries = [
[".customize-context-addToPanel", true],
[".customize-context-removeFromToolbar", true],
["---"]
];
if (!isOSX) {
expectedEntries.push(["#toggle_toolbar-menubar", true]);
}
];
expectedEntries.push(
["#toggle_PersonalToolbar", true],
["---"],
[".viewCustomizeToolbar", true]
);
checkContextMenu(contextMenu, expectedEntries);
function test() {
waitForExplicitFinish();
runTests(gTests);
}
let hiddenPromise = contextMenuHidden(contextMenu);
contextMenu.hidePopup();
yield hiddenPromise;
});
// Right-click on the urlbar-container should
// show a context menu with disabled options to move it.
add_task(function() {
let contextMenu = document.getElementById("toolbar-context-menu");
let shownPromise = contextMenuShown(contextMenu);
let urlBarContainer = document.getElementById("urlbar-container");
// Need to make sure not to click within an edit field.
let urlbarRect = urlBarContainer.getBoundingClientRect();
EventUtils.synthesizeMouse(urlBarContainer, 100, urlbarRect.height - 1, {type: "contextmenu", button: 2 });
yield shownPromise;
let expectedEntries = [
[".customize-context-addToPanel", false],
[".customize-context-removeFromToolbar", false],
["---"]
];
if (!isOSX) {
expectedEntries.push(["#toggle_toolbar-menubar", true]);
}
expectedEntries.push(
["#toggle_PersonalToolbar", true],
["---"],
[".viewCustomizeToolbar", true]
);
checkContextMenu(contextMenu, expectedEntries);
let hiddenPromise = contextMenuHidden(contextMenu);
contextMenu.hidePopup();
yield hiddenPromise;
});
// Right-click on the searchbar and moving it to the menu
// and back should move the search-container instead.
add_task(function() {
let searchbar = document.getElementById("searchbar");
gCustomizeMode.addToPanel(searchbar);
let placement = CustomizableUI.getPlacementOfWidget("search-container");
is(placement.area, CustomizableUI.AREA_PANEL, "Should be in panel");
let shownPanelPromise = promisePanelShown(window);
PanelUI.toggle({type: "command"});
yield shownPanelPromise;
let hiddenPanelPromise = promisePanelHidden(window);
PanelUI.toggle({type: "command"});
yield hiddenPanelPromise;
gCustomizeMode.addToToolbar(searchbar);
placement = CustomizableUI.getPlacementOfWidget("search-container");
is(placement.area, CustomizableUI.AREA_NAVBAR, "Should be in navbar");
gCustomizeMode.removeFromArea(searchbar);
placement = CustomizableUI.getPlacementOfWidget("search-container");
is(placement, null, "Should be in palette");
CustomizableUI.reset();
placement = CustomizableUI.getPlacementOfWidget("search-container");
is(placement.area, CustomizableUI.AREA_NAVBAR, "Should be in navbar");
});
// Right-click on an item within the menu panel should
// show a context menu with options to move it.
add_task(function() {
let shownPanelPromise = promisePanelShown(window);
PanelUI.toggle({type: "command"});
yield shownPanelPromise;
let contextMenu = document.getElementById("customizationPanelItemContextMenu");
let shownContextPromise = contextMenuShown(contextMenu);
let newWindowButton = document.getElementById("new-window-button");
ok(newWindowButton, "new-window-button was found");
EventUtils.synthesizeMouse(newWindowButton, 2, 2, {type: "contextmenu", button: 2});
yield shownContextPromise;
is(PanelUI.panel.state, "open", "The PanelUI should still be open.");
let expectedEntries = [
[".customize-context-addToToolbar", true],
[".customize-context-removeFromPanel", true],
["---"],
[".viewCustomizeToolbar", true]
];
checkContextMenu(contextMenu, expectedEntries);
let hiddenContextPromise = contextMenuHidden(contextMenu);
contextMenu.hidePopup();
yield hiddenContextPromise;
let hiddenPromise = promisePanelHidden(window);
PanelUI.toggle({type: "command"});
yield hiddenPromise;
});
// Right-click on the home button while in customization mode
// should show a context menu with options to move it.
add_task(function() {
yield startCustomizing();
let contextMenu = document.getElementById("toolbar-context-menu");
let shownPromise = contextMenuShown(contextMenu);
let homeButton = document.getElementById("wrapper-home-button");
EventUtils.synthesizeMouse(homeButton, 2, 2, {type: "contextmenu", button: 2});
yield shownPromise;
let expectedEntries = [
[".customize-context-addToPanel", true],
[".customize-context-removeFromToolbar", true],
["---"]
];
if (!isOSX) {
expectedEntries.push(["#toggle_toolbar-menubar", true]);
}
expectedEntries.push(
["#toggle_PersonalToolbar", true],
["---"],
[".viewCustomizeToolbar", false]
);
checkContextMenu(contextMenu, expectedEntries);
let hiddenContextPromise = contextMenuHidden(contextMenu);
contextMenu.hidePopup();
yield hiddenContextPromise;
});
// Right-click on an item in the palette should
// show a context menu with options to move it.
add_task(function() {
let contextMenu = document.getElementById("customizationPaletteItemContextMenu");
let shownPromise = contextMenuShown(contextMenu);
let openFileButton = document.getElementById("wrapper-open-file-button");
EventUtils.synthesizeMouse(openFileButton, 2, 2, {type: "contextmenu", button: 2});
yield shownPromise;
let expectedEntries = [
[".customize-context-addToToolbar", true],
[".customize-context-addToPanel", true]
];
checkContextMenu(contextMenu, expectedEntries);
let hiddenContextPromise = contextMenuHidden(contextMenu);
contextMenu.hidePopup();
yield hiddenContextPromise;
});
// Right-click on an item in the panel while in customization mode
// should show a context menu with options to move it.
add_task(function() {
let contextMenu = document.getElementById("customizationPanelItemContextMenu");
let shownPromise = contextMenuShown(contextMenu);
let newWindowButton = document.getElementById("wrapper-new-window-button");
EventUtils.synthesizeMouse(newWindowButton, 2, 2, {type: "contextmenu", button: 2});
yield shownPromise;
let expectedEntries = [
[".customize-context-addToToolbar", true],
[".customize-context-removeFromPanel", true],
["---"],
[".viewCustomizeToolbar", false]
];
checkContextMenu(contextMenu, expectedEntries);
let hiddenContextPromise = contextMenuHidden(contextMenu);
contextMenu.hidePopup();
yield hiddenContextPromise;
yield endCustomizing();
});
// Test the toolbarbutton panel context menu in customization mode
// without opening the panel before customization mode
add_task(function() {
this.otherWin = yield openAndLoadWindow(null, true);
yield startCustomizing(this.otherWin);
let contextMenu = this.otherWin.document.getElementById("customizationPanelItemContextMenu");
let shownPromise = contextMenuShown(contextMenu);
let newWindowButton = this.otherWin.document.getElementById("wrapper-new-window-button");
EventUtils.synthesizeMouse(newWindowButton, 2, 2, {type: "contextmenu", button: 2}, this.otherWin);
yield shownPromise;
let expectedEntries = [
[".customize-context-addToToolbar", true],
[".customize-context-removeFromPanel", true],
["---"],
[".viewCustomizeToolbar", false]
];
checkContextMenu(contextMenu, expectedEntries, this.otherWin);
let hiddenContextPromise = contextMenuHidden(contextMenu);
contextMenu.hidePopup();
yield hiddenContextPromise;
yield endCustomizing(this.otherWin);
this.otherWin.close();
this.otherWin = null;
});
// Bug 945191 - Combined buttons show wrong context menu options
// when they are in the toolbar.
add_task(function() {
yield startCustomizing();
let contextMenu = document.getElementById("customizationPanelItemContextMenu");
let shownPromise = contextMenuShown(contextMenu);
let zoomControls = document.getElementById("wrapper-zoom-controls");
EventUtils.synthesizeMouse(zoomControls, 2, 2, {type: "contextmenu", button: 2});
yield shownPromise;
// Execute the command to move the item from the panel to the toolbar.
contextMenu.childNodes[0].doCommand();
let hiddenPromise = contextMenuHidden(contextMenu);
contextMenu.hidePopup();
yield hiddenPromise;
yield endCustomizing();
zoomControls = document.getElementById("zoom-controls");
is(zoomControls.parentNode.id, "nav-bar-customization-target", "Zoom-controls should be on the nav-bar");
contextMenu = document.getElementById("toolbar-context-menu");
shownPromise = contextMenuShown(contextMenu);
EventUtils.synthesizeMouse(zoomControls, 2, 2, {type: "contextmenu", button: 2});
yield shownPromise;
let expectedEntries = [
[".customize-context-addToPanel", true],
[".customize-context-removeFromToolbar", true],
["---"]
];
if (!isOSX) {
expectedEntries.push(["#toggle_toolbar-menubar", true]);
}
expectedEntries.push(
["#toggle_PersonalToolbar", true],
["---"],
[".viewCustomizeToolbar", true]
);
checkContextMenu(contextMenu, expectedEntries);
hiddenPromise = contextMenuHidden(contextMenu);
contextMenu.hidePopup();
yield hiddenPromise;
yield resetCustomization();
});
function contextMenuShown(aContextMenu) {
let deferred = Promise.defer();

Просмотреть файл

@ -2,477 +2,449 @@
* 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/. */
let gTests = [
{
desc: "Dragging the zoom controls to be before the print button " +
"should not move any controls.",
setup: startCustomizing,
run: function() {
let zoomControls = document.getElementById("zoom-controls");
let printButton = document.getElementById("print-button");
let placementsAfterMove = ["edit-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"zoom-controls",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, printButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
let newWindowButton = document.getElementById("new-window-button");
simulateItemDrag(zoomControls, newWindowButton);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
},
},
{
desc: "Dragging the zoom controls to be before the save button " +
"should not move any controls.",
setup: startCustomizing,
run: function() {
let zoomControls = document.getElementById("zoom-controls");
let savePageButton = document.getElementById("save-page-button");
let placementsAfterMove = ["edit-controls",
"zoom-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, savePageButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
ok(CustomizableUI.inDefaultState, "Should be in default state.");
},
},
{
desc: "Dragging the zoom controls to be before the new-window " +
"button should not move any widgets.",
setup: startCustomizing,
run: function() {
let zoomControls = document.getElementById("zoom-controls");
let newWindowButton = document.getElementById("new-window-button");
let placementsAfterMove = ["edit-controls",
"zoom-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, newWindowButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
},
},
{
desc: "Dragging the zoom controls to be before the history-panelmenu " +
"should move the zoom-controls in to the row higher than the " +
"history-panelmenu.",
setup: startCustomizing,
run: function() {
let zoomControls = document.getElementById("zoom-controls");
let historyPanelMenu = document.getElementById("history-panelmenu");
let placementsAfterMove = ["edit-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"zoom-controls",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, historyPanelMenu);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
let newWindowButton = document.getElementById("new-window-button");
simulateItemDrag(zoomControls, newWindowButton);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
},
},
{
desc: "Dragging the zoom controls to be before the preferences-button " +
"should move the zoom-controls in to the row higher than the " +
"preferences-button.",
setup: startCustomizing,
run: function() {
let zoomControls = document.getElementById("zoom-controls");
let preferencesButton = document.getElementById("preferences-button");
let placementsAfterMove = ["edit-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"zoom-controls",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, preferencesButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
let newWindowButton = document.getElementById("new-window-button");
simulateItemDrag(zoomControls, newWindowButton);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
},
},
{
desc: "Dragging an item from the palette to before the zoom-controls " +
"should move it and two other buttons before the zoom controls.",
setup: startCustomizing,
run: function() {
let developerButton = document.getElementById("developer-button");
let zoomControls = document.getElementById("zoom-controls");
let placementsAfterInsert = ["edit-controls",
"developer-button",
"new-window-button",
"privatebrowsing-button",
"zoom-controls",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterInsert);
simulateItemDrag(developerButton, zoomControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
let palette = document.getElementById("customization-palette");
// Check that the palette items are re-wrapped correctly.
let feedWrapper = document.getElementById("wrapper-feed-button");
let feedButton = document.getElementById("feed-button");
is(feedButton.parentNode, feedWrapper,
"feed-button should be a child of wrapper-feed-button");
is(feedWrapper.getAttribute("place"), "palette",
"The feed-button wrapper should have it's place set to 'palette'");
simulateItemDrag(developerButton, palette);
is(developerButton.parentNode.tagName, "toolbarpaletteitem",
"The developer-button should be wrapped by a toolbarpaletteitem");
let newWindowButton = document.getElementById("new-window-button");
simulateItemDrag(zoomControls, newWindowButton);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
},
},
{
desc: "Dragging an item from the palette to before the edit-controls " +
"should move it and two other buttons before the edit and zoom controls.",
setup: startCustomizing,
run: function() {
let developerButton = document.getElementById("developer-button");
let editControls = document.getElementById("edit-controls");
let placementsAfterInsert = ["developer-button",
"new-window-button",
"privatebrowsing-button",
"edit-controls",
"zoom-controls",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterInsert);
simulateItemDrag(developerButton, editControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
let palette = document.getElementById("customization-palette");
// Check that the palette items are re-wrapped correctly.
let feedWrapper = document.getElementById("wrapper-feed-button");
let feedButton = document.getElementById("feed-button");
is(feedButton.parentNode, feedWrapper,
"feed-button should be a child of wrapper-feed-button");
is(feedWrapper.getAttribute("place"), "palette",
"The feed-button wrapper should have it's place set to 'palette'");
simulateItemDrag(developerButton, palette);
is(developerButton.parentNode.tagName, "toolbarpaletteitem",
"The developer-button should be wrapped by a toolbarpaletteitem");
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
},
},
{
desc: "Dragging the edit-controls to be before the zoom-controls button " +
"should not move any widgets.",
setup: startCustomizing,
run: function() {
let editControls = document.getElementById("edit-controls");
let zoomControls = document.getElementById("zoom-controls");
let placementsAfterMove = ["edit-controls",
"zoom-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, zoomControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
},
},
{
desc: "Dragging the edit-controls to be before the new-window-button should " +
"move the zoom-controls before the edit-controls.",
setup: startCustomizing,
run: function() {
let editControls = document.getElementById("edit-controls");
let newWindowButton = document.getElementById("new-window-button");
let placementsAfterMove = ["zoom-controls",
"edit-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, newWindowButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(editControls, zoomControls);
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
},
},
{
desc: "Dragging the edit-controls to be before the privatebrowsing-button " +
"should move the edit-controls in to the row higher than the " +
"privatebrowsing-button.",
setup: startCustomizing,
run: function() {
let editControls = document.getElementById("edit-controls");
let privateBrowsingButton = document.getElementById("privatebrowsing-button");
let placementsAfterMove = ["zoom-controls",
"edit-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, privateBrowsingButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(editControls, zoomControls);
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
},
},
{
desc: "Dragging the edit-controls to be before the save-page-button " +
"should move the edit-controls in to the row higher than the " +
"save-page-button.",
setup: startCustomizing,
run: function() {
let editControls = document.getElementById("edit-controls");
let savePageButton = document.getElementById("save-page-button");
let placementsAfterMove = ["zoom-controls",
"edit-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, savePageButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(editControls, zoomControls);
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
},
},
{
desc: "Dragging the edit-controls to the panel itself should append " +
"the edit controls to the bottom of the panel.",
setup: startCustomizing,
run: function() {
let editControls = document.getElementById("edit-controls");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let placementsAfterMove = ["zoom-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button",
"edit-controls"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, panel);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(editControls, zoomControls);
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
},
},
{
desc: "Dragging the edit-controls to the customization-palette and " +
"back should work.",
setup: startCustomizing,
run: function() {
let editControls = document.getElementById("edit-controls");
let palette = document.getElementById("customization-palette");
let placementsAfterMove = ["zoom-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
let paletteChildElementCount = palette.childElementCount;
simulateItemDrag(editControls, palette);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
is(paletteChildElementCount + 1, palette.childElementCount,
"The palette should have a new child, congratulations!");
is(editControls.parentNode.id, "wrapper-edit-controls",
"The edit-controls should be properly wrapped.");
is(editControls.parentNode.getAttribute("place"), "palette",
"The edit-controls should have the place of 'palette'.");
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(editControls, zoomControls);
is(paletteChildElementCount, palette.childElementCount,
"The palette child count should have returned to its prior value.");
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
},
},
{
desc: "Dragging the edit-controls to each of the panel placeholders " +
"should append the edit-controls to the bottom of the panel.",
setup: startCustomizing,
run: function() {
let editControls = document.getElementById("edit-controls");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let numPlaceholders = isInWin8() ? 2 : 3;
for (let i = 0; i < numPlaceholders; i++) {
// NB: We can't just iterate over all of the placeholders
// because each drag-drop action recreates them.
let placeholder = panel.getElementsByClassName("panel-customization-placeholder")[i];
let placementsAfterMove = ["zoom-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button",
"edit-controls"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, placeholder);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(editControls, zoomControls);
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
}
},
},
{
desc: "Dragging the developer-button back on to itself should work.",
setup: startCustomizing,
run: function() {
let developerButton = document.getElementById("developer-button");
is(developerButton.parentNode.tagName, "toolbarpaletteitem",
"developer-button should be wrapped by a toolbarpaletteitem");
simulateItemDrag(developerButton, developerButton);
is(developerButton.parentNode.tagName, "toolbarpaletteitem",
"developer-button should be wrapped by a toolbarpaletteitem");
let editControls = document.getElementById("edit-controls");
is(editControls.parentNode.tagName, "toolbarpaletteitem",
"edit-controls should be wrapped by a toolbarpaletteitem");
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
},
},
{
desc: "Dragging a small button onto the last big button should work.",
setup: startCustomizing,
run: function() {
let editControls = document.getElementById("edit-controls");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let target = panel.getElementsByClassName("panel-customization-placeholder")[0];
let placementsAfterMove = ["zoom-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button",
"edit-controls"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, target);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let itemToDrag = "sync-button";
let button = document.getElementById(itemToDrag);
if (!isInWin8()) {
placementsAfterMove.push(itemToDrag);
} else {
placementsAfterMove.splice(11, 0, itemToDrag);
}
simulateItemDrag(button, editControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
"use strict";
// Put stuff back:
let palette = document.getElementById("customization-palette");
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(button, palette);
simulateItemDrag(editControls, zoomControls);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
},
},
];
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
requestLongerTimeout(5);
function asyncCleanup() {
// Dragging the zoom controls to be before the print button should not move any controls.
add_task(function() {
yield startCustomizing();
let zoomControls = document.getElementById("zoom-controls");
let printButton = document.getElementById("print-button");
let placementsAfterMove = ["edit-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"zoom-controls",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, printButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
let newWindowButton = document.getElementById("new-window-button");
simulateItemDrag(zoomControls, newWindowButton);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
});
// Dragging the zoom controls to be before the save button should not move any controls.
add_task(function() {
yield startCustomizing();
let zoomControls = document.getElementById("zoom-controls");
let savePageButton = document.getElementById("save-page-button");
let placementsAfterMove = ["edit-controls",
"zoom-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, savePageButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
ok(CustomizableUI.inDefaultState, "Should be in default state.");
});
// Dragging the zoom controls to be before the new-window button should not move any widgets.
add_task(function() {
yield startCustomizing();
let zoomControls = document.getElementById("zoom-controls");
let newWindowButton = document.getElementById("new-window-button");
let placementsAfterMove = ["edit-controls",
"zoom-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, newWindowButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
});
// Dragging the zoom controls to be before the history-panelmenu should move the zoom-controls in to the row higher than the history-panelmenu.
add_task(function() {
yield startCustomizing();
let zoomControls = document.getElementById("zoom-controls");
let historyPanelMenu = document.getElementById("history-panelmenu");
let placementsAfterMove = ["edit-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"zoom-controls",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, historyPanelMenu);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
let newWindowButton = document.getElementById("new-window-button");
simulateItemDrag(zoomControls, newWindowButton);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
});
// Dragging the zoom controls to be before the preferences-button should move the zoom-controls
// in to the row higher than the preferences-button.
add_task(function() {
yield startCustomizing();
let zoomControls = document.getElementById("zoom-controls");
let preferencesButton = document.getElementById("preferences-button");
let placementsAfterMove = ["edit-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"zoom-controls",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, preferencesButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
let newWindowButton = document.getElementById("new-window-button");
simulateItemDrag(zoomControls, newWindowButton);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
});
// Dragging an item from the palette to before the zoom-controls should move it and two other buttons before the zoom controls.
add_task(function() {
yield startCustomizing();
let developerButton = document.getElementById("developer-button");
let zoomControls = document.getElementById("zoom-controls");
let placementsAfterInsert = ["edit-controls",
"developer-button",
"new-window-button",
"privatebrowsing-button",
"zoom-controls",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterInsert);
simulateItemDrag(developerButton, zoomControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
let palette = document.getElementById("customization-palette");
// Check that the palette items are re-wrapped correctly.
let feedWrapper = document.getElementById("wrapper-feed-button");
let feedButton = document.getElementById("feed-button");
is(feedButton.parentNode, feedWrapper,
"feed-button should be a child of wrapper-feed-button");
is(feedWrapper.getAttribute("place"), "palette",
"The feed-button wrapper should have it's place set to 'palette'");
simulateItemDrag(developerButton, palette);
is(developerButton.parentNode.tagName, "toolbarpaletteitem",
"The developer-button should be wrapped by a toolbarpaletteitem");
let newWindowButton = document.getElementById("new-window-button");
simulateItemDrag(zoomControls, newWindowButton);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
});
// Dragging an item from the palette to before the edit-controls
// should move it and two other buttons before the edit and zoom controls.
add_task(function() {
yield startCustomizing();
let developerButton = document.getElementById("developer-button");
let editControls = document.getElementById("edit-controls");
let placementsAfterInsert = ["developer-button",
"new-window-button",
"privatebrowsing-button",
"edit-controls",
"zoom-controls",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterInsert);
simulateItemDrag(developerButton, editControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
let palette = document.getElementById("customization-palette");
// Check that the palette items are re-wrapped correctly.
let feedWrapper = document.getElementById("wrapper-feed-button");
let feedButton = document.getElementById("feed-button");
is(feedButton.parentNode, feedWrapper,
"feed-button should be a child of wrapper-feed-button");
is(feedWrapper.getAttribute("place"), "palette",
"The feed-button wrapper should have it's place set to 'palette'");
simulateItemDrag(developerButton, palette);
is(developerButton.parentNode.tagName, "toolbarpaletteitem",
"The developer-button should be wrapped by a toolbarpaletteitem");
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
});
// Dragging the edit-controls to be before the zoom-controls button
// should not move any widgets.
add_task(function() {
yield startCustomizing();
let editControls = document.getElementById("edit-controls");
let zoomControls = document.getElementById("zoom-controls");
let placementsAfterMove = ["edit-controls",
"zoom-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, zoomControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
});
// Dragging the edit-controls to be before the new-window-button should
// move the zoom-controls before the edit-controls.
add_task(function() {
yield startCustomizing();
let editControls = document.getElementById("edit-controls");
let newWindowButton = document.getElementById("new-window-button");
let placementsAfterMove = ["zoom-controls",
"edit-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, newWindowButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(editControls, zoomControls);
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
});
// Dragging the edit-controls to be before the privatebrowsing-button
// should move the edit-controls in to the row higher than the
// privatebrowsing-button.
add_task(function() {
yield startCustomizing();
let editControls = document.getElementById("edit-controls");
let privateBrowsingButton = document.getElementById("privatebrowsing-button");
let placementsAfterMove = ["zoom-controls",
"edit-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, privateBrowsingButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(editControls, zoomControls);
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
});
// Dragging the edit-controls to be before the save-page-button
// should move the edit-controls in to the row higher than the
// save-page-button.
add_task(function() {
yield startCustomizing();
let editControls = document.getElementById("edit-controls");
let savePageButton = document.getElementById("save-page-button");
let placementsAfterMove = ["zoom-controls",
"edit-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, savePageButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(editControls, zoomControls);
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
});
// Dragging the edit-controls to the panel itself should append
// the edit controls to the bottom of the panel.
add_task(function() {
yield startCustomizing();
let editControls = document.getElementById("edit-controls");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let placementsAfterMove = ["zoom-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button",
"edit-controls"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, panel);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(editControls, zoomControls);
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
});
// Dragging the edit-controls to the customization-palette and
// back should work.
add_task(function() {
yield startCustomizing();
let editControls = document.getElementById("edit-controls");
let palette = document.getElementById("customization-palette");
let placementsAfterMove = ["zoom-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
let paletteChildElementCount = palette.childElementCount;
simulateItemDrag(editControls, palette);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
is(paletteChildElementCount + 1, palette.childElementCount,
"The palette should have a new child, congratulations!");
is(editControls.parentNode.id, "wrapper-edit-controls",
"The edit-controls should be properly wrapped.");
is(editControls.parentNode.getAttribute("place"), "palette",
"The edit-controls should have the place of 'palette'.");
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(editControls, zoomControls);
is(paletteChildElementCount, palette.childElementCount,
"The palette child count should have returned to its prior value.");
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
});
// Dragging the edit-controls to each of the panel placeholders
// should append the edit-controls to the bottom of the panel.
add_task(function() {
yield startCustomizing();
let editControls = document.getElementById("edit-controls");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let numPlaceholders = isInWin8() ? 2 : 3;
for (let i = 0; i < numPlaceholders; i++) {
// NB: We can't just iterate over all of the placeholders
// because each drag-drop action recreates them.
let placeholder = panel.getElementsByClassName("panel-customization-placeholder")[i];
let placementsAfterMove = ["zoom-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button",
"edit-controls"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, placeholder);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(editControls, zoomControls);
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
}
});
// Dragging the developer-button back on to itself should work.
add_task(function() {
yield startCustomizing();
let developerButton = document.getElementById("developer-button");
is(developerButton.parentNode.tagName, "toolbarpaletteitem",
"developer-button should be wrapped by a toolbarpaletteitem");
simulateItemDrag(developerButton, developerButton);
is(developerButton.parentNode.tagName, "toolbarpaletteitem",
"developer-button should be wrapped by a toolbarpaletteitem");
let editControls = document.getElementById("edit-controls");
is(editControls.parentNode.tagName, "toolbarpaletteitem",
"edit-controls should be wrapped by a toolbarpaletteitem");
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
});
// Dragging a small button onto the last big button should work.
add_task(function() {
yield startCustomizing();
let editControls = document.getElementById("edit-controls");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let target = panel.getElementsByClassName("panel-customization-placeholder")[0];
let placementsAfterMove = ["zoom-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
"history-panelmenu",
"fullscreen-button",
"find-button",
"preferences-button",
"add-ons-button",
"edit-controls"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, target);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let itemToDrag = "sync-button";
let button = document.getElementById(itemToDrag);
if (!isInWin8()) {
placementsAfterMove.push(itemToDrag);
} else {
placementsAfterMove.splice(11, 0, itemToDrag);
}
simulateItemDrag(button, editControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
// Put stuff back:
let palette = document.getElementById("customization-palette");
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(button, palette);
simulateItemDrag(editControls, zoomControls);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
});
add_task(function asyncCleanup() {
yield endCustomizing();
Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck");
yield resetCustomization();
}
function test() {
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
waitForExplicitFinish();
requestLongerTimeout(5);
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,6 +2,8 @@
* 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 kWidgetId = "some-widget";
function assertWidgetExists(aWindow, aExists) {
@ -14,138 +16,125 @@ function assertWidgetExists(aWindow, aExists) {
}
}
let gTests = [
{
desc: "A widget that is created with showInPrivateBrowsing undefined should " +
"have that value default to true.",
run: function() {
let wrapper = CustomizableUI.createWidget({
id: kWidgetId
});
ok(wrapper.showInPrivateBrowsing,
"showInPrivateBrowsing should have defaulted to true.");
CustomizableUI.destroyWidget(kWidgetId);
},
},
{
desc: "Add a widget via the API with showInPrivateBrowsing set to false " +
"and ensure it does not appear in pre-existing or newly created " +
"private windows.",
run: function() {
let plain = yield openAndLoadWindow();
let private = yield openAndLoadWindow({private: true});
// A widget that is created with showInPrivateBrowsing undefined should
// have that value default to true.
add_task(function() {
let wrapper = CustomizableUI.createWidget({
id: kWidgetId
});
ok(wrapper.showInPrivateBrowsing,
"showInPrivateBrowsing should have defaulted to true.");
CustomizableUI.destroyWidget(kWidgetId);
});
CustomizableUI.createWidget({
id: kWidgetId,
removable: true,
showInPrivateBrowsing: false
});
CustomizableUI.addWidgetToArea(kWidgetId,
CustomizableUI.AREA_NAVBAR);
assertWidgetExists(plain, true);
assertWidgetExists(private, false);
// Add a widget via the API with showInPrivateBrowsing set to false
// and ensure it does not appear in pre-existing or newly created
// private windows.
add_task(function() {
let plain1 = yield openAndLoadWindow();
let private1 = yield openAndLoadWindow({private: true});
CustomizableUI.createWidget({
id: kWidgetId,
removable: true,
showInPrivateBrowsing: false
});
CustomizableUI.addWidgetToArea(kWidgetId,
CustomizableUI.AREA_NAVBAR);
assertWidgetExists(plain1, true);
assertWidgetExists(private1, false);
// Now open up some new windows. The widget should exist in the new
// plain window, but not the new private window.
let plain2 = yield openAndLoadWindow();
let private2 = yield openAndLoadWindow({private: true});
// Now open up some new windows. The widget should exist in the new
// plain window, but not the new private window.
let plain2 = yield openAndLoadWindow();
let private2 = yield openAndLoadWindow({private: true});
assertWidgetExists(plain2, true);
assertWidgetExists(private2, false);
assertWidgetExists(plain2, true);
assertWidgetExists(private2, false);
// Try moving the widget around and make sure it doesn't get added
// to the private windows. We'll start by appending it to the tabstrip.
CustomizableUI.addWidgetToArea(kWidgetId,
CustomizableUI.AREA_TABSTRIP);
assertWidgetExists(plain1, true);
assertWidgetExists(plain2, true);
assertWidgetExists(private1, false);
assertWidgetExists(private2, false);
// Try moving the widget around and make sure it doesn't get added
// to the private windows. We'll start by appending it to the tabstrip.
CustomizableUI.addWidgetToArea(kWidgetId,
CustomizableUI.AREA_TABSTRIP);
assertWidgetExists(plain, true);
assertWidgetExists(plain2, true);
assertWidgetExists(private, false);
assertWidgetExists(private2, false);
// And then move it to the beginning of the tabstrip.
CustomizableUI.moveWidgetWithinArea(kWidgetId, 0);
assertWidgetExists(plain1, true);
assertWidgetExists(plain2, true);
assertWidgetExists(private1, false);
assertWidgetExists(private2, false);
// And then move it to the beginning of the tabstrip.
CustomizableUI.moveWidgetWithinArea(kWidgetId, 0);
assertWidgetExists(plain, true);
assertWidgetExists(plain2, true);
assertWidgetExists(private, false);
assertWidgetExists(private2, false);
CustomizableUI.removeWidgetFromArea("some-widget");
assertWidgetExists(plain1, false);
assertWidgetExists(plain2, false);
assertWidgetExists(private1, false);
assertWidgetExists(private2, false);
CustomizableUI.removeWidgetFromArea("some-widget");
assertWidgetExists(plain, false);
assertWidgetExists(plain2, false);
assertWidgetExists(private, false);
assertWidgetExists(private2, false);
plain1.close();
plain2.close();
private1.close();
private2.close();
plain.close();
plain2.close();
private.close();
private2.close();
CustomizableUI.destroyWidget("some-widget");
});
CustomizableUI.destroyWidget("some-widget");
},
},
{
desc: "Add a widget via the API with showInPrivateBrowsing set to true, " +
"and ensure that it appears in pre-existing or newly created " +
"private browsing windows.",
run: function() {
let plain = yield openAndLoadWindow();
let private = yield openAndLoadWindow({private: true});
// Add a widget via the API with showInPrivateBrowsing set to true,
// and ensure that it appears in pre-existing or newly created
// private browsing windows.
add_task(function() {
let plain1 = yield openAndLoadWindow();
let private1 = yield openAndLoadWindow({private: true});
CustomizableUI.createWidget({
id: kWidgetId,
removable: true,
showInPrivateBrowsing: true
});
CustomizableUI.addWidgetToArea(kWidgetId,
CustomizableUI.AREA_NAVBAR);
assertWidgetExists(plain, true);
assertWidgetExists(private, true);
CustomizableUI.createWidget({
id: kWidgetId,
removable: true,
showInPrivateBrowsing: true
});
CustomizableUI.addWidgetToArea(kWidgetId,
CustomizableUI.AREA_NAVBAR);
assertWidgetExists(plain1, true);
assertWidgetExists(private1, true);
// Now open up some new windows. The widget should exist in the new
// plain window, but not the new private window.
let plain2 = yield openAndLoadWindow();
let private2 = yield openAndLoadWindow({private: true});
// Now open up some new windows. The widget should exist in the new
// plain window, but not the new private window.
let plain2 = yield openAndLoadWindow();
let private2 = yield openAndLoadWindow({private: true});
assertWidgetExists(plain2, true);
assertWidgetExists(private2, true);
assertWidgetExists(plain2, true);
assertWidgetExists(private2, true);
// Try moving the widget around and make sure it doesn't get added
// to the private windows. We'll start by appending it to the tabstrip.
CustomizableUI.addWidgetToArea(kWidgetId,
CustomizableUI.AREA_TABSTRIP);
assertWidgetExists(plain, true);
assertWidgetExists(plain2, true);
assertWidgetExists(private, true);
assertWidgetExists(private2, true);
// Try moving the widget around and make sure it doesn't get added
// to the private windows. We'll start by appending it to the tabstrip.
CustomizableUI.addWidgetToArea(kWidgetId,
CustomizableUI.AREA_TABSTRIP);
assertWidgetExists(plain1, true);
assertWidgetExists(plain2, true);
assertWidgetExists(private1, true);
assertWidgetExists(private2, true);
// And then move it to the beginning of the tabstrip.
CustomizableUI.moveWidgetWithinArea(kWidgetId, 0);
assertWidgetExists(plain, true);
assertWidgetExists(plain2, true);
assertWidgetExists(private, true);
assertWidgetExists(private2, true);
// And then move it to the beginning of the tabstrip.
CustomizableUI.moveWidgetWithinArea(kWidgetId, 0);
assertWidgetExists(plain1, true);
assertWidgetExists(plain2, true);
assertWidgetExists(private1, true);
assertWidgetExists(private2, true);
CustomizableUI.removeWidgetFromArea("some-widget");
assertWidgetExists(plain, false);
assertWidgetExists(plain2, false);
assertWidgetExists(private, false);
assertWidgetExists(private2, false);
CustomizableUI.removeWidgetFromArea("some-widget");
assertWidgetExists(plain1, false);
assertWidgetExists(plain2, false);
assertWidgetExists(private1, false);
assertWidgetExists(private2, false);
plain.close();
plain2.close();
private.close();
private2.close();
plain1.close();
plain2.close();
private1.close();
private2.close();
CustomizableUI.destroyWidget("some-widget");
},
}
];
CustomizableUI.destroyWidget("some-widget");
});
function asyncCleanup() {
add_task(function asyncCleanup() {
yield resetCustomization();
}
function test() {
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,55 +2,45 @@
* 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 kButtonId = "test-886323-removable-moved-node";
const kLazyAreaId = "test-886323-lazy-area-for-removability-testing";
let gNavBar = document.getElementById(CustomizableUI.AREA_NAVBAR);
let gLazyArea;
let gTests = [
{
desc: "Removable nodes shouldn't be moved by buildArea",
setup: function() {
let dummyBtn = createDummyXULButton(kButtonId, "Dummy");
dummyBtn.setAttribute("removable", "true");
gNavBar.customizationTarget.appendChild(dummyBtn);
let popupSet = document.getElementById("mainPopupSet");
gLazyArea = document.createElementNS(kNSXUL, "panel");
gLazyArea.id = kLazyAreaId;
gLazyArea.setAttribute("hidden", "true");
popupSet.appendChild(gLazyArea);
CustomizableUI.registerArea(kLazyAreaId, {
type: CustomizableUI.TYPE_MENU_PANEL,
defaultPlacements: []
});
},
run: function() {
CustomizableUI.addWidgetToArea(kButtonId, kLazyAreaId);
assertAreaPlacements(kLazyAreaId, [kButtonId],
"Placements should have changed because widget is removable.");
let btn = document.getElementById(kButtonId);
btn.setAttribute("removable", "false");
gLazyArea.customizationTarget = gLazyArea;
CustomizableUI.registerToolbarNode(gLazyArea, []);
assertAreaPlacements(kLazyAreaId, [], "Placements should no longer include widget.");
is(btn.parentNode.id, gNavBar.customizationTarget.id,
"Button shouldn't actually have moved as it's not removable");
},
teardown: function() {
let btn = document.getElementById(kButtonId);
if (btn) btn.remove();
CustomizableUI.removeWidgetFromArea(kButtonId);
CustomizableUI.unregisterArea(kLazyAreaId);
gLazyArea.remove();
}
}
];
function asyncCleanup() {
// Removable nodes shouldn't be moved by buildArea
add_task(function() {
let dummyBtn = createDummyXULButton(kButtonId, "Dummy");
dummyBtn.setAttribute("removable", "true");
gNavBar.customizationTarget.appendChild(dummyBtn);
let popupSet = document.getElementById("mainPopupSet");
gLazyArea = document.createElementNS(kNSXUL, "panel");
gLazyArea.id = kLazyAreaId;
gLazyArea.setAttribute("hidden", "true");
popupSet.appendChild(gLazyArea);
CustomizableUI.registerArea(kLazyAreaId, {
type: CustomizableUI.TYPE_MENU_PANEL,
defaultPlacements: []
});
CustomizableUI.addWidgetToArea(kButtonId, kLazyAreaId);
assertAreaPlacements(kLazyAreaId, [kButtonId],
"Placements should have changed because widget is removable.");
let btn = document.getElementById(kButtonId);
btn.setAttribute("removable", "false");
gLazyArea.customizationTarget = gLazyArea;
CustomizableUI.registerToolbarNode(gLazyArea, []);
assertAreaPlacements(kLazyAreaId, [], "Placements should no longer include widget.");
is(btn.parentNode.id, gNavBar.customizationTarget.id,
"Button shouldn't actually have moved as it's not removable");
let btn = document.getElementById(kButtonId);
if (btn) btn.remove();
CustomizableUI.removeWidgetFromArea(kButtonId);
CustomizableUI.unregisterArea(kLazyAreaId);
gLazyArea.remove();
});
add_task(function asyncCleanup() {
yield resetCustomization();
}
function test() {
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,83 +2,74 @@
* 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/. */
let navbar = document.getElementById("nav-bar")
"use strict";
let navbar = document.getElementById("nav-bar");
let navbarCT = navbar.customizationTarget;
let overflowPanelList = document.getElementById("widget-overflow-list");
let gTests = [
{
desc: "Reading currentset",
run: function() {
let nodeIds = [];
for (let node of navbarCT.childNodes) {
if (node.getAttribute("skipintoolbarset") != "true") {
nodeIds.push(node.id);
}
}
for (let node of overflowPanelList.childNodes) {
if (node.getAttribute("skipintoolbarset") != "true") {
nodeIds.push(node.id);
}
}
let currentSet = navbar.currentSet;
is(currentSet.split(',').length, nodeIds.length, "Should be just as many nodes as there are.");
is(currentSet, nodeIds.join(','), "Current set and node IDs should match.");
}
},
{
desc: "Insert, then remove items",
run: function() {
let currentSet = navbar.currentSet;
let newCurrentSet = currentSet.replace('home-button', 'feed-button,sync-button,home-button');
navbar.currentSet = newCurrentSet;
is(newCurrentSet, navbar.currentSet, "Current set should match expected current set.");
let feedBtn = document.getElementById("feed-button");
let syncBtn = document.getElementById("sync-button");
ok(feedBtn, "Feed button should have been added.");
ok(syncBtn, "Sync button should have been added.");
if (feedBtn && syncBtn) {
let feedParent = feedBtn.parentNode;
let syncParent = syncBtn.parentNode;
ok(feedParent == navbarCT || feedParent == overflowPanelList,
"Feed button should be in navbar or overflow");
ok(syncParent == navbarCT || syncParent == overflowPanelList,
"Feed button should be in navbar or overflow");
is(feedBtn.nextElementSibling, syncBtn, "Feed button should be next to sync button.");
let homeBtn = document.getElementById("home-button");
is(syncBtn.nextElementSibling, homeBtn, "Sync button should be next to home button.");
}
navbar.currentSet = currentSet;
is(currentSet, navbar.currentSet, "Should be able to remove the added items.");
}
},
{
desc: "Simultaneous insert/remove:",
run: function() {
let currentSet = navbar.currentSet;
let newCurrentSet = currentSet.replace('home-button', 'feed-button');
navbar.currentSet = newCurrentSet;
is(newCurrentSet, navbar.currentSet, "Current set should match expected current set.");
let feedBtn = document.getElementById("feed-button");
ok(feedBtn, "Feed button should have been added.");
let homeBtn = document.getElementById("home-button");
ok(!homeBtn, "Home button should have been removed.");
if (feedBtn) {
let feedParent = feedBtn.parentNode;
ok(feedParent == navbarCT || feedParent == overflowPanelList,
"Feed button should be in navbar or overflow");
}
navbar.currentSet = currentSet;
is(currentSet, navbar.currentSet, "Should be able to return to original state.");
// Reading currentset
add_task(function() {
let nodeIds = [];
for (let node of navbarCT.childNodes) {
if (node.getAttribute("skipintoolbarset") != "true") {
nodeIds.push(node.id);
}
}
];
for (let node of overflowPanelList.childNodes) {
if (node.getAttribute("skipintoolbarset") != "true") {
nodeIds.push(node.id);
}
}
let currentSet = navbar.currentSet;
is(currentSet.split(',').length, nodeIds.length, "Should be just as many nodes as there are.");
is(currentSet, nodeIds.join(','), "Current set and node IDs should match.");
});
function asyncCleanup() {
// Insert, then remove items
add_task(function() {
let currentSet = navbar.currentSet;
let newCurrentSet = currentSet.replace('home-button', 'feed-button,sync-button,home-button');
navbar.currentSet = newCurrentSet;
is(newCurrentSet, navbar.currentSet, "Current set should match expected current set.");
let feedBtn = document.getElementById("feed-button");
let syncBtn = document.getElementById("sync-button");
ok(feedBtn, "Feed button should have been added.");
ok(syncBtn, "Sync button should have been added.");
if (feedBtn && syncBtn) {
let feedParent = feedBtn.parentNode;
let syncParent = syncBtn.parentNode;
ok(feedParent == navbarCT || feedParent == overflowPanelList,
"Feed button should be in navbar or overflow");
ok(syncParent == navbarCT || syncParent == overflowPanelList,
"Feed button should be in navbar or overflow");
is(feedBtn.nextElementSibling, syncBtn, "Feed button should be next to sync button.");
let homeBtn = document.getElementById("home-button");
is(syncBtn.nextElementSibling, homeBtn, "Sync button should be next to home button.");
}
navbar.currentSet = currentSet;
is(currentSet, navbar.currentSet, "Should be able to remove the added items.");
});
// Simultaneous insert/remove:
add_task(function() {
let currentSet = navbar.currentSet;
let newCurrentSet = currentSet.replace('home-button', 'feed-button');
navbar.currentSet = newCurrentSet;
is(newCurrentSet, navbar.currentSet, "Current set should match expected current set.");
let feedBtn = document.getElementById("feed-button");
ok(feedBtn, "Feed button should have been added.");
let homeBtn = document.getElementById("home-button");
ok(!homeBtn, "Home button should have been removed.");
if (feedBtn) {
let feedParent = feedBtn.parentNode;
ok(feedParent == navbarCT || feedParent == overflowPanelList,
"Feed button should be in navbar or overflow");
}
navbar.currentSet = currentSet;
is(currentSet, navbar.currentSet, "Should be able to return to original state.");
});
add_task(function asyncCleanup() {
yield resetCustomization();
}
function test() {
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,64 +2,55 @@
* 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/. */
let gTests = [
{
desc: "Adding, moving and removing items should update the relevant currentset attributes",
setup: function() {
let personalbar = document.getElementById(CustomizableUI.AREA_BOOKMARKS);
setToolbarVisibility(personalbar, true);
},
run: function() {
ok(CustomizableUI.inDefaultState, "Should be in the default state when we start");
"use strict";
let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
let personalbar = document.getElementById(CustomizableUI.AREA_BOOKMARKS);
let navbarCurrentset = navbar.getAttribute("currentset") || navbar.currentSet;
let personalbarCurrentset = personalbar.getAttribute("currentset") || personalbar.currentSet;
// Adding, moving and removing items should update the relevant currentset attributes
add_task(function() {
let personalbar = document.getElementById(CustomizableUI.AREA_BOOKMARKS);
setToolbarVisibility(personalbar, true);
ok(CustomizableUI.inDefaultState, "Should be in the default state when we start");
let otherWin = yield openAndLoadWindow();
let otherNavbar = otherWin.document.getElementById(CustomizableUI.AREA_NAVBAR);
let otherPersonalbar = otherWin.document.getElementById(CustomizableUI.AREA_BOOKMARKS);
let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
let personalbar = document.getElementById(CustomizableUI.AREA_BOOKMARKS);
let navbarCurrentset = navbar.getAttribute("currentset") || navbar.currentSet;
let personalbarCurrentset = personalbar.getAttribute("currentset") || personalbar.currentSet;
CustomizableUI.moveWidgetWithinArea("home-button", 0);
navbarCurrentset = "home-button," + navbarCurrentset.replace(",home-button", "");
is(navbar.getAttribute("currentset"), navbarCurrentset,
"Should have updated currentSet after move.");
is(otherNavbar.getAttribute("currentset"), navbarCurrentset,
"Should have updated other window's currentSet after move.");
let otherWin = yield openAndLoadWindow();
let otherNavbar = otherWin.document.getElementById(CustomizableUI.AREA_NAVBAR);
let otherPersonalbar = otherWin.document.getElementById(CustomizableUI.AREA_BOOKMARKS);
CustomizableUI.addWidgetToArea("home-button", CustomizableUI.AREA_BOOKMARKS);
navbarCurrentset = navbarCurrentset.replace("home-button,", "");
personalbarCurrentset = personalbarCurrentset + ",home-button";
is(navbar.getAttribute("currentset"), navbarCurrentset,
"Should have updated navbar currentSet after implied remove.");
is(otherNavbar.getAttribute("currentset"), navbarCurrentset,
"Should have updated other window's navbar currentSet after implied remove.");
is(personalbar.getAttribute("currentset"), personalbarCurrentset,
"Should have updated personalbar currentSet after add.");
is(otherPersonalbar.getAttribute("currentset"), personalbarCurrentset,
"Should have updated other window's personalbar currentSet after add.");
CustomizableUI.moveWidgetWithinArea("home-button", 0);
navbarCurrentset = "home-button," + navbarCurrentset.replace(",home-button", "");
is(navbar.getAttribute("currentset"), navbarCurrentset,
"Should have updated currentSet after move.");
is(otherNavbar.getAttribute("currentset"), navbarCurrentset,
"Should have updated other window's currentSet after move.");
CustomizableUI.removeWidgetFromArea("home-button");
personalbarCurrentset = personalbarCurrentset.replace(",home-button", "");
is(personalbar.getAttribute("currentset"), personalbarCurrentset,
"Should have updated currentSet after remove.");
is(otherPersonalbar.getAttribute("currentset"), personalbarCurrentset,
"Should have updated other window's currentSet after remove.");
CustomizableUI.addWidgetToArea("home-button", CustomizableUI.AREA_BOOKMARKS);
navbarCurrentset = navbarCurrentset.replace("home-button,", "");
personalbarCurrentset = personalbarCurrentset + ",home-button";
is(navbar.getAttribute("currentset"), navbarCurrentset,
"Should have updated navbar currentSet after implied remove.");
is(otherNavbar.getAttribute("currentset"), navbarCurrentset,
"Should have updated other window's navbar currentSet after implied remove.");
is(personalbar.getAttribute("currentset"), personalbarCurrentset,
"Should have updated personalbar currentSet after add.");
is(otherPersonalbar.getAttribute("currentset"), personalbarCurrentset,
"Should have updated other window's personalbar currentSet after add.");
otherWin.close();
// Reset in asyncCleanup will put our button back for us.
}
}
];
CustomizableUI.removeWidgetFromArea("home-button");
personalbarCurrentset = personalbarCurrentset.replace(",home-button", "");
is(personalbar.getAttribute("currentset"), personalbarCurrentset,
"Should have updated currentSet after remove.");
is(otherPersonalbar.getAttribute("currentset"), personalbarCurrentset,
"Should have updated other window's currentSet after remove.");
function asyncCleanup() {
otherWin.close();
// Reset in asyncCleanup will put our button back for us.
});
add_task(function asyncCleanup() {
let personalbar = document.getElementById(CustomizableUI.AREA_BOOKMARKS);
setToolbarVisibility(personalbar, false);
yield resetCustomization();
}
function test() {
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,171 +2,161 @@
* 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/. */
let gTests = [
{
desc: "One orphaned item should have two placeholders next to it.",
setup: startCustomizing,
run: function() {
let btn = document.getElementById("developer-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
"use strict";
if (!isInWin8()) {
placements = placements.concat(["developer-button"]);
simulateItemDrag(btn, panel);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
} else {
ok(CustomizableUI.inDefaultState, "Should be in default state.");
}
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placements);
is(getVisiblePlaceholderCount(panel), 2, "Should only have 2 visible placeholders before exiting");
// One orphaned item should have two placeholders next to it.
add_task(function() {
yield startCustomizing();
let btn = document.getElementById("developer-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
yield endCustomizing();
yield startCustomizing();
is(getVisiblePlaceholderCount(panel), 2, "Should only have 2 visible placeholders after re-entering");
if (!isInWin8()) {
placements = placements.concat(["developer-button"]);
simulateItemDrag(btn, panel);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
} else {
ok(CustomizableUI.inDefaultState, "Should be in default state.");
}
if (!isInWin8()) {
let palette = document.getElementById("customization-palette");
simulateItemDrag(btn, palette);
}
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
},
},
{
desc: "Two orphaned items should have one placeholder next to them (case 1).",
setup: startCustomizing,
run: function() {
let btn = document.getElementById("developer-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placements);
is(getVisiblePlaceholderCount(panel), 2, "Should only have 2 visible placeholders before exiting");
let placementsAfterAppend = placements.concat(["developer-button"]);
simulateItemDrag(btn, panel);
yield endCustomizing();
yield startCustomizing();
is(getVisiblePlaceholderCount(panel), 2, "Should only have 2 visible placeholders after re-entering");
if (!isInWin8()) {
placementsAfterAppend = placementsAfterAppend.concat(["sync-button"]);
btn = document.getElementById("sync-button");
simulateItemDrag(btn, panel);
}
if (!isInWin8()) {
let palette = document.getElementById("customization-palette");
simulateItemDrag(btn, palette);
}
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
});
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholders before exiting");
// Two orphaned items should have one placeholder next to them (case 1).
add_task(function() {
yield startCustomizing();
let btn = document.getElementById("developer-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
yield endCustomizing();
yield startCustomizing();
is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholders after re-entering");
let placementsAfterAppend = placements.concat(["developer-button"]);
simulateItemDrag(btn, panel);
let palette = document.getElementById("customization-palette");
simulateItemDrag(btn, palette);
if (!isInWin8()) {
placementsAfterAppend = placementsAfterAppend.concat(["sync-button"]);
btn = document.getElementById("sync-button");
simulateItemDrag(btn, panel);
}
if (!isInWin8()) {
btn = document.getElementById("developer-button");
simulateItemDrag(btn, palette);
}
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
},
},
{
desc: "Two orphaned items should have one placeholder next to them (case 2).",
setup: startCustomizing,
run: function() {
let btn = document.getElementById("add-ons-button");
let btn2 = document.getElementById("switch-to-metro-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let palette = document.getElementById("customization-palette");
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholders before exiting");
let placementsAfterAppend = placements.filter(p => p != btn.id);
simulateItemDrag(btn, palette);
yield endCustomizing();
yield startCustomizing();
is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholders after re-entering");
if (isInWin8()) {
placementsAfterAppend = placementsAfterAppend.filter(p => p != btn2.id);
simulateItemDrag(btn2, palette);
}
let palette = document.getElementById("customization-palette");
simulateItemDrag(btn, palette);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholders before exiting");
if (!isInWin8()) {
btn = document.getElementById("developer-button");
simulateItemDrag(btn, palette);
}
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
});
yield endCustomizing();
yield startCustomizing();
is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholders after re-entering");
// Two orphaned items should have one placeholder next to them (case 2).
add_task(function() {
yield startCustomizing();
let btn = document.getElementById("add-ons-button");
let btn2 = document.getElementById("switch-to-metro-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let palette = document.getElementById("customization-palette");
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
simulateItemDrag(btn, panel);
let placementsAfterAppend = placements.filter(p => p != btn.id);
simulateItemDrag(btn, palette);
if (isInWin8()) {
simulateItemDrag(btn2, panel);
}
if (isInWin8()) {
placementsAfterAppend = placementsAfterAppend.filter(p => p != btn2.id);
simulateItemDrag(btn2, palette);
}
assertAreaPlacements(CustomizableUI.AREA_PANEL, placements);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
},
},
{
desc: "A wide widget at the bottom of the panel should have three placeholders after it.",
setup: startCustomizing,
run: function() {
let btn = document.getElementById("edit-controls");
let metroBtn = document.getElementById("switch-to-metro-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let palette = document.getElementById("customization-palette");
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholders before exiting");
if (isInWin8()) {
// Remove switch-to-metro-button
placements.pop();
simulateItemDrag(metroBtn, palette);
}
yield endCustomizing();
yield startCustomizing();
is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholders after re-entering");
let placementsAfterAppend = placements.concat([placements.shift()]);
simulateItemDrag(btn, panel);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
is(getVisiblePlaceholderCount(panel), 3, "Should have 3 visible placeholders before exiting");
simulateItemDrag(btn, panel);
yield endCustomizing();
yield startCustomizing();
is(getVisiblePlaceholderCount(panel), 3, "Should have 3 visible placeholders after re-entering");
if (isInWin8()) {
simulateItemDrag(btn2, panel);
}
if (isInWin8()) {
simulateItemDrag(metroBtn, panel);
}
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(btn, zoomControls);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
},
},
{
desc: "The default placements should have three placeholders at the bottom (or 2 in win8).",
setup: startCustomizing,
run: function() {
let numPlaceholders = isInWin8() ? 2 : 3;
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
ok(CustomizableUI.inDefaultState, "Should be in default state.");
is(getVisiblePlaceholderCount(panel), numPlaceholders, "Should have " + numPlaceholders + " visible placeholders before exiting");
assertAreaPlacements(CustomizableUI.AREA_PANEL, placements);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
});
yield endCustomizing();
yield startCustomizing();
is(getVisiblePlaceholderCount(panel), numPlaceholders, "Should have " + numPlaceholders + " visible placeholders after re-entering");
// A wide widget at the bottom of the panel should have three placeholders after it.
add_task(function() {
yield startCustomizing();
let btn = document.getElementById("edit-controls");
let metroBtn = document.getElementById("switch-to-metro-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let palette = document.getElementById("customization-palette");
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
},
},
];
if (isInWin8()) {
// Remove switch-to-metro-button
placements.pop();
simulateItemDrag(metroBtn, palette);
}
function asyncCleanup() {
let placementsAfterAppend = placements.concat([placements.shift()]);
simulateItemDrag(btn, panel);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
is(getVisiblePlaceholderCount(panel), 3, "Should have 3 visible placeholders before exiting");
yield endCustomizing();
yield startCustomizing();
is(getVisiblePlaceholderCount(panel), 3, "Should have 3 visible placeholders after re-entering");
if (isInWin8()) {
simulateItemDrag(metroBtn, panel);
}
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(btn, zoomControls);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
});
// The default placements should have three placeholders at the bottom (or 2 in win8).
add_task(function() {
yield startCustomizing();
let numPlaceholders = isInWin8() ? 2 : 3;
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
ok(CustomizableUI.inDefaultState, "Should be in default state.");
is(getVisiblePlaceholderCount(panel), numPlaceholders, "Should have " + numPlaceholders + " visible placeholders before exiting");
yield endCustomizing();
yield startCustomizing();
is(getVisiblePlaceholderCount(panel), numPlaceholders, "Should have " + numPlaceholders + " visible placeholders after re-entering");
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
});
add_task(function asyncCleanup() {
yield endCustomizing();
Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck");
yield resetCustomization();
}
function test() {
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});
function getVisiblePlaceholderCount(aPanel) {
let visiblePlaceholders = aPanel.querySelectorAll(".panel-customization-placeholder:not([hidden=true])");

Просмотреть файл

@ -2,52 +2,51 @@
* 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 kLazyAreaId = "test-890262-lazy-area";
const kWidget1Id = "test-890262-widget1";
const kWidget2Id = "test-890262-widget2";
let gTests = [
{
desc: "Destroying a widget after defaulting it to a non-legacy area should work.",
run: function() {
CustomizableUI.createWidget({
id: kWidget1Id,
removable: true,
defaultArea: kLazyAreaId
});
let noError = true;
try {
CustomizableUI.destroyWidget(kWidget1Id);
} catch (ex) {
Cu.reportError(ex);
noError = false;
}
ok(noError, "Shouldn't throw an exception for a widget that was created in a not-yet-constructed area");
}
},
{
desc: "Destroying a widget after moving it to a non-legacy area should work.",
run: function() {
CustomizableUI.createWidget({
id: kWidget2Id,
removable: true,
defaultArea: CustomizableUI.AREA_NAVBAR
});
setupArea();
CustomizableUI.addWidgetToArea(kWidget2Id, kLazyAreaId);
let noError = true;
try {
CustomizableUI.destroyWidget(kWidget2Id);
} catch (ex) {
Cu.reportError(ex);
noError = false;
}
ok(noError, "Shouldn't throw an exception for a widget that was added to a not-yet-constructed area");
}
// Destroying a widget after defaulting it to a non-legacy area should work.
add_task(function() {
CustomizableUI.createWidget({
id: kWidget1Id,
removable: true,
defaultArea: kLazyAreaId
});
let noError = true;
try {
CustomizableUI.destroyWidget(kWidget1Id);
} catch (ex) {
Cu.reportError(ex);
noError = false;
}
];
ok(noError, "Shouldn't throw an exception for a widget that was created in a not-yet-constructed area");
});
function asyncCleanup() {
// Destroying a widget after moving it to a non-legacy area should work.
add_task(function() {
CustomizableUI.createWidget({
id: kWidget2Id,
removable: true,
defaultArea: CustomizableUI.AREA_NAVBAR
});
CustomizableUI.addWidgetToArea(kWidget2Id, kLazyAreaId);
let noError = true;
try {
CustomizableUI.destroyWidget(kWidget2Id);
} catch (ex) {
Cu.reportError(ex);
noError = false;
}
ok(noError, "Shouldn't throw an exception for a widget that was added to a not-yet-constructed area");
});
add_task(function asyncCleanup() {
let lazyArea = document.getElementById(kLazyAreaId);
if (lazyArea) {
lazyArea.remove();
@ -56,7 +55,7 @@ function asyncCleanup() {
CustomizableUI.unregisterArea(kLazyAreaId);
} catch (ex) {} // If we didn't register successfully for some reason
yield resetCustomization();
}
});
function setupArea() {
let lazyArea = document.createElementNS(kNSXUL, "hbox");
@ -67,9 +66,3 @@ function setupArea() {
defaultPlacements: []
});
}
function test() {
waitForExplicitFinish();
setupArea();
runTests(gTests, asyncCleanup);
}

Просмотреть файл

@ -2,36 +2,29 @@
* 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 kWidgetId = "test-892955-remove-widget";
let gTests = [
{
desc: "Removing a destroyed widget should work.",
run: function() {
let widgetSpec = {
id: kWidgetId,
defaultArea: CustomizableUI.AREA_NAVBAR
};
// Removing a destroyed widget should work.
add_task(function() {
let widgetSpec = {
id: kWidgetId,
defaultArea: CustomizableUI.AREA_NAVBAR
};
CustomizableUI.createWidget(widgetSpec);
CustomizableUI.destroyWidget(kWidgetId);
let noError = true;
try {
CustomizableUI.removeWidgetFromArea(kWidgetId);
} catch (ex) {
noError = false;
Cu.reportError(ex);
}
ok(noError, "Shouldn't throw an error removing a destroyed widget.");
}
CustomizableUI.createWidget(widgetSpec);
CustomizableUI.destroyWidget(kWidgetId);
let noError = true;
try {
CustomizableUI.removeWidgetFromArea(kWidgetId);
} catch (ex) {
noError = false;
Cu.reportError(ex);
}
];
ok(noError, "Shouldn't throw an error removing a destroyed widget.");
});
function asyncCleanup() {
add_task(function asyncCleanup() {
yield resetCustomization();
}
function test() {
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,30 +2,23 @@
* 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 kWidgetId = "test-892956-destroyWidget-defaultPlacement";
let gTests = [
{
desc: "destroyWidget should clean up defaultPlacements if the widget had a defaultArea",
run: function() {
ok(CustomizableUI.inDefaultState, "Should be in the default state when we start");
// destroyWidget should clean up defaultPlacements if the widget had a defaultArea
add_task(function() {
ok(CustomizableUI.inDefaultState, "Should be in the default state when we start");
let widgetSpec = {
id: kWidgetId,
defaultArea: CustomizableUI.AREA_NAVBAR
};
CustomizableUI.createWidget(widgetSpec);
CustomizableUI.destroyWidget(kWidgetId);
ok(CustomizableUI.inDefaultState, "Should be in the default state when we finish");
}
}
];
let widgetSpec = {
id: kWidgetId,
defaultArea: CustomizableUI.AREA_NAVBAR
};
CustomizableUI.createWidget(widgetSpec);
CustomizableUI.destroyWidget(kWidgetId);
ok(CustomizableUI.inDefaultState, "Should be in the default state when we finish");
});
function asyncCleanup() {
add_task(function asyncCleanup() {
yield resetCustomization();
}
function test() {
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,107 +2,89 @@
* 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/. */
let gTests = [
{
desc: "Ctrl+K should open the menu panel and focus the search bar if the search bar is in the panel.",
run: function() {
let searchbar = document.getElementById("searchbar");
gCustomizeMode.addToPanel(searchbar);
let placement = CustomizableUI.getPlacementOfWidget("search-container");
is(placement.area, CustomizableUI.AREA_PANEL, "Should be in panel");
"use strict";
let shownPanelPromise = promisePanelShown(window);
sendWebSearchKeyCommand();
yield shownPanelPromise;
// Ctrl+K should open the menu panel and focus the search bar if the search bar is in the panel.
add_task(function() {
let searchbar = document.getElementById("searchbar");
gCustomizeMode.addToPanel(searchbar);
let placement = CustomizableUI.getPlacementOfWidget("search-container");
is(placement.area, CustomizableUI.AREA_PANEL, "Should be in panel");
logActiveElement();
is(document.activeElement, searchbar.textbox.inputField, "The searchbar should be focused");
let shownPanelPromise = promisePanelShown(window);
sendWebSearchKeyCommand();
yield shownPanelPromise;
let hiddenPanelPromise = promisePanelHidden(window);
EventUtils.synthesizeKey("VK_ESCAPE", {});
yield hiddenPanelPromise;
},
teardown: function() {
CustomizableUI.reset();
}
},
{
desc: "Ctrl+K should give focus to the searchbar when the searchbar is in the menupanel and the panel is already opened.",
run: function() {
let searchbar = document.getElementById("searchbar");
gCustomizeMode.addToPanel(searchbar);
let placement = CustomizableUI.getPlacementOfWidget("search-container");
is(placement.area, CustomizableUI.AREA_PANEL, "Should be in panel");
logActiveElement();
is(document.activeElement, searchbar.textbox.inputField, "The searchbar should be focused");
let shownPanelPromise = promisePanelShown(window);
PanelUI.toggle({type: "command"});
yield shownPanelPromise;
let hiddenPanelPromise = promisePanelHidden(window);
EventUtils.synthesizeKey("VK_ESCAPE", {});
yield hiddenPanelPromise;
CustomizableUI.reset();
});
sendWebSearchKeyCommand();
logActiveElement();
is(document.activeElement, searchbar.textbox.inputField, "The searchbar should be focused");
// Ctrl+K should give focus to the searchbar when the searchbar is in the menupanel and the panel is already opened.
add_task(function() {
let searchbar = document.getElementById("searchbar");
gCustomizeMode.addToPanel(searchbar);
let placement = CustomizableUI.getPlacementOfWidget("search-container");
is(placement.area, CustomizableUI.AREA_PANEL, "Should be in panel");
let hiddenPanelPromise = promisePanelHidden(window);
EventUtils.synthesizeKey("VK_ESCAPE", {});
yield hiddenPanelPromise;
},
teardown: function() {
CustomizableUI.reset();
}
},
{
desc: "Ctrl+K should open the overflow panel and focus the search bar if the search bar is overflowed.",
setup: function() {
this.originalWindowWidth = window.outerWidth;
let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
ok(CustomizableUI.inDefaultState, "Should start in default state.");
let shownPanelPromise = promisePanelShown(window);
PanelUI.toggle({type: "command"});
yield shownPanelPromise;
window.resizeTo(480, window.outerHeight);
yield waitForCondition(() => navbar.hasAttribute("overflowing"));
ok(!navbar.querySelector("#search-container"), "Search container should be overflowing");
},
run: function() {
let searchbar = document.getElementById("searchbar");
sendWebSearchKeyCommand();
logActiveElement();
is(document.activeElement, searchbar.textbox.inputField, "The searchbar should be focused");
let shownPanelPromise = promiseOverflowShown(window);
sendWebSearchKeyCommand();
yield shownPanelPromise;
let hiddenPanelPromise = promisePanelHidden(window);
EventUtils.synthesizeKey("VK_ESCAPE", {});
yield hiddenPanelPromise;
CustomizableUI.reset();
});
let chevron = document.getElementById("nav-bar-overflow-button");
yield waitForCondition(function() chevron.open);
logActiveElement();
is(document.activeElement, searchbar.textbox.inputField, "The searchbar should be focused");
// Ctrl+K should open the overflow panel and focus the search bar if the search bar is overflowed.
add_task(function() {
this.originalWindowWidth = window.outerWidth;
let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
ok(CustomizableUI.inDefaultState, "Should start in default state.");
let hiddenPanelPromise = promiseOverflowHidden(window);
EventUtils.synthesizeKey("VK_ESCAPE", {});
yield hiddenPanelPromise;
},
teardown: function() {
let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
window.resizeTo(this.originalWindowWidth, window.outerHeight);
yield waitForCondition(() => !navbar.hasAttribute("overflowing"));
ok(!navbar.hasAttribute("overflowing"), "Should not have an overflowing toolbar.");
}
},
{
desc: "Ctrl+K should focus the search bar if it is in the navbar and not overflowing.",
run: function() {
let searchbar = document.getElementById("searchbar");
let placement = CustomizableUI.getPlacementOfWidget("search-container");
is(placement.area, CustomizableUI.AREA_NAVBAR, "Should be in nav-bar");
window.resizeTo(480, window.outerHeight);
yield waitForCondition(() => navbar.hasAttribute("overflowing"));
ok(!navbar.querySelector("#search-container"), "Search container should be overflowing");
let searchbar = document.getElementById("searchbar");
sendWebSearchKeyCommand();
logActiveElement();
is(document.activeElement, searchbar.textbox.inputField, "The searchbar should be focused");
},
},
];
let shownPanelPromise = promiseOverflowShown(window);
sendWebSearchKeyCommand();
yield shownPanelPromise;
function test() {
waitForExplicitFinish();
runTests(gTests);
}
let chevron = document.getElementById("nav-bar-overflow-button");
yield waitForCondition(function() chevron.open);
logActiveElement();
is(document.activeElement, searchbar.textbox.inputField, "The searchbar should be focused");
let hiddenPanelPromise = promiseOverflowHidden(window);
EventUtils.synthesizeKey("VK_ESCAPE", {});
yield hiddenPanelPromise;
let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
window.resizeTo(this.originalWindowWidth, window.outerHeight);
yield waitForCondition(() => !navbar.hasAttribute("overflowing"));
ok(!navbar.hasAttribute("overflowing"), "Should not have an overflowing toolbar.");
});
// Ctrl+K should focus the search bar if it is in the navbar and not overflowing.
add_task(function() {
let searchbar = document.getElementById("searchbar");
let placement = CustomizableUI.getPlacementOfWidget("search-container");
is(placement.area, CustomizableUI.AREA_NAVBAR, "Should be in nav-bar");
sendWebSearchKeyCommand();
logActiveElement();
is(document.activeElement, searchbar.textbox.inputField, "The searchbar should be focused");
});
function sendWebSearchKeyCommand() {
if (Services.appinfo.OS === "Darwin")

Просмотреть файл

@ -2,37 +2,30 @@
* 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/. */
let gTests = [
{
desc: "Resize to a small window, open a new window, check that new window handles overflow properly",
run: function() {
let originalWindowWidth = window.outerWidth;
let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
let oldChildCount = navbar.customizationTarget.childElementCount;
window.resizeTo(400, window.outerHeight);
yield waitForCondition(() => navbar.hasAttribute("overflowing"));
ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar.");
"use strict";
ok(navbar.customizationTarget.childElementCount < oldChildCount, "Should have fewer children.");
let newWindow = yield openAndLoadWindow();
let otherNavBar = newWindow.document.getElementById(CustomizableUI.AREA_NAVBAR);
yield waitForCondition(() => otherNavBar.hasAttribute("overflowing"));
ok(otherNavBar.hasAttribute("overflowing"), "Other window should have an overflowing toolbar.");
newWindow.close();
// Resize to a small window, open a new window, check that new window handles overflow properly
add_task(function() {
let originalWindowWidth = window.outerWidth;
let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
let oldChildCount = navbar.customizationTarget.childElementCount;
window.resizeTo(400, window.outerHeight);
yield waitForCondition(() => navbar.hasAttribute("overflowing"));
ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar.");
window.resizeTo(originalWindowWidth, window.outerHeight);
yield waitForCondition(() => !navbar.hasAttribute("overflowing"));
ok(!navbar.hasAttribute("overflowing"), "Should no longer have an overflowing toolbar.");
}
}
];
ok(navbar.customizationTarget.childElementCount < oldChildCount, "Should have fewer children.");
let newWindow = yield openAndLoadWindow();
let otherNavBar = newWindow.document.getElementById(CustomizableUI.AREA_NAVBAR);
yield waitForCondition(() => otherNavBar.hasAttribute("overflowing"));
ok(otherNavBar.hasAttribute("overflowing"), "Other window should have an overflowing toolbar.");
newWindow.close();
function asyncCleanup() {
window.resizeTo(originalWindowWidth, window.outerHeight);
yield waitForCondition(() => !navbar.hasAttribute("overflowing"));
ok(!navbar.hasAttribute("overflowing"), "Should no longer have an overflowing toolbar.");
});
add_task(function asyncCleanup() {
yield resetCustomization();
}
function test() {
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,61 +2,54 @@
* 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";
let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
let gTests = [
{
desc: "Resize to a small window, resize back, shouldn't affect currentSet",
run: function() {
let originalWindowWidth = window.outerWidth;
let oldCurrentSet = navbar.currentSet;
ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
ok(CustomizableUI.inDefaultState, "Should start in default state.");
let oldChildCount = navbar.customizationTarget.childElementCount;
window.resizeTo(400, window.outerHeight);
yield waitForCondition(() => navbar.hasAttribute("overflowing"));
ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar.");
is(navbar.currentSet, oldCurrentSet, "Currentset should be the same when overflowing.");
ok(CustomizableUI.inDefaultState, "Should still be in default state when overflowing.");
ok(navbar.customizationTarget.childElementCount < oldChildCount, "Should have fewer children.");
window.resizeTo(originalWindowWidth, window.outerHeight);
yield waitForCondition(() => !navbar.hasAttribute("overflowing"));
ok(!navbar.hasAttribute("overflowing"), "Should no longer have an overflowing toolbar.");
is(navbar.currentSet, oldCurrentSet, "Currentset should still be the same now we're no longer overflowing.");
ok(CustomizableUI.inDefaultState, "Should still be in default state now we're no longer overflowing.");
// Verify actual physical placements match those of the placement array:
let placementCounter = 0;
let placements = CustomizableUI.getWidgetIdsInArea(CustomizableUI.AREA_NAVBAR);
for (let node of navbar.customizationTarget.childNodes) {
if (node.getAttribute("skipintoolbarset") == "true") {
continue;
}
is(placements[placementCounter++], node.id, "Nodes should match after overflow");
}
is(placements.length, placementCounter, "Should have as many nodes as expected");
is(navbar.customizationTarget.childElementCount, oldChildCount, "Number of nodes should match");
}
},
{
desc: "Enter and exit customization mode, check that currentSet works",
run: function() {
let oldCurrentSet = navbar.currentSet;
ok(CustomizableUI.inDefaultState, "Should start in default state.");
yield startCustomizing();
ok(CustomizableUI.inDefaultState, "Should be in default state in customization mode.");
is(navbar.currentSet, oldCurrentSet, "Currentset should be the same in customization mode.");
yield endCustomizing();
ok(CustomizableUI.inDefaultState, "Should be in default state after customization mode.");
is(navbar.currentSet, oldCurrentSet, "Currentset should be the same after customization mode.");
// Resize to a small window, resize back, shouldn't affect currentSet
add_task(function() {
let originalWindowWidth = window.outerWidth;
let oldCurrentSet = navbar.currentSet;
ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
ok(CustomizableUI.inDefaultState, "Should start in default state.");
let oldChildCount = navbar.customizationTarget.childElementCount;
window.resizeTo(400, window.outerHeight);
yield waitForCondition(() => navbar.hasAttribute("overflowing"));
ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar.");
is(navbar.currentSet, oldCurrentSet, "Currentset should be the same when overflowing.");
ok(CustomizableUI.inDefaultState, "Should still be in default state when overflowing.");
ok(navbar.customizationTarget.childElementCount < oldChildCount, "Should have fewer children.");
window.resizeTo(originalWindowWidth, window.outerHeight);
yield waitForCondition(() => !navbar.hasAttribute("overflowing"));
ok(!navbar.hasAttribute("overflowing"), "Should no longer have an overflowing toolbar.");
is(navbar.currentSet, oldCurrentSet, "Currentset should still be the same now we're no longer overflowing.");
ok(CustomizableUI.inDefaultState, "Should still be in default state now we're no longer overflowing.");
// Verify actual physical placements match those of the placement array:
let placementCounter = 0;
let placements = CustomizableUI.getWidgetIdsInArea(CustomizableUI.AREA_NAVBAR);
for (let node of navbar.customizationTarget.childNodes) {
if (node.getAttribute("skipintoolbarset") == "true") {
continue;
}
is(placements[placementCounter++], node.id, "Nodes should match after overflow");
}
];
is(placements.length, placementCounter, "Should have as many nodes as expected");
is(navbar.customizationTarget.childElementCount, oldChildCount, "Number of nodes should match");
});
function asyncCleanup() {
// Enter and exit customization mode, check that currentSet works
add_task(function() {
let oldCurrentSet = navbar.currentSet;
ok(CustomizableUI.inDefaultState, "Should start in default state.");
yield startCustomizing();
ok(CustomizableUI.inDefaultState, "Should be in default state in customization mode.");
is(navbar.currentSet, oldCurrentSet, "Currentset should be the same in customization mode.");
yield endCustomizing();
ok(CustomizableUI.inDefaultState, "Should be in default state after customization mode.");
is(navbar.currentSet, oldCurrentSet, "Currentset should be the same after customization mode.");
});
add_task(function asyncCleanup() {
yield resetCustomization();
}
function test() {
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,6 +2,8 @@
* 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";
let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
let overflowList = document.getElementById(navbar.getAttribute("overflowtarget"));
@ -14,158 +16,130 @@ const kStarBtn = "bookmarks-menu-button";
let originalWindowWidth;
let gTests = [
{
desc: "Adding a widget should add it next to the widget it's being inserted next to.",
setup: function() {
originalWindowWidth = window.outerWidth;
createDummyXULButton(kTestBtn1, "Test");
},
run: function() {
ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
ok(CustomizableUI.inDefaultState, "Should start in default state.");
// Adding a widget should add it next to the widget it's being inserted next to.
add_task(function() {
originalWindowWidth = window.outerWidth;
createDummyXULButton(kTestBtn1, "Test");
ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
ok(CustomizableUI.inDefaultState, "Should start in default state.");
window.resizeTo(400, window.outerHeight);
yield waitForCondition(() => navbar.hasAttribute("overflowing"));
ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar.");
ok(!navbar.querySelector("#" + kHomeBtn), "Home button should no longer be in the navbar");
ok(overflowList.querySelector("#" + kHomeBtn), "Home button should be overflowing");
window.resizeTo(400, window.outerHeight);
yield waitForCondition(() => navbar.hasAttribute("overflowing"));
ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar.");
ok(!navbar.querySelector("#" + kHomeBtn), "Home button should no longer be in the navbar");
ok(overflowList.querySelector("#" + kHomeBtn), "Home button should be overflowing");
let placementOfHomeButton = CustomizableUI.getWidgetIdsInArea(navbar.id).indexOf(kHomeBtn);
CustomizableUI.addWidgetToArea(kTestBtn1, navbar.id, placementOfHomeButton);
ok(!navbar.querySelector("#" + kTestBtn1), "New button should not be in the navbar");
ok(overflowList.querySelector("#" + kTestBtn1), "New button should be overflowing");
let nextEl = document.getElementById(kTestBtn1).nextSibling;
is(nextEl && nextEl.id, kHomeBtn, "Test button should be next to home button.");
let placementOfHomeButton = CustomizableUI.getWidgetIdsInArea(navbar.id).indexOf(kHomeBtn);
CustomizableUI.addWidgetToArea(kTestBtn1, navbar.id, placementOfHomeButton);
ok(!navbar.querySelector("#" + kTestBtn1), "New button should not be in the navbar");
ok(overflowList.querySelector("#" + kTestBtn1), "New button should be overflowing");
let nextEl = document.getElementById(kTestBtn1).nextSibling;
is(nextEl && nextEl.id, kHomeBtn, "Test button should be next to home button.");
window.resizeTo(originalWindowWidth, window.outerHeight);
yield waitForCondition(() => !navbar.hasAttribute("overflowing"));
ok(!navbar.hasAttribute("overflowing"), "Should not have an overflowing toolbar.");
ok(navbar.querySelector("#" + kHomeBtn), "Home button should be in the navbar");
ok(!overflowList.querySelector("#" + kHomeBtn), "Home button should no longer be overflowing");
ok(navbar.querySelector("#" + kTestBtn1), "Test button should be in the navbar");
ok(!overflowList.querySelector("#" + kTestBtn1), "Test button should no longer be overflowing");
},
teardown: function() {
let el = document.getElementById(kTestBtn1);
if (el) {
CustomizableUI.removeWidgetFromArea(kTestBtn1);
el.remove();
}
window.resizeTo(originalWindowWidth, window.outerHeight);
}
},
{
desc: "Removing a widget from the toolbar should try to move items back.",
setup: function() {
// This is pretty weird. We're going to try to move only the home button into the overlay:
let downloadsBtn = document.getElementById(kDownloadsBtn);
// Guarantee overflow of too much stuff:
window.resizeTo(700, window.outerHeight);
let inc = 15;
while (window.outerWidth < originalWindowWidth &&
downloadsBtn.parentNode != navbar.customizationTarget) {
window.resizeTo(window.outerWidth + inc, window.outerHeight);
yield waitFor(500);
}
},
run: function() {
ok(overflowList.querySelector("#home-button"), "Home button should be overflowing");
CustomizableUI.removeWidgetFromArea("downloads-button");
is(document.getElementById("home-button").parentNode, navbar.customizationTarget, "Home button should move back.");
ok(!navbar.hasAttribute("overflowing"), "Navbar is no longer overflowing");
},
teardown: function() {
window.resizeTo(originalWindowWidth, window.outerHeight);
yield waitForCondition(function() !navbar.hasAttribute("overflowing"));
CustomizableUI.reset();
}
},
{
desc: "Removing a widget should remove it from the overflow list if that is where it is, and update it accordingly.",
setup: function() {
createDummyXULButton(kTestBtn2, "Test");
},
run: function() {
ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
ok(CustomizableUI.inDefaultState, "Should start in default state.");
CustomizableUI.addWidgetToArea(kTestBtn2, navbar.id);
ok(!navbar.hasAttribute("overflowing"), "Should still have a non-overflowing toolbar.");
window.resizeTo(400, window.outerHeight);
yield waitForCondition(() => navbar.hasAttribute("overflowing"));
ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar.");
ok(!navbar.querySelector("#" + kTestBtn2), "Test button should not be in the navbar");
ok(overflowList.querySelector("#" + kTestBtn2), "Test button should be overflowing");
CustomizableUI.removeWidgetFromArea(kTestBtn2);
ok(!overflowList.querySelector("#" + kTestBtn2), "Test button should not be overflowing.");
ok(!navbar.querySelector("#" + kTestBtn2), "Test button should not be in the navbar");
ok(gNavToolbox.palette.querySelector("#" + kTestBtn2), "Test button should be in the palette");
window.resizeTo(originalWindowWidth, window.outerHeight);
yield waitForCondition(() => !navbar.hasAttribute("overflowing"));
ok(!navbar.hasAttribute("overflowing"), "Should not have an overflowing toolbar.");
},
teardown: function() {
let el = document.getElementById(kTestBtn2);
if (el) {
CustomizableUI.removeWidgetFromArea(kTestBtn2);
el.remove();
}
window.resizeTo(originalWindowWidth, window.outerHeight);
}
},
{
desc: "Overflow everything that can, then reorganize that list",
setup: function() {
ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
ok(CustomizableUI.inDefaultState, "Should start in default state.");
window.resizeTo(480, window.outerHeight);
yield waitForCondition(() => navbar.hasAttribute("overflowing"));
ok(!navbar.querySelector("#" + kSearchBox), "Search container should be overflowing");
},
run: function() {
let placements = CustomizableUI.getWidgetIdsInArea(navbar.id);
let searchboxPlacement = placements.indexOf(kSearchBox);
CustomizableUI.moveWidgetWithinArea(kHomeBtn, searchboxPlacement);
yield waitForCondition(() => navbar.querySelector("#" + kHomeBtn));
ok(navbar.querySelector("#" + kHomeBtn), "Home button should have moved back");
let inc = 15;
window.resizeTo(640, window.outerHeight);
while (window.outerWidth < originalWindowWidth &&
!navbar.querySelector("#" + kSearchBox)) {
window.resizeTo(window.outerWidth + inc, window.outerHeight);
yield waitFor(500);
}
ok(!navbar.querySelector("#" + kStarBtn), "Star button should still be overflowed");
CustomizableUI.moveWidgetWithinArea(kStarBtn);
let starButtonOverflowed = overflowList.querySelector("#" + kStarBtn);
ok(starButtonOverflowed && !starButtonOverflowed.nextSibling, "Star button should be last item");
window.resizeTo(window.outerWidth + 15, window.outerHeight);
yield waitForCondition(() => navbar.querySelector("#" + kDownloadsBtn) && navbar.hasAttribute("overflowing"));
ok(navbar.hasAttribute("overflowing"), "navbar should still be overflowing");
CustomizableUI.moveWidgetWithinArea(kHomeBtn);
let homeButtonOverflowed = overflowList.querySelector("#" + kHomeBtn);
ok(homeButtonOverflowed, "Home button should be in overflow list");
ok(navbar.hasAttribute("overflowing"), "navbar should still be overflowing");
ok(homeButtonOverflowed && !homeButtonOverflowed.nextSibling, "Home button should be last item");
},
teardown: function() {
window.resizeTo(originalWindowWidth, window.outerHeight);
yield waitForCondition(() => !navbar.hasAttribute("overflowing"));
ok(!navbar.hasAttribute("overflowing"), "Should not have an overflowing toolbar.");
}
window.resizeTo(originalWindowWidth, window.outerHeight);
yield waitForCondition(() => !navbar.hasAttribute("overflowing"));
ok(!navbar.hasAttribute("overflowing"), "Should not have an overflowing toolbar.");
ok(navbar.querySelector("#" + kHomeBtn), "Home button should be in the navbar");
ok(!overflowList.querySelector("#" + kHomeBtn), "Home button should no longer be overflowing");
ok(navbar.querySelector("#" + kTestBtn1), "Test button should be in the navbar");
ok(!overflowList.querySelector("#" + kTestBtn1), "Test button should no longer be overflowing");
let el = document.getElementById(kTestBtn1);
if (el) {
CustomizableUI.removeWidgetFromArea(kTestBtn1);
el.remove();
}
];
window.resizeTo(originalWindowWidth, window.outerHeight);
});
function asyncCleanup() {
// Removing a widget from the toolbar should try to move items back.
add_task(function() {
// This is pretty weird. We're going to try to move only the home button into the overlay:
let downloadsBtn = document.getElementById(kDownloadsBtn);
// Guarantee overflow of too much stuff:
window.resizeTo(700, window.outerHeight);
let inc = 15;
while (window.outerWidth < originalWindowWidth &&
downloadsBtn.parentNode != navbar.customizationTarget) {
window.resizeTo(window.outerWidth + inc, window.outerHeight);
yield waitFor(500);
}
ok(overflowList.querySelector("#home-button"), "Home button should be overflowing");
CustomizableUI.removeWidgetFromArea("downloads-button");
is(document.getElementById("home-button").parentNode, navbar.customizationTarget, "Home button should move back.");
ok(!navbar.hasAttribute("overflowing"), "Navbar is no longer overflowing");
window.resizeTo(originalWindowWidth, window.outerHeight);
yield waitForCondition(function() !navbar.hasAttribute("overflowing"));
CustomizableUI.reset();
});
// Removing a widget should remove it from the overflow list if that is where it is, and update it accordingly.
add_task(function() {
createDummyXULButton(kTestBtn2, "Test");
ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
ok(CustomizableUI.inDefaultState, "Should start in default state.");
CustomizableUI.addWidgetToArea(kTestBtn2, navbar.id);
ok(!navbar.hasAttribute("overflowing"), "Should still have a non-overflowing toolbar.");
window.resizeTo(400, window.outerHeight);
yield waitForCondition(() => navbar.hasAttribute("overflowing"));
ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar.");
ok(!navbar.querySelector("#" + kTestBtn2), "Test button should not be in the navbar");
ok(overflowList.querySelector("#" + kTestBtn2), "Test button should be overflowing");
CustomizableUI.removeWidgetFromArea(kTestBtn2);
ok(!overflowList.querySelector("#" + kTestBtn2), "Test button should not be overflowing.");
ok(!navbar.querySelector("#" + kTestBtn2), "Test button should not be in the navbar");
ok(gNavToolbox.palette.querySelector("#" + kTestBtn2), "Test button should be in the palette");
window.resizeTo(originalWindowWidth, window.outerHeight);
yield waitForCondition(() => !navbar.hasAttribute("overflowing"));
ok(!navbar.hasAttribute("overflowing"), "Should not have an overflowing toolbar.");
let el = document.getElementById(kTestBtn2);
if (el) {
CustomizableUI.removeWidgetFromArea(kTestBtn2);
el.remove();
}
window.resizeTo(originalWindowWidth, window.outerHeight);
});
// Overflow everything that can, then reorganize that list
add_task(function() {
ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
ok(CustomizableUI.inDefaultState, "Should start in default state.");
window.resizeTo(480, window.outerHeight);
yield waitForCondition(() => navbar.hasAttribute("overflowing"));
ok(!navbar.querySelector("#" + kSearchBox), "Search container should be overflowing");
let placements = CustomizableUI.getWidgetIdsInArea(navbar.id);
let searchboxPlacement = placements.indexOf(kSearchBox);
CustomizableUI.moveWidgetWithinArea(kHomeBtn, searchboxPlacement);
yield waitForCondition(() => navbar.querySelector("#" + kHomeBtn));
ok(navbar.querySelector("#" + kHomeBtn), "Home button should have moved back");
let inc = 15;
window.resizeTo(640, window.outerHeight);
while (window.outerWidth < originalWindowWidth &&
!navbar.querySelector("#" + kSearchBox)) {
window.resizeTo(window.outerWidth + inc, window.outerHeight);
yield waitFor(500);
}
ok(!navbar.querySelector("#" + kStarBtn), "Star button should still be overflowed");
CustomizableUI.moveWidgetWithinArea(kStarBtn);
let starButtonOverflowed = overflowList.querySelector("#" + kStarBtn);
ok(starButtonOverflowed && !starButtonOverflowed.nextSibling, "Star button should be last item");
window.resizeTo(window.outerWidth + 15, window.outerHeight);
yield waitForCondition(() => navbar.querySelector("#" + kDownloadsBtn) && navbar.hasAttribute("overflowing"));
ok(navbar.hasAttribute("overflowing"), "navbar should still be overflowing");
CustomizableUI.moveWidgetWithinArea(kHomeBtn);
let homeButtonOverflowed = overflowList.querySelector("#" + kHomeBtn);
ok(homeButtonOverflowed, "Home button should be in overflow list");
ok(navbar.hasAttribute("overflowing"), "navbar should still be overflowing");
ok(homeButtonOverflowed && !homeButtonOverflowed.nextSibling, "Home button should be last item");
window.resizeTo(originalWindowWidth, window.outerHeight);
yield waitForCondition(() => !navbar.hasAttribute("overflowing"));
ok(!navbar.hasAttribute("overflowing"), "Should not have an overflowing toolbar.");
});
add_task(function asyncCleanup() {
yield resetCustomization();
}
function test() {
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,25 +2,15 @@
* 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/. */
let gTests = [
{
desc: "Entering then exiting customization mode should reenable the Help and Exit buttons.",
run: function() {
yield startCustomizing();
let helpButton = document.getElementById("PanelUI-help");
let quitButton = document.getElementById("PanelUI-quit");
ok(helpButton.getAttribute("disabled") == "true", "Help button should be disabled while in customization mode.");
ok(quitButton.getAttribute("disabled") == "true", "Quit button should be disabled while in customization mode.");
yield endCustomizing();
ok(!helpButton.hasAttribute("disabled"), "Help button should not be disabled.");
ok(!quitButton.hasAttribute("disabled"), "Quit button should not be disabled.");
}
},
];
function test() {
waitForExplicitFinish();
runTests(gTests);
}
// Entering then exiting customization mode should reenable the Help and Exit buttons.
add_task(function() {
yield startCustomizing();
let helpButton = document.getElementById("PanelUI-help");
let quitButton = document.getElementById("PanelUI-quit");
ok(helpButton.getAttribute("disabled") == "true", "Help button should be disabled while in customization mode.");
ok(quitButton.getAttribute("disabled") == "true", "Quit button should be disabled while in customization mode.");
yield endCustomizing();
ok(!helpButton.hasAttribute("disabled"), "Help button should not be disabled.");
ok(!quitButton.hasAttribute("disabled"), "Quit button should not be disabled.");
});

Просмотреть файл

@ -2,45 +2,39 @@
* 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";
let navbar;
let skippedItem;
let gTests = [
{
desc: "Attempting to drag a skipintoolbarset item should work.",
setup: function() {
navbar = document.getElementById("nav-bar");
skippedItem = document.createElement("toolbarbutton");
skippedItem.id = "test-skipintoolbarset-item";
skippedItem.setAttribute("label", "Test");
skippedItem.setAttribute("skipintoolbarset", "true");
navbar.customizationTarget.appendChild(skippedItem);
},
run: function() {
let downloadsButton = document.getElementById("downloads-button");
yield startCustomizing();
ok(CustomizableUI.inDefaultState, "Should still be in default state");
simulateItemDrag(skippedItem, downloadsButton);
ok(CustomizableUI.inDefaultState, "Should still be in default state");
let skippedItemWrapper = skippedItem.parentNode;
is(skippedItemWrapper.nextSibling && skippedItemWrapper.nextSibling.id,
downloadsButton.parentNode.id, "Should be next to downloads button");
simulateItemDrag(downloadsButton, skippedItem);
let downloadWrapper = downloadsButton.parentNode;
is(downloadWrapper.nextSibling && downloadWrapper.nextSibling.id,
skippedItem.parentNode.id, "Should be next to skipintoolbarset item");
ok(CustomizableUI.inDefaultState, "Should still be in default state");
}
},
];
function asyncCleanup() {
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
// Attempting to drag a skipintoolbarset item should work.
add_task(function() {
navbar = document.getElementById("nav-bar");
skippedItem = document.createElement("toolbarbutton");
skippedItem.id = "test-skipintoolbarset-item";
skippedItem.setAttribute("label", "Test");
skippedItem.setAttribute("skipintoolbarset", "true");
navbar.customizationTarget.appendChild(skippedItem);
let downloadsButton = document.getElementById("downloads-button");
yield startCustomizing();
ok(CustomizableUI.inDefaultState, "Should still be in default state");
simulateItemDrag(skippedItem, downloadsButton);
ok(CustomizableUI.inDefaultState, "Should still be in default state");
let skippedItemWrapper = skippedItem.parentNode;
is(skippedItemWrapper.nextSibling && skippedItemWrapper.nextSibling.id,
downloadsButton.parentNode.id, "Should be next to downloads button");
simulateItemDrag(downloadsButton, skippedItem);
let downloadWrapper = downloadsButton.parentNode;
is(downloadWrapper.nextSibling && downloadWrapper.nextSibling.id,
skippedItem.parentNode.id, "Should be next to skipintoolbarset item");
ok(CustomizableUI.inDefaultState, "Should still be in default state");
});
add_task(function asyncCleanup() {
yield endCustomizing();
skippedItem.remove();
Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck");
yield resetCustomization();
}
function test() {
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,37 +2,27 @@
* 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/. */
let gTests = [
{
desc: "Customize mode reset button should revert correctly",
setup: function() {
yield startCustomizing();
},
run: function() {
let devButton = document.getElementById("developer-button");
let downloadsButton = document.getElementById("downloads-button");
let searchBox = document.getElementById("search-container");
let palette = document.getElementById("customization-palette");
ok(devButton && downloadsButton && searchBox && palette, "Stuff should exist");
simulateItemDrag(devButton, downloadsButton);
simulateItemDrag(searchBox, palette);
gCustomizeMode.reset();
yield waitForCondition(function() !gCustomizeMode.resetting);
ok(CustomizableUI.inDefaultState, "Should be back in default state");
},
teardown: function() {
yield endCustomizing();
}
}
];
"use strict";
function asyncCleanup() {
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
// Customize mode reset button should revert correctly
add_task(function() {
yield startCustomizing();
let devButton = document.getElementById("developer-button");
let downloadsButton = document.getElementById("downloads-button");
let searchBox = document.getElementById("search-container");
let palette = document.getElementById("customization-palette");
ok(devButton && downloadsButton && searchBox && palette, "Stuff should exist");
simulateItemDrag(devButton, downloadsButton);
simulateItemDrag(searchBox, palette);
gCustomizeMode.reset();
yield waitForCondition(function() !gCustomizeMode.resetting);
ok(CustomizableUI.inDefaultState, "Should be back in default state");
yield endCustomizing();
});
add_task(function asyncCleanup() {
Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck");
yield resetCustomization();
}
function test() {
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,36 +2,27 @@
* 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";
let gTests = [
{
desc: "Attempting to drag an item to an empty container should work.",
setup: function() {
createToolbarWithPlacements(kTestToolbarId, []);
},
run: function() {
yield startCustomizing();
let downloadButton = document.getElementById("downloads-button");
let customToolbar = document.getElementById(kTestToolbarId);
simulateItemDrag(downloadButton, customToolbar);
assertAreaPlacements(kTestToolbarId, ["downloads-button"]);
ok(downloadButton.parentNode && downloadButton.parentNode.parentNode == customToolbar,
"Button should really be in toolbar");
},
teardown: function() {
yield endCustomizing();
removeCustomToolbars();
}
},
];
function asyncCleanup() {
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
// Attempting to drag an item to an empty container should work.
add_task(function() {
yield createToolbarWithPlacements(kTestToolbarId, []);
yield startCustomizing();
let downloadButton = document.getElementById("downloads-button");
let customToolbar = document.getElementById(kTestToolbarId);
simulateItemDrag(downloadButton, customToolbar);
assertAreaPlacements(kTestToolbarId, ["downloads-button"]);
ok(downloadButton.parentNode && downloadButton.parentNode.parentNode == customToolbar,
"Button should really be in toolbar");
yield endCustomizing();
removeCustomToolbars();
});
add_task(function asyncCleanup() {
yield endCustomizing();
Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck");
yield resetCustomization();
}
function test() {
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,31 +2,27 @@
* 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/. */
let gTests = [
{
desc: "Attempting to drag the menubar to the navbar shouldn't work.",
setup: startCustomizing,
run: function() {
let menuItems = document.getElementById("menubar-items");
let navbar = document.getElementById("nav-bar");
let menubar = document.getElementById("toolbar-menubar");
simulateItemDrag(menuItems, navbar.customizationTarget);
is(getAreaWidgetIds("nav-bar").indexOf("menubar-items"), -1, "Menu bar shouldn't be in the navbar.");
ok(!navbar.querySelector("#menubar-items"), "Shouldn't find menubar items in the navbar.");
ok(menubar.querySelector("#menubar-items"), "Should find menubar items in the menubar.");
isnot(getAreaWidgetIds("toolbar-menubar").indexOf("menubar-items"), -1, "Menubar items shouldn't be missing from the navbar.");
},
teardown: endCustomizing
},
];
function asyncCleanup() {
"use strict";
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
// Attempting to drag the menubar to the navbar shouldn't work.
add_task(function() {
yield startCustomizing();
let menuItems = document.getElementById("menubar-items");
let navbar = document.getElementById("nav-bar");
let menubar = document.getElementById("toolbar-menubar");
simulateItemDrag(menuItems, navbar.customizationTarget);
is(getAreaWidgetIds("nav-bar").indexOf("menubar-items"), -1, "Menu bar shouldn't be in the navbar.");
ok(!navbar.querySelector("#menubar-items"), "Shouldn't find menubar items in the navbar.");
ok(menubar.querySelector("#menubar-items"), "Should find menubar items in the menubar.");
isnot(getAreaWidgetIds("toolbar-menubar").indexOf("menubar-items"), -1,
"Menubar items shouldn't be missing from the navbar.");
yield endCustomizing();
});
add_task(function asyncCleanup() {
yield endCustomizing();
Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck");
yield resetCustomization();
}
function test() {
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,25 +2,16 @@
* 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/. */
let gTests = [
{
desc: "Customization reset should restore visibility to default-visible toolbars.",
setup: null,
run: function() {
let navbar = document.getElementById("nav-bar");
is(navbar.collapsed, false, "Test should start with navbar visible");
navbar.collapsed = true;
is(navbar.collapsed, true, "navbar should be hidden now");
"use strict";
yield resetCustomization();
// Customization reset should restore visibility to default-visible toolbars.
add_task(function() {
let navbar = document.getElementById("nav-bar");
is(navbar.collapsed, false, "Test should start with navbar visible");
navbar.collapsed = true;
is(navbar.collapsed, true, "navbar should be hidden now");
is(navbar.collapsed, false, "Customization reset should restore visibility to the navbar");
},
teardown: null
},
];
yield resetCustomization();
function test() {
waitForExplicitFinish();
runTests(gTests);
}
is(navbar.collapsed, false, "Customization reset should restore visibility to the navbar");
});

Просмотреть файл

@ -2,33 +2,25 @@
* 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 kWidgetId = "test-non-removable-widget";
let gTests = [
{
desc: "Adding non-removable items to a toolbar or the panel shouldn't change inDefaultState",
run: function() {
let navbar = document.getElementById("nav-bar");
ok(CustomizableUI.inDefaultState, "Should start in default state");
let button = createDummyXULButton(kWidgetId, "Test non-removable inDefaultState handling");
CustomizableUI.addWidgetToArea(kWidgetId, CustomizableUI.AREA_NAVBAR);
button.setAttribute("removable", "false");
ok(CustomizableUI.inDefaultState, "Should still be in default state after navbar addition");
button.remove();
// Adding non-removable items to a toolbar or the panel shouldn't change inDefaultState
add_task(function() {
let navbar = document.getElementById("nav-bar");
ok(CustomizableUI.inDefaultState, "Should start in default state");
button = createDummyXULButton(kWidgetId, "Test non-removable inDefaultState handling");
CustomizableUI.addWidgetToArea(kWidgetId, CustomizableUI.AREA_PANEL);
button.setAttribute("removable", "false");
ok(CustomizableUI.inDefaultState, "Should still be in default state after panel addition");
button.remove();
ok(CustomizableUI.inDefaultState, "Should be in default state after destroying both widgets");
},
teardown: null
},
];
function test() {
waitForExplicitFinish();
runTests(gTests);
}
let button = createDummyXULButton(kWidgetId, "Test non-removable inDefaultState handling");
CustomizableUI.addWidgetToArea(kWidgetId, CustomizableUI.AREA_NAVBAR);
button.setAttribute("removable", "false");
ok(CustomizableUI.inDefaultState, "Should still be in default state after navbar addition");
button.remove();
button = createDummyXULButton(kWidgetId, "Test non-removable inDefaultState handling");
CustomizableUI.addWidgetToArea(kWidgetId, CustomizableUI.AREA_PANEL);
button.setAttribute("removable", "false");
ok(CustomizableUI.inDefaultState, "Should still be in default state after panel addition");
button.remove();
ok(CustomizableUI.inDefaultState, "Should be in default state after destroying both widgets");
});

Просмотреть файл

@ -2,59 +2,58 @@
* 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 kToolbarId = "test-registerToolbarNode-toolbar";
const kButtonId = "test-registerToolbarNode-button";
let gTests = [
{
desc: "Registering a toolbar with defaultset attribute should work",
run: function() {
let btn = createDummyXULButton(kButtonId);
let toolbar = document.createElement("toolbar");
toolbar.id = kToolbarId;
toolbar.setAttribute("customizable", true);
toolbar.setAttribute("defaultset", kButtonId);
gNavToolbox.appendChild(toolbar);
ok(CustomizableUI.areas.indexOf(kToolbarId) != -1,
"Toolbar should have been registered automatically.");
is(CustomizableUI.getAreaType(kToolbarId), CustomizableUI.TYPE_TOOLBAR,
"Area should be registered as toolbar");
assertAreaPlacements(kToolbarId, [kButtonId]);
ok(CustomizableUI.inDefaultState, "Everything should be in its default state.");
CustomizableUI.unregisterArea(kToolbarId, true);
toolbar.remove();
ok(CustomizableUI.inDefaultState, "Everything should be in its default state.");
btn.remove();
}
},
{
desc: "Registering a toolbar without a defaultset attribute should " +
"wait for the registerArea call",
run: function() {
let btn = createDummyXULButton(kButtonId);
let toolbar = document.createElement("toolbar");
toolbar.id = kToolbarId;
toolbar.setAttribute("customizable", true);
gNavToolbox.appendChild(toolbar);
ok(CustomizableUI.areas.indexOf(kToolbarId) == -1,
"Toolbar should not yet have been registered automatically.");
CustomizableUI.registerArea(kToolbarId, {defaultPlacements: [kButtonId]});
ok(CustomizableUI.areas.indexOf(kToolbarId) != -1,
"Toolbar should have been registered now.");
is(CustomizableUI.getAreaType(kToolbarId), CustomizableUI.TYPE_TOOLBAR,
"Area should be registered as toolbar");
assertAreaPlacements(kToolbarId, [kButtonId]);
ok(CustomizableUI.inDefaultState, "Everything should be in its default state.");
CustomizableUI.unregisterArea(kToolbarId, true);
toolbar.remove();
ok(CustomizableUI.inDefaultState, "Everything should be in its default state.");
btn.remove();
}
}
];
registerCleanupFunction(cleanup);
function asyncCleanup() {
// Registering a toolbar with defaultset attribute should work
add_task(function() {
let btn = createDummyXULButton(kButtonId);
let toolbar = document.createElement("toolbar");
toolbar.id = kToolbarId;
toolbar.setAttribute("customizable", true);
toolbar.setAttribute("defaultset", kButtonId);
gNavToolbox.appendChild(toolbar);
ok(CustomizableUI.areas.indexOf(kToolbarId) != -1,
"Toolbar should have been registered automatically.");
is(CustomizableUI.getAreaType(kToolbarId), CustomizableUI.TYPE_TOOLBAR,
"Area should be registered as toolbar");
assertAreaPlacements(kToolbarId, [kButtonId]);
ok(CustomizableUI.inDefaultState, "Everything should be in its default state.");
CustomizableUI.unregisterArea(kToolbarId, true);
toolbar.remove();
ok(CustomizableUI.inDefaultState, "Everything should be in its default state.");
btn.remove();
});
// Registering a toolbar without a defaultset attribute should
// wait for the registerArea call
add_task(function() {
let btn = createDummyXULButton(kButtonId);
let toolbar = document.createElement("toolbar");
toolbar.id = kToolbarId;
toolbar.setAttribute("customizable", true);
gNavToolbox.appendChild(toolbar);
ok(CustomizableUI.areas.indexOf(kToolbarId) == -1,
"Toolbar should not yet have been registered automatically.");
CustomizableUI.registerArea(kToolbarId, {defaultPlacements: [kButtonId]});
ok(CustomizableUI.areas.indexOf(kToolbarId) != -1,
"Toolbar should have been registered now.");
is(CustomizableUI.getAreaType(kToolbarId), CustomizableUI.TYPE_TOOLBAR,
"Area should be registered as toolbar");
assertAreaPlacements(kToolbarId, [kButtonId]);
ok(CustomizableUI.inDefaultState, "Everything should be in its default state.");
CustomizableUI.unregisterArea(kToolbarId, true);
toolbar.remove();
ok(CustomizableUI.inDefaultState, "Everything should be in its default state.");
btn.remove();
});
add_task(function asyncCleanup() {
yield resetCustomization();
}
});
function cleanup() {
let toolbar = document.getElementById(kToolbarId);
@ -67,11 +66,3 @@ function cleanup() {
btn.remove();
}
}
function test() {
waitForExplicitFinish();
registerCleanupFunction(cleanup);
runTests(gTests, asyncCleanup);
}

Просмотреть файл

@ -2,32 +2,21 @@
* 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 kTestBtnId = "test-removable-navbar-customize-mode";
let gTests = [
{
desc: "Items without the removable attribute in the navbar should be considered non-removable",
setup: function() {
let btn = createDummyXULButton(kTestBtnId, "Test removable in navbar in customize mode");
document.getElementById("nav-bar").customizationTarget.appendChild(btn);
return startCustomizing();
},
run: function() {
ok(!CustomizableUI.isWidgetRemovable(kTestBtnId), "Widget should not be considered removable");
},
teardown: function() {
yield endCustomizing();
document.getElementById(kTestBtnId).remove();
}
},
];
function asyncCleanup() {
// Items without the removable attribute in the navbar should be considered non-removable
add_task(function() {
let btn = createDummyXULButton(kTestBtnId, "Test removable in navbar in customize mode");
document.getElementById("nav-bar").customizationTarget.appendChild(btn);
yield startCustomizing();
ok(!CustomizableUI.isWidgetRemovable(kTestBtnId), "Widget should not be considered removable");
yield endCustomizing();
document.getElementById(kTestBtnId).remove();
});
add_task(function asyncCleanup() {
yield endCustomizing();
yield resetCustomization();
}
function test() {
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,37 +2,30 @@
* 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";
// See https://bugzilla.mozilla.org/show_bug.cgi?id=941083
const kWidgetId = "test-invalidate-wrapper-cache";
let gTests = [
{
desc: "Check createWidget invalidates the widget cache",
run: function() {
let groupWrapper = CustomizableUI.getWidget(kWidgetId);
ok(groupWrapper, "Should get group wrapper.");
let singleWrapper = groupWrapper.forWindow(window);
ok(singleWrapper, "Should get single wrapper.");
// Check createWidget invalidates the widget cache
add_task(function() {
let groupWrapper = CustomizableUI.getWidget(kWidgetId);
ok(groupWrapper, "Should get group wrapper.");
let singleWrapper = groupWrapper.forWindow(window);
ok(singleWrapper, "Should get single wrapper.");
CustomizableUI.createWidget({id: kWidgetId, label: "Test invalidating widgets caching"});
CustomizableUI.createWidget({id: kWidgetId, label: "Test invalidating widgets caching"});
let newGroupWrapper = CustomizableUI.getWidget(kWidgetId);
ok(newGroupWrapper, "Should get a group wrapper again.");
isnot(newGroupWrapper, groupWrapper, "Wrappers shouldn't be the same.");
isnot(newGroupWrapper.provider, groupWrapper.provider, "Wrapper providers shouldn't be the same.");
let newGroupWrapper = CustomizableUI.getWidget(kWidgetId);
ok(newGroupWrapper, "Should get a group wrapper again.");
isnot(newGroupWrapper, groupWrapper, "Wrappers shouldn't be the same.");
isnot(newGroupWrapper.provider, groupWrapper.provider, "Wrapper providers shouldn't be the same.");
let newSingleWrapper = newGroupWrapper.forWindow(window);
isnot(newSingleWrapper, singleWrapper, "Single wrappers shouldn't be the same.");
isnot(newSingleWrapper.provider, singleWrapper.provider, "Single wrapper providers shouldn't be the same.");
let newSingleWrapper = newGroupWrapper.forWindow(window);
isnot(newSingleWrapper, singleWrapper, "Single wrappers shouldn't be the same.");
isnot(newSingleWrapper.provider, singleWrapper.provider, "Single wrapper providers shouldn't be the same.");
CustomizableUI.destroyWidget(kWidgetId);
ok(!CustomizableUI.getWidget(kWidgetId), "Shouldn't get a wrapper after destroying the widget.");
},
},
];
function test() {
waitForExplicitFinish();
runTests(gTests);
}
CustomizableUI.destroyWidget(kWidgetId);
ok(!CustomizableUI.getWidget(kWidgetId), "Shouldn't get a wrapper after destroying the widget.");
});

Просмотреть файл

@ -2,88 +2,87 @@
* 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 kToolbarName = "test-unregisterArea-placements-toolbar";
const kTestWidgetPfx = "test-widget-for-unregisterArea-placements-";
const kTestWidgetCount = 3;
registerCleanupFunction(removeCustomToolbars);
let gTests = [
{
desc: "unregisterArea should keep placements by default and restore them when re-adding the area",
run: function() {
let widgetIds = []
for (let i = 0; i < kTestWidgetCount; i++) {
let id = kTestWidgetPfx + i;
widgetIds.push(id);
let spec = {id: id, type: 'button', removable: true, label: "unregisterArea test", tooltiptext: "" + i};
CustomizableUI.createWidget(spec);
}
for (let i = kTestWidgetCount; i < kTestWidgetCount * 2; i++) {
let id = kTestWidgetPfx + i;
widgetIds.push(id);
createDummyXULButton(id, "unregisterArea XUL test " + i);
}
let toolbarNode = createToolbarWithPlacements(kToolbarName, widgetIds);
checkAbstractAndRealPlacements(toolbarNode, widgetIds);
// Now move one of them:
CustomizableUI.moveWidgetWithinArea(kTestWidgetPfx + kTestWidgetCount, 0);
// Clone the array so we know this is the modified one:
let modifiedWidgetIds = [...widgetIds];
let movedWidget = modifiedWidgetIds.splice(kTestWidgetCount, 1)[0];
modifiedWidgetIds.unshift(movedWidget);
// Check it:
checkAbstractAndRealPlacements(toolbarNode, modifiedWidgetIds);
// Then unregister
CustomizableUI.unregisterArea(kToolbarName);
// Check we tell the outside world no dangerous things:
checkWidgetFates(widgetIds);
// Only then remove the real node
toolbarNode.remove();
// Now move one of the items to the palette, and another to the navbar:
let lastWidget = modifiedWidgetIds.pop();
CustomizableUI.removeWidgetFromArea(lastWidget);
lastWidget = modifiedWidgetIds.pop();
CustomizableUI.addWidgetToArea(lastWidget, CustomizableUI.AREA_NAVBAR);
// Recreate ourselves with the default placements being the same:
toolbarNode = createToolbarWithPlacements(kToolbarName, widgetIds);
// Then check that after doing this, our actual placements match
// the modified list, not the default one.
checkAbstractAndRealPlacements(toolbarNode, modifiedWidgetIds);
// Now remove completely:
CustomizableUI.unregisterArea(kToolbarName, true);
checkWidgetFates(modifiedWidgetIds);
toolbarNode.remove();
// One more time:
// Recreate ourselves with the default placements being the same:
toolbarNode = createToolbarWithPlacements(kToolbarName, widgetIds);
// Should now be back to default:
checkAbstractAndRealPlacements(toolbarNode, widgetIds);
CustomizableUI.unregisterArea(kToolbarName, true);
checkWidgetFates(widgetIds);
toolbarNode.remove();
//XXXgijs: ensure cleanup function doesn't barf:
gAddedToolbars.delete(kToolbarName);
// Remove all the XUL widgets, destroy the others:
for (let widget of widgetIds) {
let widgetWrapper = CustomizableUI.getWidget(widget);
if (widgetWrapper.provider == CustomizableUI.PROVIDER_XUL) {
gNavToolbox.palette.querySelector("#" + widget).remove();
} else {
CustomizableUI.destroyWidget(widget);
}
}
},
// unregisterArea should keep placements by default and restore them when re-adding the area
add_task(function() {
let widgetIds = [];
for (let i = 0; i < kTestWidgetCount; i++) {
let id = kTestWidgetPfx + i;
widgetIds.push(id);
let spec = {id: id, type: 'button', removable: true, label: "unregisterArea test", tooltiptext: "" + i};
CustomizableUI.createWidget(spec);
}
];
for (let i = kTestWidgetCount; i < kTestWidgetCount * 2; i++) {
let id = kTestWidgetPfx + i;
widgetIds.push(id);
createDummyXULButton(id, "unregisterArea XUL test " + i);
}
let toolbarNode = createToolbarWithPlacements(kToolbarName, widgetIds);
checkAbstractAndRealPlacements(toolbarNode, widgetIds);
// Now move one of them:
CustomizableUI.moveWidgetWithinArea(kTestWidgetPfx + kTestWidgetCount, 0);
// Clone the array so we know this is the modified one:
let modifiedWidgetIds = [...widgetIds];
let movedWidget = modifiedWidgetIds.splice(kTestWidgetCount, 1)[0];
modifiedWidgetIds.unshift(movedWidget);
// Check it:
checkAbstractAndRealPlacements(toolbarNode, modifiedWidgetIds);
// Then unregister
CustomizableUI.unregisterArea(kToolbarName);
// Check we tell the outside world no dangerous things:
checkWidgetFates(widgetIds);
// Only then remove the real node
toolbarNode.remove();
// Now move one of the items to the palette, and another to the navbar:
let lastWidget = modifiedWidgetIds.pop();
CustomizableUI.removeWidgetFromArea(lastWidget);
lastWidget = modifiedWidgetIds.pop();
CustomizableUI.addWidgetToArea(lastWidget, CustomizableUI.AREA_NAVBAR);
// Recreate ourselves with the default placements being the same:
toolbarNode = createToolbarWithPlacements(kToolbarName, widgetIds);
// Then check that after doing this, our actual placements match
// the modified list, not the default one.
checkAbstractAndRealPlacements(toolbarNode, modifiedWidgetIds);
// Now remove completely:
CustomizableUI.unregisterArea(kToolbarName, true);
checkWidgetFates(modifiedWidgetIds);
toolbarNode.remove();
// One more time:
// Recreate ourselves with the default placements being the same:
toolbarNode = createToolbarWithPlacements(kToolbarName, widgetIds);
// Should now be back to default:
checkAbstractAndRealPlacements(toolbarNode, widgetIds);
CustomizableUI.unregisterArea(kToolbarName, true);
checkWidgetFates(widgetIds);
toolbarNode.remove();
//XXXgijs: ensure cleanup function doesn't barf:
gAddedToolbars.delete(kToolbarName);
// Remove all the XUL widgets, destroy the others:
for (let widget of widgetIds) {
let widgetWrapper = CustomizableUI.getWidget(widget);
if (widgetWrapper.provider == CustomizableUI.PROVIDER_XUL) {
gNavToolbox.palette.querySelector("#" + widget).remove();
} else {
CustomizableUI.destroyWidget(widget);
}
}
});
function checkAbstractAndRealPlacements(aNode, aExpectedPlacements) {
assertAreaPlacements(kToolbarName, aExpectedPlacements);
@ -102,17 +101,6 @@ function checkWidgetFates(aWidgetIds) {
}
}
function asyncCleanup() {
add_task(function asyncCleanup() {
yield resetCustomization();
}
function cleanup() {
removeCustomToolbars();
}
function test() {
waitForExplicitFinish();
registerCleanupFunction(cleanup);
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,6 +2,8 @@
* 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 kWidgetId = "test-addonbar-migration";
const kWidgetId2 = "test-addonbar-migration2";
@ -11,52 +13,38 @@ let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
let btn;
let btn2;
let gTests = [
{
desc: "Check we migrate normal stuff to the navbar",
setup: function() {
btn = createDummyXULButton(kWidgetId, "Test");
btn2 = createDummyXULButton(kWidgetId2, "Test2");
},
run: function() {
addonbar.insertItem(btn.id);
ok(btn.parentNode == navbar.customizationTarget, "Button should end up in navbar");
let migrationArray = addonbar.getMigratedItems();
is(migrationArray.length, 1, "Should have migrated 1 item");
is(migrationArray[0], kWidgetId, "Should have migrated our 1 item");
// Check we migrate normal stuff to the navbar
add_task(function() {
btn = createDummyXULButton(kWidgetId, "Test");
btn2 = createDummyXULButton(kWidgetId2, "Test2");
addonbar.insertItem(btn.id);
ok(btn.parentNode == navbar.customizationTarget, "Button should end up in navbar");
let migrationArray = addonbar.getMigratedItems();
is(migrationArray.length, 1, "Should have migrated 1 item");
is(migrationArray[0], kWidgetId, "Should have migrated our 1 item");
addonbar.currentSet = addonbar.currentSet + "," + kWidgetId2;
ok(btn2.parentNode == navbar.customizationTarget, "Second button should end up in the navbar");
migrationArray = addonbar.getMigratedItems();
is(migrationArray.length, 2, "Should have migrated 2 items");
isnot(migrationArray.indexOf(kWidgetId2), -1, "Should have migrated our second item");
addonbar.currentSet = addonbar.currentSet + "," + kWidgetId2;
ok(btn2.parentNode == navbar.customizationTarget, "Second button should end up in the navbar");
migrationArray = addonbar.getMigratedItems();
is(migrationArray.length, 2, "Should have migrated 2 items");
isnot(migrationArray.indexOf(kWidgetId2), -1, "Should have migrated our second item");
let otherWindow = yield openAndLoadWindow(undefined, true);
try {
let addonBar = otherWindow.document.getElementById("addon-bar");
let otherMigrationArray = addonBar.getMigratedItems();
is(migrationArray.length, otherMigrationArray.length,
"Other window should have the same number of migrated items.");
if (migrationArray.length == otherMigrationArray.length) {
for (let widget of migrationArray) {
isnot(otherMigrationArray.indexOf(widget), -1,
"Migrated widget " + widget + " should also be listed as migrated in the other window.");
}
}
} finally {
otherWindow.close();
let otherWindow = yield openAndLoadWindow(undefined, true);
try {
let addonBar = otherWindow.document.getElementById("addon-bar");
let otherMigrationArray = addonBar.getMigratedItems();
is(migrationArray.length, otherMigrationArray.length,
"Other window should have the same number of migrated items.");
if (migrationArray.length == otherMigrationArray.length) {
for (let widget of migrationArray) {
isnot(otherMigrationArray.indexOf(widget), -1,
"Migrated widget " + widget + " should also be listed as migrated in the other window.");
}
},
teardown: function() {
btn.remove();
btn2.remove();
CustomizableUI.reset();
},
},
];
function test() {
waitForExplicitFinish();
runTests(gTests);
}
}
} finally {
otherWindow.close();
}
btn.remove();
btn2.remove();
CustomizableUI.reset();
});

Просмотреть файл

@ -2,24 +2,16 @@
* 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 kWidgetId = "test-destroy-in-palette";
let gTests = [
{
desc: "Check destroyWidget destroys the node if it's in the palette",
run: function() {
CustomizableUI.createWidget({id: kWidgetId, label: "Test destroying widgets in palette."});
yield startCustomizing();
yield endCustomizing();
ok(gNavToolbox.palette.querySelector("#" + kWidgetId), "Widget still exists in palette.");
CustomizableUI.destroyWidget(kWidgetId);
ok(!gNavToolbox.palette.querySelector("#" + kWidgetId), "Widget no longer exists in palette.");
},
},
];
function test() {
waitForExplicitFinish();
runTests(gTests);
}
// Check destroyWidget destroys the node if it's in the palette
add_task(function() {
CustomizableUI.createWidget({id: kWidgetId, label: "Test destroying widgets in palette."});
yield startCustomizing();
yield endCustomizing();
ok(gNavToolbox.palette.querySelector("#" + kWidgetId), "Widget still exists in palette.");
CustomizableUI.destroyWidget(kWidgetId);
ok(!gNavToolbox.palette.querySelector("#" + kWidgetId), "Widget no longer exists in palette.");
});

Просмотреть файл

@ -2,41 +2,34 @@
* 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 kWidgetId = "test-private-browsing-customize-mode-widget";
let gTests = [
{
desc: "Add a widget via the API with showInPrivateBrowsing set to false " +
"and ensure it does not appear in the list of unused widgets in private windows",
run: function() {
CustomizableUI.createWidget({
id: kWidgetId,
showInPrivateBrowsing: false
});
// Add a widget via the API with showInPrivateBrowsing set to false
// and ensure it does not appear in the list of unused widgets in private
// windows.
add_task(function testPrivateBrowsingCustomizeModeWidget() {
CustomizableUI.createWidget({
id: kWidgetId,
showInPrivateBrowsing: false
});
let normalWidgetArray = CustomizableUI.getUnusedWidgets(gNavToolbox.palette);
normalWidgetArray = normalWidgetArray.map((w) => w.id);
ok(normalWidgetArray.indexOf(kWidgetId) > -1,
"Widget should appear as unused in non-private window");
let normalWidgetArray = CustomizableUI.getUnusedWidgets(gNavToolbox.palette);
normalWidgetArray = normalWidgetArray.map((w) => w.id);
ok(normalWidgetArray.indexOf(kWidgetId) > -1,
"Widget should appear as unused in non-private window");
let privateWindow = yield openAndLoadWindow({private: true});
let privateWidgetArray = CustomizableUI.getUnusedWidgets(privateWindow.gNavToolbox.palette);
privateWidgetArray = privateWidgetArray.map((w) => w.id);
is(privateWidgetArray.indexOf(kWidgetId), -1,
"Widget should not appear as unused in private window");
privateWindow.close();
let privateWindow = yield openAndLoadWindow({private: true});
let privateWidgetArray = CustomizableUI.getUnusedWidgets(privateWindow.gNavToolbox.palette);
privateWidgetArray = privateWidgetArray.map((w) => w.id);
is(privateWidgetArray.indexOf(kWidgetId), -1,
"Widget should not appear as unused in private window");
privateWindow.close();
CustomizableUI.destroyWidget(kWidgetId);
},
},
];
CustomizableUI.destroyWidget(kWidgetId);
});
function asyncCleanup() {
add_task(function asyncCleanup() {
yield resetCustomization();
}
function test() {
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,78 +2,66 @@
* 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";
let kWidgetId = "test-removable-widget-default";
const kNavBar = CustomizableUI.AREA_NAVBAR;
let widgetCounter = 0;
let gTests = [
{
desc: "Sanity checks",
run: function() {
let brokenSpec = {id: kWidgetId + (widgetCounter++), removable: false};
SimpleTest.doesThrow(function() CustomizableUI.createWidget(brokenSpec),
"Creating non-removable widget without defaultArea should throw.");
// Widget without removable set should be removable:
let wrapper = CustomizableUI.createWidget({id: kWidgetId + (widgetCounter++)});
ok(CustomizableUI.isWidgetRemovable(wrapper.id), "Should be removable by default.");
CustomizableUI.destroyWidget(wrapper.id);
registerCleanupFunction(removeCustomToolbars);
// Sanity checks
add_task(function() {
let brokenSpec = {id: kWidgetId + (widgetCounter++), removable: false};
SimpleTest.doesThrow(function() CustomizableUI.createWidget(brokenSpec),
"Creating non-removable widget without defaultArea should throw.");
// Widget without removable set should be removable:
let wrapper = CustomizableUI.createWidget({id: kWidgetId + (widgetCounter++)});
ok(CustomizableUI.isWidgetRemovable(wrapper.id), "Should be removable by default.");
CustomizableUI.destroyWidget(wrapper.id);
});
// Test non-removable widget with defaultArea
add_task(function() {
// Non-removable widget with defaultArea should work:
let spec = {id: kWidgetId + (widgetCounter++), removable: false,
defaultArea: kNavBar};
let widgetWrapper;
try {
widgetWrapper = CustomizableUI.createWidget(spec);
} catch (ex) {
ok(false, "Creating a non-removable widget with a default area should not throw.");
return;
}
let placement = CustomizableUI.getPlacementOfWidget(spec.id);
ok(placement, "Widget should be placed.");
is(placement.area, kNavBar, "Widget should be in navbar");
let singleWrapper = widgetWrapper.forWindow(window);
ok(singleWrapper, "Widget should exist in window.");
ok(singleWrapper.node, "Widget node should exist in window.");
let expectedParent = CustomizableUI.getCustomizeTargetForArea(kNavBar, window);
is(singleWrapper.node.parentNode, expectedParent, "Widget should be in navbar.");
let otherWin = yield openAndLoadWindow(true);
placement = CustomizableUI.getPlacementOfWidget(spec.id);
ok(placement, "Widget should be placed.");
is(placement && placement.area, kNavBar, "Widget should be in navbar");
singleWrapper = widgetWrapper.forWindow(otherWin);
ok(singleWrapper, "Widget should exist in other window.");
if (singleWrapper) {
ok(singleWrapper.node, "Widget node should exist in other window.");
if (singleWrapper.node) {
let expectedParent = CustomizableUI.getCustomizeTargetForArea(kNavBar, otherWin);
is(singleWrapper.node.parentNode, expectedParent,
"Widget should be in navbar in other window.");
}
},
{
desc: "Test non-removable widget with defaultArea",
run: function() {
// Non-removable widget with defaultArea should work:
let spec = {id: kWidgetId + (widgetCounter++), removable: false,
defaultArea: kNavBar};
let widgetWrapper;
try {
widgetWrapper = CustomizableUI.createWidget(spec);
} catch (ex) {
ok(false, "Creating a non-removable widget with a default area should not throw.");
return;
}
}
otherWin.close();
});
let placement = CustomizableUI.getPlacementOfWidget(spec.id);
ok(placement, "Widget should be placed.");
is(placement.area, kNavBar, "Widget should be in navbar");
let singleWrapper = widgetWrapper.forWindow(window);
ok(singleWrapper, "Widget should exist in window.");
ok(singleWrapper.node, "Widget node should exist in window.");
let expectedParent = CustomizableUI.getCustomizeTargetForArea(kNavBar, window);
is(singleWrapper.node.parentNode, expectedParent, "Widget should be in navbar.");
let otherWin = yield openAndLoadWindow(true);
placement = CustomizableUI.getPlacementOfWidget(spec.id);
ok(placement, "Widget should be placed.");
is(placement && placement.area, kNavBar, "Widget should be in navbar");
singleWrapper = widgetWrapper.forWindow(otherWin);
ok(singleWrapper, "Widget should exist in other window.");
if (singleWrapper) {
ok(singleWrapper.node, "Widget node should exist in other window.");
if (singleWrapper.node) {
let expectedParent = CustomizableUI.getCustomizeTargetForArea(kNavBar, otherWin);
is(singleWrapper.node.parentNode, expectedParent,
"Widget should be in navbar in other window.");
}
}
otherWin.close();
}
},
];
function asyncCleanup() {
add_task(function asyncCleanup() {
yield resetCustomization();
}
function cleanup() {
removeCustomToolbars();
}
function test() {
waitForExplicitFinish();
registerCleanupFunction(cleanup);
runTests(gTests, asyncCleanup);
}
});

Просмотреть файл

@ -2,52 +2,42 @@
* 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";
/**
* Test opening and closing the menu panel UI.
*/
let gTests = [
{
desc: "Show and hide the menu panel programmatically without an event (like UITour.jsm would)",
setup: null,
run: function() {
let shownPromise = promisePanelShown(window);
PanelUI.show();
yield shownPromise;
// Show and hide the menu panel programmatically without an event (like UITour.jsm would)
add_task(function() {
let shownPromise = promisePanelShown(window);
PanelUI.show();
yield shownPromise;
is(PanelUI.panel.getAttribute("panelopen"), "true", "Check that panel has panelopen attribute");
is(PanelUI.panel.state, "open", "Check that panel state is 'open'");
is(PanelUI.panel.getAttribute("panelopen"), "true", "Check that panel has panelopen attribute");
is(PanelUI.panel.state, "open", "Check that panel state is 'open'");
let hiddenPromise = promisePanelHidden(window);
PanelUI.hide();
yield hiddenPromise;
let hiddenPromise = promisePanelHidden(window);
PanelUI.hide();
yield hiddenPromise;
ok(!PanelUI.panel.hasAttribute("panelopen"), "Check that panel doesn't have the panelopen attribute");
is(PanelUI.panel.state, "closed", "Check that panel state is 'closed'");
},
},
{
desc: "Toggle the menu panel open and closed",
setup: null,
run: function() {
let shownPromise = promisePanelShown(window);
PanelUI.toggle({type: "command"});
yield shownPromise;
ok(!PanelUI.panel.hasAttribute("panelopen"), "Check that panel doesn't have the panelopen attribute");
is(PanelUI.panel.state, "closed", "Check that panel state is 'closed'");
});
is(PanelUI.panel.getAttribute("panelopen"), "true", "Check that panel has panelopen attribute");
is(PanelUI.panel.state, "open", "Check that panel state is 'open'");
// Toggle the menu panel open and closed
add_task(function() {
let shownPromise = promisePanelShown(window);
PanelUI.toggle({type: "command"});
yield shownPromise;
let hiddenPromise = promisePanelHidden(window);
PanelUI.toggle({type: "command"});
yield hiddenPromise;
is(PanelUI.panel.getAttribute("panelopen"), "true", "Check that panel has panelopen attribute");
is(PanelUI.panel.state, "open", "Check that panel state is 'open'");
ok(!PanelUI.panel.hasAttribute("panelopen"), "Check that panel doesn't have the panelopen attribute");
is(PanelUI.panel.state, "closed", "Check that panel state is 'closed'");
},
},
];
let hiddenPromise = promisePanelHidden(window);
PanelUI.toggle({type: "command"});
yield hiddenPromise;
function test() {
waitForExplicitFinish();
runTests(gTests);
}
ok(!PanelUI.panel.hasAttribute("panelopen"), "Check that panel doesn't have the panelopen attribute");
is(PanelUI.panel.state, "closed", "Check that panel state is 'closed'");
});

Просмотреть файл

@ -2,13 +2,13 @@
* 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";
// Avoid leaks by using tmp for imports...
let tmp = {};
Cu.import("resource://gre/modules/Promise.jsm", tmp);
Cu.import("resource://gre/modules/Task.jsm", tmp);
Cu.import("resource:///modules/CustomizableUI.jsm", tmp);
let {Promise, Task, CustomizableUI} = tmp;
let {Promise, CustomizableUI} = tmp;
let ChromeUtils = {};
let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
@ -109,7 +109,7 @@ function todoAssertAreaPlacements(areaId, expectedPlacements) {
}
}
todo(isPassing, "The area placements for " + areaId +
" should equal the expected placements.")
" should equal the expected placements.");
}
function getAreaWidgetIds(areaId) {
@ -128,8 +128,10 @@ function endCustomizing(aWindow=window) {
if (aWindow.document.documentElement.getAttribute("customizing") != "true") {
return true;
}
Services.prefs.setBoolPref("browser.uiCustomization.disableAnimation", true);
let deferredEndCustomizing = Promise.defer();
function onCustomizationEnds() {
Services.prefs.setBoolPref("browser.uiCustomization.disableAnimation", false);
aWindow.gNavToolbox.removeEventListener("aftercustomization", onCustomizationEnds);
deferredEndCustomizing.resolve();
}
@ -163,9 +165,11 @@ function startCustomizing(aWindow=window) {
if (aWindow.document.documentElement.getAttribute("customizing") == "true") {
return;
}
Services.prefs.setBoolPref("browser.uiCustomization.disableAnimation", true);
let deferred = Promise.defer();
function onCustomizing() {
aWindow.gNavToolbox.removeEventListener("customizationready", onCustomizing);
Services.prefs.setBoolPref("browser.uiCustomization.disableAnimation", false);
deferred.resolve();
}
aWindow.gNavToolbox.addEventListener("customizationready", onCustomizing);
@ -267,38 +271,3 @@ function waitFor(aTimeout=100) {
setTimeout(function() deferred.resolve(), aTimeout);
return deferred.promise;
}
function testRunner(testAry, asyncCleanup) {
Services.prefs.setBoolPref("browser.uiCustomization.disableAnimation", true);
for (let test of testAry) {
info(test.desc);
if (test.setup)
yield test.setup();
info("Running test");
try {
yield test.run();
} catch (ex) {
ok(false, "Unexpected exception occurred while running the test:\n" + ex);
}
info("Cleanup");
if (test.teardown)
yield test.teardown();
ok(!document.getElementById(CustomizableUI.AREA_NAVBAR).hasAttribute("overflowing"), "Shouldn't overflow");
}
if (asyncCleanup) {
yield asyncCleanup();
}
ok(CustomizableUI.inDefaultState, "Should remain in default state");
Services.prefs.clearUserPref("browser.uiCustomization.disableAnimation");
}
function runTests(testAry, asyncCleanup) {
Task.spawn(testRunner(gTests, asyncCleanup)).then(finish, ex => {
// The stack of ok() here is misleading due to Promises. The stack of the
// actual exception is likely much more valuable, hence concatentating it.
ok(false, "Unexpected exception: " + ex + " With stack: " + ex.stack);
finish();
}).then(null, Cu.reportError);
}

Просмотреть файл

@ -1499,34 +1499,12 @@ let SessionStoreInternal = {
throw Components.Exception("Window is not tracked", Cr.NS_ERROR_INVALID_ARG);
},
/**
* Restores the given state |aState| for a given window |aWindow|.
*
* @param aWindow (xul window)
* The window that the given state will be restored to.
* @param aState (string)
* The state that will be applied to the given window.
* @param aOverwrite (bool)
* When true, existing tabs in the given window will be re-used or
* removed. When false, only new tabs will be added, no existing ones
8 will be removed or overwritten.
*/
setWindowState: function ssi_setWindowState(aWindow, aState, aOverwrite) {
if (!aWindow.__SSi) {
throw Components.Exception("Window is not tracked", Cr.NS_ERROR_INVALID_ARG);
}
let winState = JSON.parse(aState);
if (!winState) {
throw Components.Exception("Invalid state string: not JSON", Cr.NS_ERROR_INVALID_ARG);
}
if (!winState.windows || !winState.windows[0]) {
throw Components.Exception("Invalid window state passed", Cr.NS_ERROR_INVALID_ARG);
}
let state = {windows: [winState.windows[0]]};
this.restoreWindow(aWindow, state, {overwriteTabs: aOverwrite});
this.restoreWindow(aWindow, aState, {overwriteTabs: aOverwrite});
},
getTabState: function ssi_getTabState(aTab) {
@ -2264,7 +2242,7 @@ let SessionStoreInternal = {
* @param aWindow
* Window reference
* @param aState
* JS object
* JS object or its eval'able source
* @param aOptions
* {overwriteTabs: true} to overwrite existing tabs w/ new ones
* {isFollowUp: true} if this is not the restoration of the 1st window
@ -2284,10 +2262,17 @@ let SessionStoreInternal = {
if (aWindow && (!aWindow.__SSi || !this._windows[aWindow.__SSi]))
this.onLoad(aWindow);
var root = aState;
if (!root.windows[0]) {
try {
var root = typeof aState == "string" ? JSON.parse(aState) : aState;
if (!root.windows[0]) {
this._sendRestoreCompletedNotifications();
return; // nothing to restore
}
}
catch (ex) { // invalid state object - don't restore anything
debug(ex);
this._sendRestoreCompletedNotifications();
return; // nothing to restore
return;
}
TelemetryStopwatch.start("FX_SESSION_RESTORE_RESTORE_WINDOW_MS");

Просмотреть файл

@ -78,38 +78,44 @@ function test() {
}
}
gPrefService.setIntPref("browser.sessionstore.max_windows_undo",
test_state._closedWindows.length);
ss.setBrowserState(JSON.stringify(test_state), true);
// open a window and add the above closed window list
let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
newWin.addEventListener("load", function(aEvent) {
this.removeEventListener("load", arguments.callee, false);
gPrefService.setIntPref("browser.sessionstore.max_windows_undo",
test_state._closedWindows.length);
ss.setWindowState(newWin, JSON.stringify(test_state), true);
let closedWindows = JSON.parse(ss.getClosedWindowData());
is(closedWindows.length, test_state._closedWindows.length,
"Closed window list has the expected length");
is(countByTitle(closedWindows, FORGET),
test_state._closedWindows.length - remember_count,
"The correct amount of windows are to be forgotten");
is(countByTitle(closedWindows, REMEMBER), remember_count,
"Everything is set up.");
let closedWindows = JSON.parse(ss.getClosedWindowData());
is(closedWindows.length, test_state._closedWindows.length,
"Closed window list has the expected length");
is(countByTitle(closedWindows, FORGET),
test_state._closedWindows.length - remember_count,
"The correct amount of windows are to be forgotten");
is(countByTitle(closedWindows, REMEMBER), remember_count,
"Everything is set up.");
// all of the following calls with illegal arguments should throw NS_ERROR_ILLEGAL_VALUE
ok(testForError(function() ss.forgetClosedWindow(-1)),
"Invalid window for forgetClosedWindow throws");
ok(testForError(function() ss.forgetClosedWindow(test_state._closedWindows.length + 1)),
"Invalid window for forgetClosedWindow throws");
// all of the following calls with illegal arguments should throw NS_ERROR_ILLEGAL_VALUE
ok(testForError(function() ss.forgetClosedWindow(-1)),
"Invalid window for forgetClosedWindow throws");
ok(testForError(function() ss.forgetClosedWindow(test_state._closedWindows.length + 1)),
"Invalid window for forgetClosedWindow throws");
// Remove third window, then first window
ss.forgetClosedWindow(2);
ss.forgetClosedWindow(null);
// Remove third window, then first window
ss.forgetClosedWindow(2);
ss.forgetClosedWindow(null);
closedWindows = JSON.parse(ss.getClosedWindowData());
is(closedWindows.length, remember_count,
"The correct amount of windows were removed");
is(countByTitle(closedWindows, FORGET), 0,
"All windows specifically forgotten were indeed removed");
is(countByTitle(closedWindows, REMEMBER), remember_count,
"... and windows not specifically forgetten weren't.");
closedWindows = JSON.parse(ss.getClosedWindowData());
is(closedWindows.length, remember_count,
"The correct amount of windows were removed");
is(countByTitle(closedWindows, FORGET), 0,
"All windows specifically forgotten were indeed removed");
is(countByTitle(closedWindows, REMEMBER), remember_count,
"... and windows not specifically forgetten weren't.");
// clean up
gPrefService.clearUserPref("browser.sessionstore.max_windows_undo");
finish();
// clean up
newWin.close();
gPrefService.clearUserPref("browser.sessionstore.max_windows_undo");
finish();
}, false);
}

Просмотреть файл

@ -645,7 +645,6 @@ just addresses the organization to follow, e.g. "This site is run by " -->
<!ENTITY syncToolbarButton.label "Sync">
<!ENTITY socialToolbar.title "Social Toolbar Button">
<!ENTITY social.notLoggedIn.label "Not logged in">
<!ENTITY social.ok.label "OK">
<!ENTITY social.ok.accesskey "O">

Просмотреть файл

@ -4,7 +4,9 @@
"use strict";
this.EXPORTED_SYMBOLS = ["Social", "OpenGraphBuilder", "DynamicResizeWatcher", "sizeSocialPanelToContent"];
this.EXPORTED_SYMBOLS = ["Social", "CreateSocialStatusWidget",
"CreateSocialMarkWidget", "OpenGraphBuilder",
"DynamicResizeWatcher", "sizeSocialPanelToContent"];
const Ci = Components.interfaces;
const Cc = Components.classes;
@ -17,6 +19,8 @@ const PANEL_MIN_WIDTH = 330;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
"resource:///modules/CustomizableUI.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SocialService",
"resource://gre/modules/SocialService.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
@ -381,6 +385,70 @@ function schedule(callback) {
Services.tm.mainThread.dispatch(callback, Ci.nsIThread.DISPATCH_NORMAL);
}
function CreateSocialStatusWidget(aId, aProvider) {
if (!aProvider.statusURL)
return;
let widget = CustomizableUI.getWidget(aId);
// The widget is only null if we've created then destroyed the widget.
// Once we've actually called createWidget the provider will be set to
// PROVIDER_API.
if (widget && widget.provider == CustomizableUI.PROVIDER_API)
return;
CustomizableUI.createWidget({
id: aId,
type: 'custom',
removable: true,
defaultArea: CustomizableUI.AREA_NAVBAR,
onBuild: function(aDocument) {
let node = aDocument.createElement('toolbarbutton');
node.id = this.id;
node.setAttribute('class', 'toolbarbutton-1 chromeclass-toolbar-additional social-status-button');
node.setAttribute('type', "badged");
node.style.listStyleImage = "url(" + (aProvider.icon32URL || aProvider.iconURL) + ")";
node.setAttribute("origin", aProvider.origin);
node.setAttribute("label", aProvider.name);
node.setAttribute("tooltiptext", aProvider.name);
node.setAttribute("oncommand", "SocialStatus.showPopup(this);");
return node;
}
});
};
function CreateSocialMarkWidget(aId, aProvider) {
if (!aProvider.markURL)
return;
let widget = CustomizableUI.getWidget(aId);
// The widget is only null if we've created then destroyed the widget.
// Once we've actually called createWidget the provider will be set to
// PROVIDER_API.
if (widget && widget.provider == CustomizableUI.PROVIDER_API)
return;
CustomizableUI.createWidget({
id: aId,
type: 'custom',
removable: true,
defaultArea: CustomizableUI.AREA_NAVBAR,
onBuild: function(aDocument) {
let node = aDocument.createElement('toolbarbutton');
node.id = this.id;
node.setAttribute('class', 'toolbarbutton-1 chromeclass-toolbar-additional social-mark-button');
node.setAttribute('type', "socialmark");
node.style.listStyleImage = "url(" + (aProvider.unmarkedIcon || aProvider.icon32URL || aProvider.iconURL) + ")";
node.setAttribute("origin", aProvider.origin);
node.setAttribute("oncommand", "this.markCurrentPage();");
let window = aDocument.defaultView;
let menuLabel = window.gNavigatorBundle.getFormattedString("social.markpageMenu.label", [aProvider.name]);
node.setAttribute("label", menuLabel);
node.setAttribute("tooltiptext", menuLabel);
return node;
}
});
};
// Error handling class used to listen for network errors in the social frames
// and replace them with a social-specific error page

Просмотреть файл

@ -123,6 +123,8 @@ browser.jar:
skin/classic/browser/social/share-button.png (social/share-button.png)
skin/classic/browser/social/share-button-active.png (social/share-button-active.png)
skin/classic/browser/social/chat-icons.png (social/chat-icons.png)
skin/classic/browser/social/gear_default.png (../shared/social/gear_default.png)
skin/classic/browser/social/gear_clicked.png (../shared/social/gear_clicked.png)
skin/classic/browser/tabbrowser/connecting.png (tabbrowser/connecting.png)
skin/classic/browser/tabbrowser/loading.png (tabbrowser/loading.png)
skin/classic/browser/tabbrowser/tab.png (tabbrowser/tab.png)

Просмотреть файл

@ -2402,11 +2402,13 @@ sidebarheader {
-moz-margin-end: -3px;
}
.sidebar-title,
#sidebar-title {
color: #535f6d;
font-weight: bold;
}
.sidebar-throbber[loading="true"],
#sidebar-throbber[loading="true"] {
list-style-image: url("chrome://global/skin/icons/loading_16.png");
}

Просмотреть файл

@ -196,6 +196,8 @@ browser.jar:
skin/classic/browser/social/services-64@2x.png (social/services-64@2x.png)
skin/classic/browser/social/chat-icons.png (social/chat-icons.png)
skin/classic/browser/social/chat-icons@2x.png (social/chat-icons@2x.png)
skin/classic/browser/social/gear_default.png (../shared/social/gear_default.png)
skin/classic/browser/social/gear_clicked.png (../shared/social/gear_clicked.png)
skin/classic/browser/tabbrowser/alltabs-box-bkgnd-icon.png (tabbrowser/alltabs-box-bkgnd-icon.png)
skin/classic/browser/tabbrowser/alltabs-box-bkgnd-icon-inverted.png (tabbrowser/alltabs-box-bkgnd-icon-inverted.png)
skin/classic/browser/tabbrowser/alltabs-box-bkgnd-icon-inverted@2x.png (tabbrowser/alltabs-box-bkgnd-icon-inverted@2x.png)

Просмотреть файл

@ -4,6 +4,36 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
%endif
#social-sidebar-header {
padding: 3px;
}
#social-sidebar-button {
-moz-appearance: none;
list-style-image: url(chrome://browser/skin/social/gear_default.png);
min-width: 16px;
padding: 0;
margin: 2px;
}
#social-sidebar-button:hover,
#social-sidebar-button:hover:active {
list-style-image: url(chrome://browser/skin/social/gear_clicked.png);
}
#social-sidebar-button > .toolbarbutton-menu-dropmarker {
display: none;
}
#social-sidebar-button[loading="true"] {
list-style-image: url("chrome://global/skin/icons/loading_16.png");
}
#social-sidebar-favico {
max-height: 16px;
max-width: 16px;
padding: 0;
margin: 2px;
}
.chat-status-icon {
max-height: 16px;
max-width: 16px;

Двоичные данные
browser/themes/shared/social/gear_clicked.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.2 KiB

Двоичные данные
browser/themes/shared/social/gear_default.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.2 KiB

Просмотреть файл

@ -52,6 +52,7 @@
border-color: hsla(206,100%,60%,.65) hsla(206,100%,55%,.65) hsla(206,100%,50%,.65);
}
.sidebar-header,
#sidebar-header {
-moz-appearance: none;
color: black;
@ -60,6 +61,7 @@
text-shadow: none;
}
.sidebar-title,
#sidebar-title {
font-weight: bold;
}

Просмотреть файл

@ -142,6 +142,8 @@ browser.jar:
skin/classic/browser/social/services-16.png (social/services-16.png)
skin/classic/browser/social/services-64.png (social/services-64.png)
skin/classic/browser/social/chat-icons.png (social/chat-icons.png)
skin/classic/browser/social/gear_default.png (../shared/social/gear_default.png)
skin/classic/browser/social/gear_clicked.png (../shared/social/gear_clicked.png)
skin/classic/browser/tabbrowser/newtab.png (tabbrowser/newtab.png)
skin/classic/browser/tabbrowser/newtab-inverted.png (tabbrowser/newtab-inverted.png)
skin/classic/browser/tabbrowser/connecting.png (tabbrowser/connecting.png)
@ -449,6 +451,8 @@ browser.jar:
skin/classic/aero/browser/social/services-16.png (social/services-16.png)
skin/classic/aero/browser/social/services-64.png (social/services-64.png)
skin/classic/aero/browser/social/chat-icons.png (social/chat-icons.png)
skin/classic/aero/browser/social/gear_default.png (../shared/social/gear_default.png)
skin/classic/aero/browser/social/gear_clicked.png (../shared/social/gear_clicked.png)
skin/classic/aero/browser/tabbrowser/newtab.png (tabbrowser/newtab.png)
skin/classic/aero/browser/tabbrowser/newtab-inverted.png (tabbrowser/newtab-inverted.png)
skin/classic/aero/browser/tabbrowser/connecting.png (tabbrowser/connecting.png)

Просмотреть файл

@ -17,8 +17,6 @@
#include "mozilla/layers/CompositableForwarder.h"
#include "mozilla/layers/LayersTypes.h"
#include "mozilla/layers/TextureClient.h" // for TextureClient, etc
#include "mozilla/layers/GrallocTextureClient.h"
#include "mozilla/layers/TextureClientOGL.h"
#include "nsAutoPtr.h" // for nsRefPtr
#include "nsDebug.h" // for printf_stderr, NS_ASSERTION
#include "nsXULAppAPI.h" // for XRE_GetProcessType, etc
@ -29,6 +27,12 @@
using namespace mozilla::gfx;
using namespace mozilla::gl;
namespace mozilla {
namespace gfx {
class SharedSurface;
}
}
namespace mozilla {
namespace layers {
@ -40,7 +44,7 @@ CanvasClient::CreateCanvasClient(CanvasClientType aType,
if (aType == CanvasClientGLContext &&
aForwarder->GetCompositorBackendType() == LAYERS_OPENGL) {
aFlags |= TEXTURE_DEALLOCATE_CLIENT;
return new CanvasClientSurfaceStream(aForwarder, aFlags);
return new DeprecatedCanvasClientSurfaceStream(aForwarder, aFlags);
}
if (gfxPlatform::GetPlatform()->UseDeprecatedTextures()) {
aFlags |= TEXTURE_DEALLOCATE_CLIENT;
@ -102,78 +106,6 @@ CanvasClient2D::CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFla
mTextureInfo.mTextureFlags | aFlags);
}
CanvasClientSurfaceStream::CanvasClientSurfaceStream(CompositableForwarder* aLayerForwarder,
TextureFlags aFlags)
: CanvasClient(aLayerForwarder, aFlags)
{
}
void
CanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
{
GLScreenBuffer* screen = aLayer->mGLContext->Screen();
SurfaceStream* stream = screen->Stream();
bool isCrossProcess = !(XRE_GetProcessType() == GeckoProcessType_Default);
bool bufferCreated = false;
if (isCrossProcess) {
#ifdef MOZ_WIDGET_GONK
SharedSurface* surf = stream->SwapConsumer();
if (!surf) {
printf_stderr("surf is null post-SwapConsumer!\n");
return;
}
if (surf->Type() != SharedSurfaceType::Gralloc) {
printf_stderr("Unexpected non-Gralloc SharedSurface in IPC path!");
MOZ_ASSERT(false);
return;
}
SharedSurface_Gralloc* grallocSurf = SharedSurface_Gralloc::Cast(surf);
if (mBuffers.find(surf) == mBuffers.end()) {
GrallocTextureClientOGL* grallocTC =
new GrallocTextureClientOGL(static_cast<GrallocBufferActor*>(grallocSurf->GetDescriptor().bufferChild()),
grallocSurf->Size(),
mTextureInfo.mTextureFlags);
mBuffers[surf] = grallocTC;
bufferCreated = true;
}
if (bufferCreated && !AddTextureClient(mBuffers[surf])) {
mBuffers.erase(surf);
}
if (mBuffers.find(surf) != mBuffers.end()) {
GetForwarder()->UseTexture(this, mBuffers[surf]);
}
#else
printf_stderr("isCrossProcess, but not MOZ_WIDGET_GONK! Someone needs to write some code!");
MOZ_ASSERT(false);
#endif
} else {
if (!mBuffer) {
StreamTextureClientOGL* textureClient =
new StreamTextureClientOGL(mTextureInfo.mTextureFlags);
textureClient->InitWith(stream);
mBuffer = textureClient;
bufferCreated = true;
}
if (bufferCreated && !AddTextureClient(mBuffer)) {
mBuffer = nullptr;
}
if (mBuffer) {
GetForwarder()->UseTexture(this, mBuffer);
}
}
aLayer->Painted();
}
void
DeprecatedCanvasClient2D::Updated()
{

Просмотреть файл

@ -18,12 +18,6 @@
#include "mozilla/gfx/Point.h" // for IntSize
#include "mozilla/gfx/Types.h" // for SurfaceFormat
namespace mozilla {
namespace gfx {
class SharedSurface;
}
}
namespace mozilla {
namespace layers {
@ -101,31 +95,6 @@ private:
RefPtr<TextureClient> mBuffer;
};
// Used for GL canvases where we don't need to do any readback, i.e., with a
// GL backend.
class CanvasClientSurfaceStream : public CanvasClient
{
public:
CanvasClientSurfaceStream(CompositableForwarder* aLayerForwarder, TextureFlags aFlags);
TextureInfo GetTextureInfo() const
{
return TextureInfo(COMPOSITABLE_IMAGE);
}
virtual void Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer) MOZ_OVERRIDE;
virtual void OnDetach() MOZ_OVERRIDE
{
mBuffers.clear();
mBuffer = nullptr;
}
private:
std::map<gfx::SharedSurface*, RefPtr<TextureClient> > mBuffers;
RefPtr<TextureClient> mBuffer;
};
class DeprecatedCanvasClient2D : public CanvasClient
{
public:

Просмотреть файл

@ -51,11 +51,11 @@ public:
"Can only set properties in construction phase");
CanvasLayer::SetVisibleRegion(aRegion);
}
virtual void Initialize(const Data& aData);
virtual void RenderLayer();
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
{
aAttrs = CanvasLayerAttributes(mFilter, mBounds);
@ -63,7 +63,7 @@ public:
virtual Layer* AsLayer() { return this; }
virtual ShadowableLayer* AsShadowableLayer() { return this; }
virtual void Disconnect()
{
mCanvasClient = nullptr;
@ -79,7 +79,7 @@ protected:
{
return static_cast<ClientLayerManager*>(mManager);
}
CanvasClientType GetCanvasClientType()
{
if (mGLContext) {
@ -93,7 +93,6 @@ protected:
friend class DeprecatedCanvasClient2D;
friend class CanvasClient2D;
friend class DeprecatedCanvasClientSurfaceStream;
friend class CanvasClientSurfaceStream;
};
}
}

Просмотреть файл

@ -4,7 +4,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/layers/TextureClientOGL.h"
#include "SurfaceStream.h"
#include "GLContext.h" // for GLContext, etc
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/layers/ISurfaceAllocator.h"
@ -67,42 +66,6 @@ SharedTextureClientOGL::IsAllocated() const
return mHandle != 0;
}
StreamTextureClientOGL::StreamTextureClientOGL(TextureFlags aFlags)
: TextureClient(aFlags)
, mStream(0)
{
}
StreamTextureClientOGL::~StreamTextureClientOGL()
{
// the data is owned externally.
}
bool
StreamTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
{
if (!IsAllocated()) {
return false;
}
gfx::SurfaceStreamHandle handle = mStream->GetShareHandle();
aOutDescriptor = SurfaceStreamDescriptor(handle, false);
return true;
}
void
StreamTextureClientOGL::InitWith(gfx::SurfaceStream* aStream)
{
MOZ_ASSERT(!IsAllocated());
mStream = aStream;
}
bool
StreamTextureClientOGL::IsAllocated() const
{
return mStream != 0;
}
DeprecatedTextureClientSharedOGL::DeprecatedTextureClientSharedOGL(CompositableForwarder* aForwarder,
const TextureInfo& aTextureInfo)
: DeprecatedTextureClient(aForwarder, aTextureInfo)

Просмотреть файл

@ -14,12 +14,6 @@
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
#include "mozilla/layers/TextureClient.h" // for DeprecatedTextureClient, etc
namespace mozilla {
namespace gfx {
class SurfaceStream;
}
}
namespace mozilla {
namespace layers {
@ -63,30 +57,6 @@ protected:
bool mInverted;
};
/**
* A TextureClient implementation to share SurfaceStream.
*/
class StreamTextureClientOGL : public TextureClient
{
public:
StreamTextureClientOGL(TextureFlags aFlags);
~StreamTextureClientOGL();
virtual bool IsAllocated() const MOZ_OVERRIDE;
virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE;
virtual TextureClientData* DropTextureData() MOZ_OVERRIDE { return nullptr; }
void InitWith(gfx::SurfaceStream* aStream);
virtual gfx::IntSize GetSize() const { return gfx::IntSize(); }
protected:
gfx::SurfaceStream* mStream;
};
class DeprecatedTextureClientSharedOGL : public DeprecatedTextureClient
{
public:

Просмотреть файл

@ -109,11 +109,6 @@ CreateTextureHostOGL(const SurfaceDescriptor& aDesc,
desc.inverted());
break;
}
case SurfaceDescriptor::TSurfaceStreamDescriptor: {
const SurfaceStreamDescriptor& desc = aDesc.get_SurfaceStreamDescriptor();
result = new StreamTextureHostOGL(aFlags, desc);
break;
}
#ifdef XP_MACOSX
case SurfaceDescriptor::TSurfaceDescriptorMacIOSurface: {
const SurfaceDescriptorMacIOSurface& desc =
@ -460,178 +455,6 @@ SharedTextureHostOGL::GetFormat() const
return mTextureSource->GetFormat();
}
void
StreamTextureSourceOGL::BindTexture(GLenum activetex)
{
MOZ_ASSERT(gl());
gl()->fActiveTexture(activetex);
gl()->fBindTexture(mTextureTarget, mTextureHandle);
}
bool
StreamTextureSourceOGL::RetrieveTextureFromStream()
{
gl()->MakeCurrent();
SharedSurface* sharedSurf = mStream->SwapConsumer();
if (!sharedSurf) {
// We don't have a valid surf to show yet.
return false;
}
gl()->MakeCurrent();
mSize = IntSize(sharedSurf->Size().width, sharedSurf->Size().height);
gfxImageSurface* toUpload = nullptr;
switch (sharedSurf->Type()) {
case SharedSurfaceType::GLTextureShare: {
SharedSurface_GLTexture* glTexSurf = SharedSurface_GLTexture::Cast(sharedSurf);
glTexSurf->SetConsumerGL(gl());
mTextureHandle = glTexSurf->Texture();
mTextureTarget = glTexSurf->TextureTarget();
MOZ_ASSERT(mTextureHandle);
mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8
: FORMAT_R8G8B8X8;
break;
}
case SharedSurfaceType::EGLImageShare: {
SharedSurface_EGLImage* eglImageSurf =
SharedSurface_EGLImage::Cast(sharedSurf);
mTextureHandle = eglImageSurf->AcquireConsumerTexture(gl());
mTextureTarget = eglImageSurf->TextureTarget();
if (!mTextureHandle) {
toUpload = eglImageSurf->GetPixels();
MOZ_ASSERT(toUpload);
} else {
mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8
: FORMAT_R8G8B8X8;
}
break;
}
#ifdef XP_MACOSX
case SharedSurfaceType::IOSurface: {
SharedSurface_IOSurface* glTexSurf = SharedSurface_IOSurface::Cast(sharedSurf);
mTextureHandle = glTexSurf->Texture();
mTextureTarget = glTexSurf->TextureTarget();
MOZ_ASSERT(mTextureHandle);
mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8
: FORMAT_R8G8B8X8;
break;
}
#endif
case SharedSurfaceType::Basic: {
toUpload = SharedSurface_Basic::Cast(sharedSurf)->GetData();
MOZ_ASSERT(toUpload);
break;
}
default:
MOZ_CRASH("Invalid SharedSurface type.");
}
if (toUpload) {
// mBounds seems to end up as (0,0,0,0) a lot, so don't use it?
nsIntSize size(toUpload->GetSize());
nsIntRect rect(nsIntPoint(0,0), size);
nsIntRegion bounds(rect);
mFormat = UploadSurfaceToTexture(gl(),
toUpload,
bounds,
mUploadTexture,
true);
mTextureHandle = mUploadTexture;
mTextureTarget = LOCAL_GL_TEXTURE_2D;
}
MOZ_ASSERT(mTextureHandle);
gl()->fBindTexture(mTextureTarget, mTextureHandle);
gl()->fTexParameteri(mTextureTarget,
LOCAL_GL_TEXTURE_WRAP_S,
LOCAL_GL_CLAMP_TO_EDGE);
gl()->fTexParameteri(mTextureTarget,
LOCAL_GL_TEXTURE_WRAP_T,
LOCAL_GL_CLAMP_TO_EDGE);
return true;
}
void
StreamTextureSourceOGL::DeallocateDeviceData()
{
if (mUploadTexture) {
MOZ_ASSERT(gl());
gl()->MakeCurrent();
gl()->fDeleteTextures(1, &mUploadTexture);
mUploadTexture = 0;
mTextureHandle = 0;
}
}
gl::GLContext*
StreamTextureSourceOGL::gl() const
{
return mCompositor ? mCompositor->gl() : nullptr;
}
StreamTextureHostOGL::StreamTextureHostOGL(TextureFlags aFlags,
const SurfaceStreamDescriptor& aDesc)
: TextureHost(aFlags)
{
mStream = SurfaceStream::FromHandle(aDesc.handle());
MOZ_ASSERT(mStream);
}
StreamTextureHostOGL::~StreamTextureHostOGL()
{
// If need to deallocate textures, call DeallocateSharedData() before
// the destructor
}
bool
StreamTextureHostOGL::Lock()
{
if (!mCompositor) {
return false;
}
if (!mTextureSource) {
mTextureSource = new StreamTextureSourceOGL(mCompositor,
mStream);
}
return mTextureSource->RetrieveTextureFromStream();
}
void
StreamTextureHostOGL::Unlock()
{
}
void
StreamTextureHostOGL::SetCompositor(Compositor* aCompositor)
{
CompositorOGL* glCompositor = static_cast<CompositorOGL*>(aCompositor);
mCompositor = glCompositor;
if (mTextureSource) {
mTextureSource->SetCompositor(glCompositor);
}
}
gfx::SurfaceFormat
StreamTextureHostOGL::GetFormat() const
{
MOZ_ASSERT(mTextureSource);
return mTextureSource->GetFormat();
}
gfx::IntSize
StreamTextureHostOGL::GetSize() const
{
MOZ_ASSERT(mTextureSource);
return mTextureSource->GetSize();
}
TextureImageDeprecatedTextureHostOGL::~TextureImageDeprecatedTextureHostOGL()
{
MOZ_COUNT_DTOR(TextureImageDeprecatedTextureHostOGL);

Просмотреть файл

@ -333,108 +333,6 @@ protected:
RefPtr<SharedTextureSourceOGL> mTextureSource;
};
/**
* A texture source meant for use with StreamTextureHostOGL.
*
* It does not own any texture, we get texture from SurfaceStream.
*/
class StreamTextureSourceOGL : public NewTextureSource
, public TextureSourceOGL
{
public:
StreamTextureSourceOGL(CompositorOGL* aCompositor,
gfx::SurfaceStream* aStream)
: mCompositor(aCompositor)
, mStream(aStream)
, mTextureHandle(0)
, mTextureTarget(LOCAL_GL_TEXTURE_2D)
, mUploadTexture(0)
, mFormat(gfx::FORMAT_UNKNOWN)
{
MOZ_COUNT_CTOR(StreamTextureSourceOGL);
}
~StreamTextureSourceOGL()
{
MOZ_COUNT_DTOR(StreamTextureSourceOGL);
}
virtual TextureSourceOGL* AsSourceOGL() { return this; }
virtual void BindTexture(GLenum activetex) MOZ_OVERRIDE;
virtual bool IsValid() const MOZ_OVERRIDE { return !!gl(); }
virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; }
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; }
virtual GLenum GetTextureTarget() const { return mTextureTarget; }
virtual GLenum GetWrapMode() const MOZ_OVERRIDE { return LOCAL_GL_CLAMP_TO_EDGE; }
virtual void DeallocateDeviceData();
bool RetrieveTextureFromStream();
void SetCompositor(CompositorOGL* aCompositor) { mCompositor = aCompositor; }
protected:
gl::GLContext* gl() const;
CompositorOGL* mCompositor;
gfx::SurfaceStream* mStream;
GLuint mTextureHandle;
GLenum mTextureTarget;
GLuint mUploadTexture;
gfx::IntSize mSize;
gfx::SurfaceFormat mFormat;
};
/**
* A TextureHost for shared SurfaceStream
*/
class StreamTextureHostOGL : public TextureHost
{
public:
StreamTextureHostOGL(TextureFlags aFlags,
const SurfaceStreamDescriptor& aDesc);
virtual ~StreamTextureHostOGL();
// SharedTextureHostOGL doesn't own any GL texture
virtual void DeallocateDeviceData() MOZ_OVERRIDE {}
virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
virtual bool Lock() MOZ_OVERRIDE;
virtual void Unlock() MOZ_OVERRIDE;
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE
{
return mTextureSource;
}
virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE
{
return nullptr; // XXX - implement this (for MOZ_DUMP_PAINTING)
}
virtual gfx::IntSize GetSize() const MOZ_OVERRIDE;
#ifdef MOZ_LAYERS_HAVE_LOG
virtual const char* Name() { return "StreamTextureHostOGL"; }
#endif
protected:
CompositorOGL* mCompositor;
gfx::SurfaceStream* mStream;
RefPtr<StreamTextureSourceOGL> mTextureSource;
};
/**
* DeprecatedTextureHost implementation using a TextureImage as the underlying texture.
*/

Просмотреть файл

@ -21,7 +21,6 @@ import org.mozilla.gecko.db.BrowserContract.Thumbnails;
import org.mozilla.gecko.db.BrowserContract.URLColumns;
import org.mozilla.gecko.db.PerProfileDatabases.DatabaseHelperFactory;
import org.mozilla.gecko.gfx.BitmapUtils;
import org.mozilla.gecko.mozglue.RobocopTarget;
import org.mozilla.gecko.sync.Utils;
import org.mozilla.gecko.util.GeckoJarReader;
import org.mozilla.gecko.util.ThreadUtils;
@ -1954,11 +1953,6 @@ public class BrowserProvider extends ContentProvider {
}
}
@RobocopTarget
public String getDatabasePath(String profile, boolean isTest) {
return mDatabases.getDatabasePathForProfile(profile, isTest);
}
private SQLiteDatabase getReadableDatabase(Uri uri) {
trace("Getting readable database for URI: " + uri);

Просмотреть файл

@ -35,14 +35,6 @@ public class PerProfileDatabases<T extends SQLiteOpenHelper> {
}
public String getDatabasePathForProfile(String profile) {
return getDatabasePathForProfile(profile, false);
}
public String getDatabasePathForProfile(String profile, boolean isTest) {
if (isTest) {
return mDatabaseName;
}
final File profileDir = GeckoProfile.get(mContext, profile).getDir();
if (profileDir == null) {
return null;
@ -66,7 +58,7 @@ public class PerProfileDatabases<T extends SQLiteOpenHelper> {
return mStorages.get(profile);
}
final String databasePath = getDatabasePathForProfile(profile, isTest);
final String databasePath = isTest ? mDatabaseName : getDatabasePathForProfile(profile);
if (databasePath == null) {
throw new IllegalStateException("Database path is null for profile: " + profile);
}

Просмотреть файл

@ -13,7 +13,6 @@ import org.mozilla.gecko.GeckoProfile;
import org.mozilla.gecko.db.BrowserContract.Clients;
import org.mozilla.gecko.db.BrowserContract.Tabs;
import org.mozilla.gecko.db.PerProfileDatabases.DatabaseHelperFactory;
import org.mozilla.gecko.mozglue.RobocopTarget;
import android.content.ContentProvider;
import android.content.ContentUris;
@ -208,11 +207,6 @@ public class TabsProvider extends ContentProvider {
}
}
@RobocopTarget
private String getDatabasePath(String profile) {
return mDatabases.getDatabasePathForProfile(profile);
}
private SQLiteDatabase getReadableDatabase(Uri uri) {
trace("Getting readable database for URI: " + uri);

Просмотреть файл

@ -47,6 +47,7 @@ abstract class ContentProviderTest extends BaseTest {
protected ChangeRecordingMockContentResolver mResolver;
protected ClassLoader mClassLoader;
protected ArrayList<Runnable> mTests;
protected String mDatabaseName;
protected Class mProviderClass;
protected Class mProviderContract;
protected String mProviderAuthority;
@ -228,15 +229,16 @@ abstract class ContentProviderTest extends BaseTest {
@Override
public void setUp() throws Exception {
throw new Exception("You should call setUp(providerClassName, authorityUriField) instead");
throw new Exception("You should call setUp(providerClassName, authorityUriField, databaseName) instead");
}
// TODO: Take the actual class as an arg.
public void setUp(String providerClassName, String authorityUriField) throws Exception {
public void setUp(String providerClassName, String authorityUriField, String databaseName) throws Exception {
super.setUp();
mClassLoader = getInstrumentation().getContext().getClassLoader();
mTests = new ArrayList<Runnable>();
mDatabaseName = databaseName;
setUpProviderClassAndAuthority(providerClassName, authorityUriField);
setUpContentProvider();
@ -248,16 +250,9 @@ abstract class ContentProviderTest extends BaseTest {
mProvider.shutdown();
}
String databaseName = null;
Method getDatabasePath =
mProviderClass.getDeclaredMethod("getDatabasePath", String.class, boolean.class);
String defaultProfile = "default";
ContentProvider targetProvider = (ContentProvider) mProviderClass.newInstance();
databaseName = (String) getDatabasePath.invoke(targetProvider, defaultProfile, true /* is test */);
if (databaseName != null)
mProviderContext.deleteDatabase(databaseName);
if (mDatabaseName != null) {
mProviderContext.deleteDatabase(mDatabaseName);
}
super.tearDown();
}

Просмотреть файл

@ -323,7 +323,7 @@ public class testBrowserProvider extends ContentProviderTest {
@Override
public void setUp() throws Exception {
super.setUp("org.mozilla.gecko.db.BrowserProvider", "AUTHORITY");
super.setUp("org.mozilla.gecko.db.BrowserProvider", "AUTHORITY", "browser.db");
loadContractInfo();
mTests.add(new TestSpecialFolders());

Просмотреть файл

@ -233,7 +233,7 @@ public class testBrowserProviderPerf extends ContentProviderTest {
@Override
public void setUp() throws Exception {
super.setUp("org.mozilla.gecko.db.BrowserProvider", "AUTHORITY");
super.setUp("org.mozilla.gecko.db.BrowserProvider", "AUTHORITY", "browser.db");
mGenerator = new Random(19580427);

Просмотреть файл

@ -303,7 +303,7 @@ public class testDistribution extends ContentProviderTest {
@Override
public void setUp() throws Exception {
// TODO: Set up the content provider after setting the distribution.
super.setUp("org.mozilla.gecko.db.BrowserProvider", "AUTHORITY");
super.setUp("org.mozilla.gecko.db.BrowserProvider", "AUTHORITY", "browser.db");
}
private void delete(File file) throws Exception {

Просмотреть файл

@ -523,10 +523,9 @@ this.FxAccounts.prototype = Object.freeze({
return null;
}
if (!internal.isUserEmailVerified(data)) {
// If the email is not verified, start polling for verification,
// but return null right away. We don't want to return a promise
// that might not be fulfilled for a long time.
internal.startVerifiedCheck(credentials);
// If the email is not verified, start polling for verification and
// return the unverified account credentials.
internal.startVerifiedCheck(data);
}
return data;
});

Просмотреть файл

@ -36,11 +36,11 @@ def run_marionette(tests, b2g_path=None, emulator=None, testtype=None,
address=None, bin=None, topsrcdir=None):
from marionette.runtests import (
MarionetteTestRunner,
MarionetteTestOptions,
BaseMarionetteOptions,
startTestRunner
)
parser = MarionetteTestOptions()
parser = BaseMarionetteOptions()
options, args = parser.parse_args()
if not tests:

Просмотреть файл

@ -654,7 +654,7 @@ this.SocialService = {
if (!manifest)
throw new Error("Cannot install provider without manifest data");
installer = new AddonInstaller(sourceURI, manifest, installCallback);
installer.install();
this._showInstallNotification(aDOMDocument, installer);
break;
default:
throw new Error("SocialService.installProvider: Invalid install type "+installType+"\n");