diff --git a/addon-sdk/source/lib/sdk/content/sandbox.js b/addon-sdk/source/lib/sdk/content/sandbox.js index d63ca8c54161..1676ebb3e333 100644 --- a/addon-sdk/source/lib/sdk/content/sandbox.js +++ b/addon-sdk/source/lib/sdk/content/sandbox.js @@ -74,7 +74,10 @@ const WorkerSandbox = Class({ * Mainly used by context-menu in order to avoid breaking it. */ emitSync: function emitSync(...args) { - return emitToContent(this, args); + // because the arguments could be also non JSONable values, + // we need to ensure the array instance is created from + // the content's sandbox + return emitToContent(this, new modelFor(this).sandbox.Array(...args)); }, /** diff --git a/addon-sdk/source/lib/sdk/panel/window.js b/addon-sdk/source/lib/sdk/panel/window.js index 47ca21d64f17..22a829e4c00a 100644 --- a/addon-sdk/source/lib/sdk/panel/window.js +++ b/addon-sdk/source/lib/sdk/panel/window.js @@ -35,10 +35,14 @@ function getWindow(anchor) { } // Check if the anchor is in a browser tab in this browser window. - let browser = enumWindow.gBrowser.getBrowserForDocument(anchorDocument); - if (browser) { - window = enumWindow; - break; + try { + let browser = enumWindow.gBrowser.getBrowserForDocument(anchorDocument); + if (browser) { + window = enumWindow; + break; + } + } + catch (e) { } // Look in other subdocuments (sidebar, etc.)? diff --git a/browser/components/customizableui/test/browser.ini b/browser/components/customizableui/test/browser.ini index b7f7a6075e31..00a09c2d5386 100644 --- a/browser/components/customizableui/test/browser.ini +++ b/browser/components/customizableui/test/browser.ini @@ -135,6 +135,7 @@ skip-if = os == "linux" [browser_989751_subviewbutton_class.js] [browser_987177_destroyWidget_xul.js] [browser_987177_xul_wrapper_updating.js] +[browser_987185_syncButton.js] [browser_987492_window_api.js] [browser_987640_charEncoding.js] [browser_992747_toggle_noncustomizable_toolbar.js] diff --git a/browser/components/customizableui/test/browser_987185_syncButton.js b/browser/components/customizableui/test/browser_987185_syncButton.js new file mode 100755 index 000000000000..71fac1e86f62 --- /dev/null +++ b/browser/components/customizableui/test/browser_987185_syncButton.js @@ -0,0 +1,69 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +"use strict"; + +let syncService = {}; +Components.utils.import("resource://services-sync/service.js", syncService); + +let needsSetup; +let originalSync; +let service = syncService.Service; +let syncWasCalled = false; + +add_task(function* testSyncButtonFunctionality() { + info("Check Sync button functionality"); + storeInitialValues(); + mockFunctions(); + + // add the Sync button to the panel + CustomizableUI.addWidgetToArea("sync-button", CustomizableUI.AREA_PANEL); + + // check the button's functionality + yield PanelUI.show(); + info("The panel menu was opened"); + + let syncButton = document.getElementById("sync-button"); + ok(syncButton, "The Sync button was added to the Panel Menu"); + syncButton.click(); + info("The sync button was clicked"); + + yield waitForCondition(() => syncWasCalled); +}); + +add_task(function* asyncCleanup() { + // reset the panel UI to the default state + yield resetCustomization(); + ok(CustomizableUI.inDefaultState, "The panel UI is in default state again."); + + if (isPanelUIOpen()) { + let panelHidePromise = promisePanelHidden(window); + PanelUI.hide(); + yield panelHidePromise; + } + + restoreValues(); +}); + +function mockFunctions() { + // mock needsSetup + gSyncUI._needsSetup = function() false; + + // mock service.errorHandler.syncAndReportErrors() + service.errorHandler.syncAndReportErrors = mocked_syncAndReportErrors; +} + +function mocked_syncAndReportErrors() { + syncWasCalled = true; +} + +function restoreValues() { + gSyncUI._needsSetup = needsSetup; + service.sync = originalSync; +} + +function storeInitialValues() { + needsSetup = gSyncUI._needsSetup; + originalSync = service.sync; +} diff --git a/browser/components/loop/content/js/panel.js b/browser/components/loop/content/js/panel.js index 58793f96d5c7..134747ecbb45 100644 --- a/browser/components/loop/content/js/panel.js +++ b/browser/components/loop/content/js/panel.js @@ -55,7 +55,9 @@ loop.panel = (function(_, mozL10n) { }, this); return ( React.DOM.div({className: "tab-view-container"}, - React.DOM.ul({className: "tab-view"}, tabButtons), + !this.props.buttonsHidden + ? React.DOM.ul({className: "tab-view"}, tabButtons) + : null, tabs ) ); @@ -439,6 +441,7 @@ loop.panel = (function(_, mozL10n) { // Mostly used for UI components showcase and unit tests callUrl: React.PropTypes.string, userProfile: React.PropTypes.object, + showTabButtons: React.PropTypes.bool, }, getInitialState: function() { @@ -475,7 +478,12 @@ loop.panel = (function(_, mozL10n) { }, _onStatusChanged: function() { - this.setState({userProfile: navigator.mozLoop.userProfile}); + var profile = navigator.mozLoop.userProfile; + if (profile != this.state.userProfile) { + // On profile change (login, logout), switch back to the default tab. + this.selectTab("call"); + } + this.setState({userProfile: profile}); this.updateServiceErrors(); }, @@ -508,7 +516,7 @@ loop.panel = (function(_, mozL10n) { React.DOM.div(null, NotificationListView({notifications: this.props.notifications, clearOnDocumentHidden: true}), - TabView({ref: "tabView"}, + TabView({ref: "tabView", buttonsHidden: !this.state.userProfile && !this.props.showTabButtons}, Tab({name: "call"}, React.DOM.div({className: "content-area"}, CallUrlResult({client: this.props.client, diff --git a/browser/components/loop/content/js/panel.jsx b/browser/components/loop/content/js/panel.jsx index 29f666f0544e..def5147c96f9 100644 --- a/browser/components/loop/content/js/panel.jsx +++ b/browser/components/loop/content/js/panel.jsx @@ -55,7 +55,9 @@ loop.panel = (function(_, mozL10n) { }, this); return (