From 8f9be8ed3ae68e0a15dd2add1694553a46334d4f Mon Sep 17 00:00:00 2001 From: "Bellindira Castillo [:bellindira]" Date: Thu, 13 Sep 2012 18:23:50 -0600 Subject: [PATCH 01/10] Bug 744610 - Page Thumbnails - WARNING: Surface width or height less than 0: file gfx/thebes/gfxASurface.cpp; r=ttaubert --- browser/components/thumbnails/PageThumbs.jsm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/components/thumbnails/PageThumbs.jsm b/browser/components/thumbnails/PageThumbs.jsm index dec242e01b3e..b9922e037bd3 100644 --- a/browser/components/thumbnails/PageThumbs.jsm +++ b/browser/components/thumbnails/PageThumbs.jsm @@ -224,7 +224,7 @@ let PageThumbs = { let sh = aWindow.innerHeight; let {width: thumbnailWidth, height: thumbnailHeight} = aCanvas; - let scale = Math.max(thumbnailWidth / sw, thumbnailHeight / sh); + let scale = Math.min(Math.max(thumbnailWidth / sw, thumbnailHeight / sh), 1); let scaledWidth = sw * scale; let scaledHeight = sh * scale; From 340e310a98ee302c12872327b0d96ae77e60c5c9 Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Mon, 17 Sep 2012 17:19:23 +0200 Subject: [PATCH 02/10] Bug 791676 - [New Tab Page] don't start transition for dynamically created elements off a timeout; r=dao --- browser/base/content/newtab/updater.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/browser/base/content/newtab/updater.js b/browser/base/content/newtab/updater.js index 1b9310466346..5ecff71adeae 100644 --- a/browser/base/content/newtab/updater.js +++ b/browser/base/content/newtab/updater.js @@ -171,10 +171,10 @@ let gUpdater = { // Set the site's initial opacity to zero. site.node.style.opacity = 0; - // Without the setTimeout() the node would just appear instead of fade in. - setTimeout(function () { - gTransformation.showSite(site, function () batch.pop()); - }, 0); + // Flush all style changes for the dynamically inserted site to make + // the fade-in transition work. + window.getComputedStyle(site.node).opacity; + gTransformation.showSite(site, function () batch.pop()); }); batch.close(); From 2267136e3c90367e0673e53f0501d26044c3e022 Mon Sep 17 00:00:00 2001 From: Andres Hernandez Date: Mon, 10 Sep 2012 10:54:41 -0600 Subject: [PATCH 03/10] Bug 721165 - Extract repeated code for retrieving CHANNEL information from Blocklist and Telemetry to a javascript module r=gavin --- toolkit/components/telemetry/TelemetryPing.js | 40 ++------------- .../components/urlformatter/nsURLFormatter.js | 30 ++---------- toolkit/content/Makefile.in | 1 + toolkit/content/UpdateChannel.jsm | 40 +++++++++++++++ .../mozapps/extensions/nsBlocklistService.js | 42 ++-------------- toolkit/mozapps/update/nsUpdateService.js | 49 +++---------------- 6 files changed, 57 insertions(+), 145 deletions(-) create mode 100644 toolkit/content/UpdateChannel.jsm diff --git a/toolkit/components/telemetry/TelemetryPing.js b/toolkit/components/telemetry/TelemetryPing.js index 892537601a3f..8508965add30 100644 --- a/toolkit/components/telemetry/TelemetryPing.js +++ b/toolkit/components/telemetry/TelemetryPing.js @@ -82,6 +82,8 @@ XPCOMUtils.defineLazyServiceGetter(this, "Telemetry", XPCOMUtils.defineLazyServiceGetter(this, "idleService", "@mozilla.org/widget/idleservice;1", "nsIIdleService"); +XPCOMUtils.defineLazyModuleGetter(this, "UpdateChannel", + "resource://gre/modules/UpdateChannel.jsm"); function generateUUID() { let str = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator).generateUUID().toString(); @@ -143,42 +145,6 @@ function getSimpleMeasurements() { return ret; } -/** - * Read the update channel from defaults only. We do this to ensure that - * the channel is tightly coupled with the application and does not apply - * to other installations of the application that may use the same profile. - */ -function getUpdateChannel() { - var channel = "default"; - var prefName; - var prefValue; - - var defaults = Services.prefs.getDefaultBranch(null); - try { - channel = defaults.getCharPref("app.update.channel"); - } catch (e) { - // use default when pref not found - } - - try { - var partners = Services.prefs.getChildList("app.partner."); - if (partners.length) { - channel += "-cck"; - partners.sort(); - - for each (prefName in partners) { - prefValue = Services.prefs.getCharPref(prefName); - channel += "-" + prefValue; - } - } - } - catch (e) { - Cu.reportError(e); - } - - return channel; -} - /** * Read current process I/O counters. */ @@ -359,7 +325,7 @@ TelemetryPing.prototype = { appVersion: ai.version, appName: ai.name, appBuildID: ai.appBuildID, - appUpdateChannel: getUpdateChannel(), + appUpdateChannel: UpdateChannel.get(), platformBuildID: ai.platformBuildID, locale: getLocale() }; diff --git a/toolkit/components/urlformatter/nsURLFormatter.js b/toolkit/components/urlformatter/nsURLFormatter.js index c0f7ce7846c1..82b610ebd3a5 100644 --- a/toolkit/components/urlformatter/nsURLFormatter.js +++ b/toolkit/components/urlformatter/nsURLFormatter.js @@ -20,11 +20,12 @@ const Cu = Components.utils; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); -const PREF_APP_UPDATE_CHANNEL = "app.update.channel"; -const PREF_PARTNER_BRANCH = "app.partner."; const PREF_APP_DISTRIBUTION = "distribution.id"; const PREF_APP_DISTRIBUTION_VERSION = "distribution.version"; +XPCOMUtils.defineLazyModuleGetter(this, "UpdateChannel", + "resource://gre/modules/UpdateChannel.jsm"); + function nsURLFormatterService() { XPCOMUtils.defineLazyGetter(this, "appInfo", function UFS_appInfo() { return Cc["@mozilla.org/xre/app-info;1"]. @@ -62,29 +63,6 @@ function nsURLFormatterService() { return encodeURIComponent(OSVersion); }); - XPCOMUtils.defineLazyGetter(this, "updateChannel", function UFS_updateChannel() { - // Read the update channel from defaults only. We do this to ensure that - // the channel is tightly coupled with the application and does not apply - // to other instances of the application that may use the same profile. - let channel = "default"; - let defaults = Services.prefs.getDefaultBranch(null); - try { - channel = defaults.getCharPref(PREF_APP_UPDATE_CHANNEL); - } catch (e) {} - - try { - let partners = Services.prefs.getChildList(PREF_PARTNER_BRANCH).sort(); - if (partners.length) { - channel += "-cck"; - partners.forEach(function (prefName) { - channel += "-" + Services.prefs.getCharPref(prefName); - }); - } - } catch (e) {} - - return channel; - }); - XPCOMUtils.defineLazyGetter(this, "distribution", function UFS_distribution() { let distribution = { id: "default", version: "default" }; @@ -120,7 +98,7 @@ nsURLFormatterService.prototype = { XPCOMABI: function() this.ABI, BUILD_TARGET: function() this.appInfo.OS + "_" + this.ABI, OS_VERSION: function() this.OSVersion, - CHANNEL: function() this.updateChannel, + CHANNEL: function() UpdateChannel.get(), DISTRIBUTION: function() this.distribution.id, DISTRIBUTION_VERSION: function() this.distribution.version }, diff --git a/toolkit/content/Makefile.in b/toolkit/content/Makefile.in index 36217adad5a9..7763377ea78b 100644 --- a/toolkit/content/Makefile.in +++ b/toolkit/content/Makefile.in @@ -67,6 +67,7 @@ EXTRA_JS_MODULES = \ PrivateBrowsingUtils.jsm \ PropertyListUtils.jsm \ Task.jsm \ + UpdateChannel.jsm \ $(NULL) EXTRA_PP_JS_MODULES = \ diff --git a/toolkit/content/UpdateChannel.jsm b/toolkit/content/UpdateChannel.jsm new file mode 100644 index 000000000000..46237e95b98d --- /dev/null +++ b/toolkit/content/UpdateChannel.jsm @@ -0,0 +1,40 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const EXPORTED_SYMBOLS = ["UpdateChannel"]; + +const Cu = Components.utils; + +Cu.import("resource://gre/modules/Services.jsm"); + +let UpdateChannel = { + /** + * Read the update channel from defaults only. We do this to ensure that + * the channel is tightly coupled with the application and does not apply + * to other instances of the application that may use the same profile. + */ + get: function UpdateChannel_get() { + let channel = "default"; + let defaults = Services.prefs.getDefaultBranch(null); + try { + channel = defaults.getCharPref("app.update.channel"); + } catch (e) { + // use default when pref not found + } + + try { + let partners = Services.prefs.getChildList("app.partner.").sort(); + if (partners.length) { + channel += "-cck"; + partners.forEach(function (prefName) { + channel += "-" + Services.prefs.getCharPref(prefName); + }); + } + } catch (e) { + Cu.reportError(e); + } + + return channel; + } +}; diff --git a/toolkit/mozapps/extensions/nsBlocklistService.js b/toolkit/mozapps/extensions/nsBlocklistService.js index e2e6d61874ad..e0d7099c5a45 100644 --- a/toolkit/mozapps/extensions/nsBlocklistService.js +++ b/toolkit/mozapps/extensions/nsBlocklistService.js @@ -16,6 +16,8 @@ Components.utils.import("resource://gre/modules/Services.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "FileUtils", "resource://gre/modules/FileUtils.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "UpdateChannel", + "resource://gre/modules/UpdateChannel.jsm"); const TOOLKIT_ID = "toolkit@mozilla.org" const KEY_PROFILEDIR = "ProfD"; @@ -31,10 +33,8 @@ const PREF_BLOCKLIST_PINGCOUNTTOTAL = "extensions.blocklist.pingCountTotal"; const PREF_BLOCKLIST_PINGCOUNTVERSION = "extensions.blocklist.pingCountVersion"; const PREF_PLUGINS_NOTIFYUSER = "plugins.update.notifyUser"; const PREF_GENERAL_USERAGENT_LOCALE = "general.useragent.locale"; -const PREF_PARTNER_BRANCH = "app.partner."; const PREF_APP_DISTRIBUTION = "distribution.id"; const PREF_APP_DISTRIBUTION_VERSION = "distribution.version"; -const PREF_APP_UPDATE_CHANNEL = "app.update.channel"; const PREF_EM_LOGGING_ENABLED = "extensions.logging.enabled"; const XMLURI_BLOCKLIST = "http://www.mozilla.org/2006/addons-blocklist"; const XMLURI_PARSE_ERROR = "http://www.mozilla.org/newlayout/xml/parsererror.xml" @@ -225,42 +225,6 @@ function getLocale() { return gPref.getCharPref(PREF_GENERAL_USERAGENT_LOCALE); } -/** - * Read the update channel from defaults only. We do this to ensure that - * the channel is tightly coupled with the application and does not apply - * to other installations of the application that may use the same profile. - */ -function getUpdateChannel() { - var channel = "default"; - var prefName; - var prefValue; - - var defaults = gPref.getDefaultBranch(null); - try { - channel = defaults.getCharPref(PREF_APP_UPDATE_CHANNEL); - } catch (e) { - // use default when pref not found - } - - try { - var partners = gPref.getChildList(PREF_PARTNER_BRANCH); - if (partners.length) { - channel += "-cck"; - partners.sort(); - - for each (prefName in partners) { - prefValue = gPref.getCharPref(prefName); - channel += "-" + prefValue; - } - } - } - catch (e) { - Components.utils.reportError(e); - } - - return channel; -} - /* Get the distribution pref values, from defaults only */ function getDistributionPrefValue(aPrefName) { var prefValue = "default"; @@ -461,7 +425,7 @@ Blocklist.prototype = { dsURI = dsURI.replace(/%BUILD_TARGET%/g, gApp.OS + "_" + gABI); dsURI = dsURI.replace(/%OS_VERSION%/g, gOSVersion); dsURI = dsURI.replace(/%LOCALE%/g, getLocale()); - dsURI = dsURI.replace(/%CHANNEL%/g, getUpdateChannel()); + dsURI = dsURI.replace(/%CHANNEL%/g, UpdateChannel.get()); dsURI = dsURI.replace(/%PLATFORM_VERSION%/g, gApp.platformVersion); dsURI = dsURI.replace(/%DISTRIBUTION%/g, getDistributionPrefValue(PREF_APP_DISTRIBUTION)); diff --git a/toolkit/mozapps/update/nsUpdateService.js b/toolkit/mozapps/update/nsUpdateService.js index 248ee5c84f9f..0fa4769361b3 100644 --- a/toolkit/mozapps/update/nsUpdateService.js +++ b/toolkit/mozapps/update/nsUpdateService.js @@ -30,7 +30,6 @@ const PREF_APP_UPDATE_CERT_CHECKATTRS = "app.update.cert.checkAttributes"; const PREF_APP_UPDATE_CERT_ERRORS = "app.update.cert.errors"; const PREF_APP_UPDATE_CERT_MAXERRORS = "app.update.cert.maxErrors"; const PREF_APP_UPDATE_CERT_REQUIREBUILTIN = "app.update.cert.requireBuiltIn"; -const PREF_APP_UPDATE_CHANNEL = "app.update.channel"; const PREF_APP_UPDATE_ENABLED = "app.update.enabled"; const PREF_APP_UPDATE_IDLETIME = "app.update.idletime"; const PREF_APP_UPDATE_INCOMPATIBLE_MODE = "app.update.incompatible.mode"; @@ -50,7 +49,6 @@ const PREF_APP_UPDATE_SERVICE_ENABLED = "app.update.service.enabled"; const PREF_APP_UPDATE_SERVICE_ERRORS = "app.update.service.errors"; const PREF_APP_UPDATE_SERVICE_MAX_ERRORS = "app.update.service.maxErrors"; -const PREF_PARTNER_BRANCH = "app.partner."; const PREF_APP_DISTRIBUTION = "distribution.id"; const PREF_APP_DISTRIBUTION_VERSION = "distribution.version"; @@ -160,6 +158,9 @@ const DEFAULT_SERVICE_MAX_ERRORS = 10; var gLocale = null; +XPCOMUtils.defineLazyModuleGetter(this, "UpdateChannel", + "resource://gre/modules/UpdateChannel.jsm"); + XPCOMUtils.defineLazyGetter(this, "gLogEnabled", function aus_gLogEnabled() { return getPref("getBoolPref", PREF_APP_UPDATE_LOG, false); }); @@ -873,44 +874,6 @@ function getLocale() { return gLocale; } -/** - * Read the update channel from defaults only. We do this to ensure that - * the channel is tightly coupled with the application and does not apply - * to other instances of the application that may use the same profile. - */ -function getUpdateChannel() { - // Preprocess the channel name that is defined when building to allow updating - // even when the preference file that defines the channel name doesn't exist. - var channel = "@MOZ_UPDATE_CHANNEL@"; - var prefName; - var prefValue; - - try { - channel = Services.prefs.getDefaultBranch(null). - getCharPref(PREF_APP_UPDATE_CHANNEL); - } catch (e) { - // Use the channel name from above that was preprocessed when building. - } - - try { - var partners = Services.prefs.getChildList(PREF_PARTNER_BRANCH); - if (partners.length) { - channel += "-cck"; - partners.sort(); - - for each (prefName in partners) { - prefValue = Services.prefs.getCharPref(prefName); - channel += "-" + prefValue; - } - } - } - catch (e) { - Components.utils.reportError(e); - } - - return channel; -} - /* Get the distribution pref values, from defaults only */ function getDistributionPrefValue(aPrefName) { var prefValue = "default"; @@ -2450,7 +2413,7 @@ UpdateManager.prototype = { */ get activeUpdate() { if (this._activeUpdate && - this._activeUpdate.channel != getUpdateChannel()) { + this._activeUpdate.channel != UpdateChannel.get()) { // User switched channels, clear out any old active updates and remove // partial downloads this._activeUpdate = null; @@ -2661,7 +2624,7 @@ Checker.prototype = { url = url.replace(/%OS_VERSION%/g, gOSVersion); if (/%LOCALE%/.test(url)) url = url.replace(/%LOCALE%/g, getLocale()); - url = url.replace(/%CHANNEL%/g, getUpdateChannel()); + url = url.replace(/%CHANNEL%/g, UpdateChannel.get()); url = url.replace(/%PLATFORM_VERSION%/g, Services.appinfo.platformVersion); url = url.replace(/%DISTRIBUTION%/g, getDistributionPrefValue(PREF_APP_DISTRIBUTION)); @@ -2754,7 +2717,7 @@ Checker.prototype = { continue; } update.serviceURL = this.getUpdateURL(this._forced); - update.channel = getUpdateChannel(); + update.channel = UpdateChannel.get(); updates.push(update); } From 14f84b1dd837fe2ec06754cb577a68648258d85a Mon Sep 17 00:00:00 2001 From: Anton Kovalyov Date: Thu, 13 Sep 2012 17:54:02 -0700 Subject: [PATCH 04/10] Bug 740948 - Scratchpad should provide a quick way to reload the tab and re-run the code; r=harth --- browser/devtools/scratchpad/scratchpad.js | 35 +++++++++ browser/devtools/scratchpad/scratchpad.xul | 10 +++ browser/devtools/scratchpad/test/Makefile.in | 1 + ...ser_scratchpad_bug740948_reload_and_run.js | 73 +++++++++++++++++++ .../chrome/browser/devtools/scratchpad.dtd | 4 + .../browser/devtools/scratchpad.properties | 4 + 6 files changed, 127 insertions(+) create mode 100644 browser/devtools/scratchpad/test/browser_scratchpad_bug740948_reload_and_run.js diff --git a/browser/devtools/scratchpad/scratchpad.js b/browser/devtools/scratchpad/scratchpad.js index 8221c1f5f2c3..f3ddfea6b416 100644 --- a/browser/devtools/scratchpad/scratchpad.js +++ b/browser/devtools/scratchpad/scratchpad.js @@ -411,6 +411,34 @@ var Scratchpad = { } }, + /** + * Reload the current page and execute the entire editor content when + * the page finishes loading. Note that this operation should be available + * only in the content context. + */ + reloadAndRun: function SP_reloadAndRun() + { + if (this.executionContext !== SCRATCHPAD_CONTEXT_CONTENT) { + Cu.reportError(this.strings. + GetStringFromName("scratchpadContext.invalid")); + return; + } + + let browser = this.gBrowser.selectedBrowser; + + this._reloadAndRunEvent = function onLoad(evt) { + if (evt.target !== browser.contentDocument) { + return; + } + + browser.removeEventListener("load", this._reloadAndRunEvent, true); + this.run(); + }.bind(this); + + browser.addEventListener("load", this._reloadAndRunEvent, true); + browser.contentWindow.location.reload(); + }, + /** * Execute the selected text (if any) or the entire editor content in the * current context. The evaluation result is inserted into the editor after @@ -979,6 +1007,7 @@ var Scratchpad = { let content = document.getElementById("sp-menu-content"); document.getElementById("sp-menu-browser").removeAttribute("checked"); + document.getElementById("sp-cmd-reloadAndRun").removeAttribute("disabled"); content.setAttribute("checked", true); this.executionContext = SCRATCHPAD_CONTEXT_CONTENT; this.notificationBox.removeAllNotifications(false); @@ -995,8 +1024,12 @@ var Scratchpad = { } let browser = document.getElementById("sp-menu-browser"); + let reloadAndRun = document.getElementById("sp-cmd-reloadAndRun"); + document.getElementById("sp-menu-content").removeAttribute("checked"); + reloadAndRun.setAttribute("disabled", true); browser.setAttribute("checked", true); + this.executionContext = SCRATCHPAD_CONTEXT_BROWSER; this.notificationBox.appendNotification( this.strings.GetStringFromName("browserContext.notification"), @@ -1173,6 +1206,8 @@ var Scratchpad = { } this.resetContext(); + this.gBrowser.selectedBrowser.removeEventListener("load", + this._reloadAndRunEvent, true); this.editor.removeEventListener(SourceEditor.EVENTS.DIRTY_CHANGED, this._onDirtyChanged); PreferenceObserver.uninit(); diff --git a/browser/devtools/scratchpad/scratchpad.xul b/browser/devtools/scratchpad/scratchpad.xul index 1c760bbd1e5c..2829d4b4abb5 100644 --- a/browser/devtools/scratchpad/scratchpad.xul +++ b/browser/devtools/scratchpad/scratchpad.xul @@ -45,6 +45,7 @@ + @@ -90,6 +91,10 @@ key="&display.key;" command="sp-cmd-display" modifiers="accel"/> + + + + + + diff --git a/browser/locales/en-US/chrome/browser/devtools/scratchpad.properties b/browser/locales/en-US/chrome/browser/devtools/scratchpad.properties index 916ead3937eb..024c8b7cee4c 100644 --- a/browser/locales/en-US/chrome/browser/devtools/scratchpad.properties +++ b/browser/locales/en-US/chrome/browser/devtools/scratchpad.properties @@ -26,6 +26,10 @@ export.fileOverwriteConfirmation=File exists. Overwrite? # type. browserWindow.unavailable=Scratchpad cannot find any browser window to execute the code in. +# LOCALIZATION NOTE (scratchpadContext.invalid): This error message is shown +# when user tries to run an operation in Scratchpad in an unsupported context. +scratchpadContext.invalid=Scratchpad cannot run this operation in the current mode. + # LOCALIZATION NOTE (openFile.title): This is the file picker title, when you # open a file from Scratchpad. openFile.title=Open File From 5622f195d5fc1ca374a7c53534503e456b910578 Mon Sep 17 00:00:00 2001 From: Blair McBride Date: Tue, 18 Sep 2012 16:48:01 +1200 Subject: [PATCH 05/10] Bug 788416 - Remove ancient and unused tests in toolkit\mozapps\extensions\test\unit. r=Mossop --- .../test/unit/data/test_bug356370.rdf | 64 ----- .../test/unit/data/test_bug356370_1.rdf | 20 -- .../test/unit/data/test_bug356370_2.rdf | 20 -- .../test/unit/data/test_bug356370_4.rdf | 21 -- .../unit/data/test_bug421396/chrome.manifest | 1 - .../test/unit/data/test_bug421396/install.rdf | 22 -- .../test/unit/data/test_bug463819.rdf | 63 ----- .../test/unit/data/test_bug463819.xml | 24 -- .../test/unit/head_extensionmanager.js | 234 ------------------ .../test/unit/tail_extensionmanager.js | 8 - .../extensions/test/unit/test_bug356370.js | 128 ---------- .../extensions/test/unit/test_bug421396.js | 220 ---------------- .../extensions/test/unit/test_bug463819.js | 229 ----------------- 13 files changed, 1054 deletions(-) delete mode 100644 toolkit/mozapps/extensions/test/unit/data/test_bug356370.rdf delete mode 100644 toolkit/mozapps/extensions/test/unit/data/test_bug356370_1.rdf delete mode 100644 toolkit/mozapps/extensions/test/unit/data/test_bug356370_2.rdf delete mode 100644 toolkit/mozapps/extensions/test/unit/data/test_bug356370_4.rdf delete mode 100644 toolkit/mozapps/extensions/test/unit/data/test_bug421396/chrome.manifest delete mode 100644 toolkit/mozapps/extensions/test/unit/data/test_bug421396/install.rdf delete mode 100644 toolkit/mozapps/extensions/test/unit/data/test_bug463819.rdf delete mode 100644 toolkit/mozapps/extensions/test/unit/data/test_bug463819.xml delete mode 100644 toolkit/mozapps/extensions/test/unit/head_extensionmanager.js delete mode 100644 toolkit/mozapps/extensions/test/unit/tail_extensionmanager.js delete mode 100644 toolkit/mozapps/extensions/test/unit/test_bug356370.js delete mode 100644 toolkit/mozapps/extensions/test/unit/test_bug421396.js delete mode 100644 toolkit/mozapps/extensions/test/unit/test_bug463819.js diff --git a/toolkit/mozapps/extensions/test/unit/data/test_bug356370.rdf b/toolkit/mozapps/extensions/test/unit/data/test_bug356370.rdf deleted file mode 100644 index dfda3f3ad9a9..000000000000 --- a/toolkit/mozapps/extensions/test/unit/data/test_bug356370.rdf +++ /dev/null @@ -1,64 +0,0 @@ - - - - app-profile - 1 - Bug 356370 test 1 - 2 - - - xpcshell@tests.mozilla.org - 1 - 1 - - - - - invalid-hi - 1 - Bug 356370 test 2 - 2 - true - - - xpcshell@tests.mozilla.org - 1 - 1 - - - - - invalid - 1 - Bug 356370 test 3 - 2 - - - xpcshell@tests.mozilla.org - 1 - 1 - - - - - invalid - 1 - Bug 356370 test 4 - 4 - - - xpcshell@tests.mozilla.org - 1 - 1 - - - - - - - - - - diff --git a/toolkit/mozapps/extensions/test/unit/data/test_bug356370_1.rdf b/toolkit/mozapps/extensions/test/unit/data/test_bug356370_1.rdf deleted file mode 100644 index 6b2fdb860b67..000000000000 --- a/toolkit/mozapps/extensions/test/unit/data/test_bug356370_1.rdf +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - bug356370_1@tests.mozilla.org - 1 - - - - xpcshell@tests.mozilla.org - 1 - 1 - - - - Bug 356370 test 1 - - diff --git a/toolkit/mozapps/extensions/test/unit/data/test_bug356370_2.rdf b/toolkit/mozapps/extensions/test/unit/data/test_bug356370_2.rdf deleted file mode 100644 index e9871b40e1b2..000000000000 --- a/toolkit/mozapps/extensions/test/unit/data/test_bug356370_2.rdf +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - bug356370_2@tests.mozilla.org - 1 - - - - xpcshell@tests.mozilla.org - 1 - 1 - - - - Bug 356370 test 2 - - diff --git a/toolkit/mozapps/extensions/test/unit/data/test_bug356370_4.rdf b/toolkit/mozapps/extensions/test/unit/data/test_bug356370_4.rdf deleted file mode 100644 index eb5d4d9a882f..000000000000 --- a/toolkit/mozapps/extensions/test/unit/data/test_bug356370_4.rdf +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - bug356370_4@tests.mozilla.org - 1 - - - - xpcshell@tests.mozilla.org - 1 - 1 - - - - Bug 356370 test 4 - 4 - - diff --git a/toolkit/mozapps/extensions/test/unit/data/test_bug421396/chrome.manifest b/toolkit/mozapps/extensions/test/unit/data/test_bug421396/chrome.manifest deleted file mode 100644 index dc7f95abd69c..000000000000 --- a/toolkit/mozapps/extensions/test/unit/data/test_bug421396/chrome.manifest +++ /dev/null @@ -1 +0,0 @@ -# blank file to stop the EM attempting to create one anyway \ No newline at end of file diff --git a/toolkit/mozapps/extensions/test/unit/data/test_bug421396/install.rdf b/toolkit/mozapps/extensions/test/unit/data/test_bug421396/install.rdf deleted file mode 100644 index a785025bea19..000000000000 --- a/toolkit/mozapps/extensions/test/unit/data/test_bug421396/install.rdf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - bug421396@tests.mozilla.org - 1.0 - - - - xpcshell@tests.mozilla.org - 1 - 1 - - - - - bug421396 test - - - diff --git a/toolkit/mozapps/extensions/test/unit/data/test_bug463819.rdf b/toolkit/mozapps/extensions/test/unit/data/test_bug463819.rdf deleted file mode 100644 index cd5e336e9896..000000000000 --- a/toolkit/mozapps/extensions/test/unit/data/test_bug463819.rdf +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - 1.0 - - - xpcshell@tests.mozilla.org - 1 - 2 - - - - - - - - - - - - - - 1.0 - - - xpcshell@tests.mozilla.org - 1 - 2 - - - - - - - - - - - - - - 1.0 - - - xpcshell@tests.mozilla.org - 1 - 2 - - - - - - - - - diff --git a/toolkit/mozapps/extensions/test/unit/data/test_bug463819.xml b/toolkit/mozapps/extensions/test/unit/data/test_bug463819.xml deleted file mode 100644 index 52a7cb5583e5..000000000000 --- a/toolkit/mozapps/extensions/test/unit/data/test_bug463819.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/mozapps/extensions/test/unit/head_extensionmanager.js b/toolkit/mozapps/extensions/test/unit/head_extensionmanager.js deleted file mode 100644 index 54276b46b806..000000000000 --- a/toolkit/mozapps/extensions/test/unit/head_extensionmanager.js +++ /dev/null @@ -1,234 +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/. - */ - -/* - * These are intended to be a set of base functions enabling unit testing - * for the Extension Manager component. - */ - -const PREFIX_NS_EM = "http://www.mozilla.org/2004/em-rdf#"; -const PREFIX_NS_CHROME = "http://www.mozilla.org/rdf/chrome#"; -const PREFIX_ITEM_URI = "urn:mozilla:item:"; - -const NS_INSTALL_LOCATION_APPPROFILE = "app-profile"; - -const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1"; -const XULAPPINFO_CID = Components.ID("{c763b610-9d49-455a-bbd2-ede71682a1ac}"); - -var gXULAppInfo = null; -var gEM = null; -var gRDF = Components.classes["@mozilla.org/rdf/rdf-service;1"] - .getService(Components.interfaces.nsIRDFService); - -/** - * Utility functions - */ -function EM_NS(property) { - return PREFIX_NS_EM + property; -} - -function CHROME_NS(property) { - return PREFIX_NS_CHROME + property; -} - -function EM_R(property) { - return gRDF.GetResource(EM_NS(property)); -} - -function EM_L(literal) { - return gRDF.GetLiteral(literal); -} - -function EM_I(integer) { - return gRDF.GetIntLiteral(integer); -} - -function EM_D(integer) { - return gRDF.GetDateLiteral(integer); -} - -/** - * Extract the string value from a RDF Literal or Resource - * @param literalOrResource - * RDF String Literal or Resource - * @returns String value of the literal or resource, or undefined if the object - * supplied is not a RDF string literal or resource. - */ -function stringData(literalOrResource) { - if (literalOrResource instanceof Components.interfaces.nsIRDFLiteral) - return literalOrResource.Value; - if (literalOrResource instanceof Components.interfaces.nsIRDFResource) - return literalOrResource.Value; - return undefined; -} - -/** - * Extract the integer value of a RDF Literal - * @param literal - * nsIRDFInt literal - * @return integer value of the literal - */ -function intData(literal) { - if (literal instanceof Components.interfaces.nsIRDFInt) - return literal.Value; - return undefined; -} - -/** - * Gets a RDF Resource for item with the given ID - * @param id - * The GUID of the item to construct a RDF resource to the - * active item for - * @returns The RDF Resource to the Active item. - */ -function getResourceForID(id) { - return gRDF.GetResource(PREFIX_ITEM_URI + id); -} - -/** - * Extract a string property for an add-on - * @param id - * ID of the add-on to retrieve a property for - * @param property - * The localname of the property - * @returns String value of the property or undefined if the property - * does not exist - */ -function getManifestProperty(id, property) { - return stringData(gEM.datasource.GetTarget(getResourceForID(id), EM_R(property), true)); -} - -/** - * Returns a testcase xpi - * @param name - * The name of the testcase (without extension) - * @returns an nsIFile pointing to the testcase xpi - */ -function do_get_addon(name) -{ - return do_get_file("addons/" + name + ".xpi"); -} - -/** - * Creates an nsIXULAppInfo - * @param id - * The ID of the test application - * @param name - * A name for the test application - * @param version - * The version of the application - * @param platformVersion - * The gecko version of the application - */ -function createAppInfo(id, name, version, platformVersion) -{ - gXULAppInfo = { - vendor: "Mozilla", - name: name, - ID: id, - version: version, - appBuildID: "2007010101", - platformVersion: platformVersion, - platformBuildID: "2007010101", - inSafeMode: false, - logConsoleErrors: true, - OS: "XPCShell", - XPCOMABI: "noarch-spidermonkey", - invalidateCachesOnRestart: function invalidateCachesOnRestart() {}, - - QueryInterface: function QueryInterface(iid) { - if (iid.equals(Components.interfaces.nsIXULAppInfo) - || iid.equals(Components.interfaces.nsIXULRuntime) - || iid.equals(Components.interfaces.nsISupports)) - return this; - - throw Components.results.NS_ERROR_NO_INTERFACE; - } - }; - - var XULAppInfoFactory = { - createInstance: function (outer, iid) { - if (outer != null) - throw Components.results.NS_ERROR_NO_AGGREGATION; - return gXULAppInfo.QueryInterface(iid); - } - }; - var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar); - registrar.registerFactory(XULAPPINFO_CID, "XULAppInfo", - XULAPPINFO_CONTRACTID, XULAppInfoFactory); -} - -function startEM(upgraded) { - var needsRestart = false; - if (upgraded) { - try { - needsRestart = gEM.checkForMismatches(); - } - catch (e) { - do_throw("checkForMismatches threw an exception: " + e + "\n"); - needsRestart = false; - upgraded = false; - } - } - - if (!upgraded || !needsRestart) - needsRestart = gEM.start(); - - if (needsRestart) - restartEM(); -} - -/** - * This simulates an application startup. Since we will be starting from an - * empty profile we follow that path. - */ -function startupEM() -{ - gEM = Components.classes["@mozilla.org/extensions/manager;1"] - .getService(Components.interfaces.nsIExtensionManager); - - gEM.QueryInterface(Components.interfaces.nsIObserver); - gEM.observe(null, "profile-after-change", "startup"); - - // First run is a new profile which nsAppRunner would consider as an update - // (no existing compatibility.ini) - startEM(true); -} - -/** - * Simple function to simulate the termination of an app to the EM. - * This harness does not support creating a new EM after calling this. - */ -function shutdownEM() -{ - // xpcshell calls xpcom-shutdown so we don't actually do anything here. - gEM = null; -} - -/** - * Many operations require restarts to take effect. This function should - * perform all that is necessary for this to happen. - */ -function restartEM(newVersion) -{ - if (newVersion) { - gXULAppInfo.version = newVersion; - startEM(true); - } - else { - startEM(false); - } -} - -var gDirSvc = Components.classes["@mozilla.org/file/directory_service;1"] - .getService(Components.interfaces.nsIProperties); - -// Need to create and register a profile folder. -var gProfD = do_get_profile(); - -var gPrefs = Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefBranch); -// Enable more extensive EM logging -gPrefs.setBoolPref("extensions.logging.enabled", true); diff --git a/toolkit/mozapps/extensions/test/unit/tail_extensionmanager.js b/toolkit/mozapps/extensions/test/unit/tail_extensionmanager.js deleted file mode 100644 index 48bb76b87652..000000000000 --- a/toolkit/mozapps/extensions/test/unit/tail_extensionmanager.js +++ /dev/null @@ -1,8 +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/. - */ - -// Close down any remaining EM -if (gEM) - shutdownEM(); diff --git a/toolkit/mozapps/extensions/test/unit/test_bug356370.js b/toolkit/mozapps/extensions/test/unit/test_bug356370.js deleted file mode 100644 index d68ab3fb0549..000000000000 --- a/toolkit/mozapps/extensions/test/unit/test_bug356370.js +++ /dev/null @@ -1,128 +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/. - */ -const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul"; - -// Don't need the full interface, attempts to call other methods will just -// throw which is just fine -var WindowWatcher = { - openWindow: function(parent, url, name, features, arguments) { - // It is expected that the update dialog is shown during this test. - do_check_eq(url, URI_EXTENSION_UPDATE_DIALOG); - }, - - QueryInterface: function(iid) { - if (iid.equals(Components.interfaces.nsIWindowWatcher) - || iid.equals(Components.interfaces.nsISupports)) - return this; - - throw Components.results.NS_ERROR_NO_INTERFACE; - } -} - -var WindowWatcherFactory = { - createInstance: function createInstance(outer, iid) { - if (outer != null) - throw Components.results.NS_ERROR_NO_AGGREGATION; - return WindowWatcher.QueryInterface(iid); - } -}; -var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar); -registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"), - "Fake Window Watcher", - "@mozilla.org/embedcomp/window-watcher;1", - WindowWatcherFactory); - -function write_cache_line(stream, location, id, mtime) { - var line = location + "\t" + id + "\trel%" + id + "\t" + Math.floor(mtime / 1000) + "\t\r\n"; - stream.write(line, line.length); -} - -/** - * This copies two extensions, a default extensions datasource into the profile - * It also manufactures an extensions.cache file with invalid items. - * There are 4 test extensions: - * bug356370_1@tests.mozilla.org exists in app-profile and an unused version is in invalid-lo - * bug356370_2@tests.mozilla.org exists in invalid-hi and an unused version is in app-profile - * bug356370_3@tests.mozilla.org exists in invalid - * bug356370_4@tests.mozilla.org is a theme existing in invalid and a new install - * will be detected in app-profile - * - * After startup only the first two should exist in the correct install location - * and installing extensions should be successful. - */ -function setup_profile() { - // Set up the profile with some existing extensions - // Not nice to copy the extensions datasource in, but bringing up the EM to - // create it properly will invalidate the test - var source = do_get_file("data/test_bug356370.rdf"); - source.copyTo(gProfD, "extensions.rdf"); - - // Must programmatically generate the cache since it depends on the mimetimes - // being accurate. - var cache = gProfD.clone(); - cache.append("extensions.cache"); - var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"] - .createInstance(Components.interfaces.nsIFileOutputStream); - foStream.init(cache, 0x02 | 0x08 | 0x20, 0666, 0); // Write, create, truncate - - var addon = gProfD.clone(); - addon.append("extensions"); - addon.append("bug356370_1@tests.mozilla.org"); - source = do_get_file("data/test_bug356370_1.rdf"); - addon.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755); - source.copyTo(addon, "install.rdf"); - write_cache_line(foStream, "app-profile", "bug356370_1@tests.mozilla.org", - addon.lastModifiedTime); - - addon = gProfD.clone(); - addon.append("extensions"); - addon.append("bug356370_2@tests.mozilla.org"); - source = do_get_file("data/test_bug356370_2.rdf"); - addon.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755); - source.copyTo(addon, "install.rdf"); - write_cache_line(foStream, "app-profile", "bug356370_2@tests.mozilla.org", - addon.lastModifiedTime); - - addon = gProfD.clone(); - addon.append("extensions"); - addon.append("bug356370_4@tests.mozilla.org"); - source = do_get_file("data/test_bug356370_4.rdf"); - addon.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755); - source.copyTo(addon, "install.rdf"); - - // Write out a set of invalid entries - write_cache_line(foStream, "invalid-lo", "bug356370_1@tests.mozilla.org", 0); - write_cache_line(foStream, "invalid-hi", "bug356370_2@tests.mozilla.org", 0); - write_cache_line(foStream, "invalid", "bug356370_3@tests.mozilla.org", 0); - write_cache_line(foStream, "invalid", "bug356370_4@tests.mozilla.org", 0); - foStream.close(); -} - -function run_test() { - createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9"); - gPrefs.setCharPref("extensions.lastAppVersion", "4"); - setup_profile(); - - startupEM(); - do_check_neq(gEM.getItemForID("bug356370_1@tests.mozilla.org"), null); - do_check_eq(getManifestProperty("bug356370_1@tests.mozilla.org", "installLocation"), "app-profile"); - do_check_neq(gEM.getItemForID("bug356370_2@tests.mozilla.org"), null); - do_check_eq(getManifestProperty("bug356370_2@tests.mozilla.org", "installLocation"), "app-profile"); - // This should still be disabled - do_check_eq(getManifestProperty("bug356370_2@tests.mozilla.org", "isDisabled"), "true"); - do_check_eq(gEM.getItemForID("bug356370_3@tests.mozilla.org"), null); - do_check_neq(gEM.getItemForID("bug356370_4@tests.mozilla.org"), null); - do_check_eq(getManifestProperty("bug356370_4@tests.mozilla.org", "installLocation"), "app-profile"); - - gEM.installItemFromFile(do_get_addon("test_bug257155"), NS_INSTALL_LOCATION_APPPROFILE); - do_check_neq(gEM.getItemForID("bug257155@tests.mozilla.org"), null); - - restartEM(); - do_check_neq(gEM.getItemForID("bug257155@tests.mozilla.org"), null); - do_check_neq(gEM.getItemForID("bug356370_1@tests.mozilla.org"), null); - do_check_neq(gEM.getItemForID("bug356370_2@tests.mozilla.org"), null); - do_check_eq(gEM.getItemForID("bug356370_3@tests.mozilla.org"), null); - do_check_neq(gEM.getItemForID("bug356370_4@tests.mozilla.org"), null); -} diff --git a/toolkit/mozapps/extensions/test/unit/test_bug421396.js b/toolkit/mozapps/extensions/test/unit/test_bug421396.js deleted file mode 100644 index 8a6940c0c182..000000000000 --- a/toolkit/mozapps/extensions/test/unit/test_bug421396.js +++ /dev/null @@ -1,220 +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/. - */ - -const TESTID = "bug421396@tests.mozilla.org"; -var INSTALLED = true; - -// This creates a fake directory that cannot be modified. Nothing exists inside -// the directory. -function RestrictedPath(source, isVisible) { - this.source = source; - this.isVisible = isVisible; -} - -// This doesn't implement all of nsIFile, just enough to keep the EM happy. -RestrictedPath.prototype = { - // A real nsIFile that this shadows - source: null, - // If this file is visible or not. Only the main directory for the addon is visible. - isVisible: null, - - append: function(node) { - this.source.append(node); - this.isVisible = false; - }, - - normalize: function() { - this.source.normalize(); - }, - - create: function(type, permissions) { - if (this.isVisible) - throw Components.errors.NS_ERROR_FILE_ALREADY_EXISTS; - throw Components.errors.NS_ERROR_FILE_ACCESS_DENIED; - }, - - get leafName() { - return this.source.leafName; - }, - - copyTo: function(parentdir, name) { - throw Components.errors.NS_ERROR_FILE_ACCESS_DENIED; - }, - - copyToFollowingLinks: function(parentdir, name) { - throw Components.errors.NS_ERROR_FILE_ACCESS_DENIED; - }, - - moveTo: function(parentdir, name) { - throw Components.errors.NS_ERROR_FILE_ACCESS_DENIED; - }, - - remove: function(recursive) { - if (this.isVisible) - throw Components.errors.NS_ERROR_FILE_ACCESS_DENIED; - throw Components.errors.NS_ERROR_FILE_NOT_FOUND; - }, - - get lastModifiedTime() { - if (this.isVisible) - return Date.now(); - throw Components.errors.NS_ERROR_FILE_NOT_FOUND; - }, - - get lastModifiedTimeOfLink() { - return this.lastModifiedTime; - }, - - get path() { return this.source.path; }, - exists: function() { return this.isVisible; }, - isDirectory: function() { return this.isVisible; }, - isFile: function() { return !this.isVisible; }, - - clone: function() { - return new RestrictedPath(this.source.clone(), this.isVisible); - }, - - get parent() { - return new RestrictedPath(this.source.parent, false); - }, - - getRelativeDescriptor: function(basedir) { - return this.source.getRelativeDescriptor(basedir); - }, - - QueryInterface: function(iid) { - if (iid.equals(Components.interfaces.nsIFile) - || iid.equals(Components.interfaces.nsISupports)) - return this; - - throw Components.results.NS_ERROR_NO_INTERFACE; - } -}; - -function DirectoryEnumerator(files) { - this.files = files; - this.pos = 0; -} - -DirectoryEnumerator.prototype = { - pos: null, - files: null, - - get nextFile() { - if (this.pos < this.files.length) - return this.files[this.pos++]; - return null; - }, - - close: function() { - } -}; - -var InstallLocation = { - name: "test-location", - location: null, - restricted: null, - canAccess: null, - priority: Components.interfaces.nsIInstallLocation.PRIORITY_APP_SYSTEM_GLOBAL, - - get itemLocations() { - return new DirectoryEnumerator([ this.getItemLocation(TESTID) ]); - }, - - getItemLocation: function(id) { - if (id == TESTID) { - var file = do_get_file("data/test_bug421396"); - if (INSTALLED) - return file; - // If we are simulating after the extension is "removed" then return the - // empty undeletable directory. - return new RestrictedPath(file, true); - } - var file = do_get_cwd(); - file.append("INVALIDNAME"); - file.append(id); - return file; - }, - - getIDForLocation: function(file) { - if (file.leafName == "test_bug421396") - return TESTID; - return file.leafName; - }, - - getItemFile: function(id, filePath) { - var itemLocation = this.getItemLocation(id).clone(); - var parts = filePath.split("/"); - for (let part of parts) - itemLocation.append(part); - return itemLocation; - }, - - itemIsManagedIndependently: function(id) { - return false; - }, - - stageFile: function(file, id) { - throw Components.results.NS_ERROR_NOT_IMPLEMENTED; - }, - - getStageFile: function(id) { - return null; - }, - - removeFile: function(file) { - throw Components.results.NS_ERROR_NOT_IMPLEMENTED; - }, - - QueryInterface: function(iid) { - if (iid.equals(Components.interfaces.nsIInstallLocation) - || iid.equals(Components.interfaces.nsISupports)) - return this; - - throw Components.results.NS_ERROR_NO_INTERFACE; - } -} - -var InstallLocationFactory = { - createInstance: function (outer, iid) { - if (outer != null) - throw Components.results.NS_ERROR_NO_AGGREGATION; - return InstallLocation.QueryInterface(iid); - } -}; - -const IL_CID = Components.ID("{6bdd8320-57c7-4f19-81ad-c32fdfc2b423}"); -const IL_CONTRACT = "@tests.mozilla.org/installlocation;1"; -var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar); -registrar.registerFactory(IL_CID, "Test Install Location", - IL_CONTRACT, InstallLocationFactory); - -var categoryManager = Components.classes["@mozilla.org/categorymanager;1"] - .getService(Components.interfaces.nsICategoryManager); -categoryManager.addCategoryEntry("extension-install-locations", "test-location", - IL_CONTRACT, false, true); - -function run_test() -{ - // EM needs to be running. - createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9"); - startupEM(); - // Addon in the fake location should be installed now. - do_check_neq(gEM.getItemForID(TESTID), null); - - // Mark the add-on as uninstalled and restart ot pickup the change. - INSTALLED = false; - restartEM(); - - do_check_eq(gEM.getItemForID(TESTID), null); - // Test install something. - gEM.installItemFromFile(do_get_addon("test_bug397778"), NS_INSTALL_LOCATION_APPPROFILE); - do_check_neq(gEM.getItemForID("bug397778@tests.mozilla.org"), null); - restartEM(); - - do_check_eq(gEM.getItemForID(TESTID), null); - do_check_neq(gEM.getItemForID("bug397778@tests.mozilla.org"), null); -} - diff --git a/toolkit/mozapps/extensions/test/unit/test_bug463819.js b/toolkit/mozapps/extensions/test/unit/test_bug463819.js deleted file mode 100644 index dfc01b22430f..000000000000 --- a/toolkit/mozapps/extensions/test/unit/test_bug463819.js +++ /dev/null @@ -1,229 +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/. - */ - -const INSTALLERROR_SUCCESS = 0; -const INSTALLERROR_INCOMPATIBLE_VERSION = -3; -const INSTALLERROR_BLOCKLISTED = -6; -const INSTALLERROR_SOFTBLOCKED = -10; - -// Disables security checking our updates which haven't been signed -gPrefs.setBoolPref("extensions.checkUpdateSecurity", false); - -// Get the HTTP server. -const Cr = Components.results; -Components.utils.import("resource://testing-common/httpd.js"); -var testserver; - -// This allows the EM to attempt to display errors to the user without failing -var promptService = { - alert: function(aParent, aDialogTitle, aText) { - }, - - alertCheck: function(aParent, aDialogTitle, aText, aCheckMsg, aCheckState) { - }, - - confirm: function(aParent, aDialogTitle, aText) { - }, - - confirmCheck: function(aParent, aDialogTitle, aText, aCheckMsg, aCheckState) { - }, - - confirmEx: function(aParent, aDialogTitle, aText, aButtonFlags, aButton0Title, aButton1Title, aButton2Title, aCheckMsg, aCheckState) { - }, - - prompt: function(aParent, aDialogTitle, aText, aValue, aCheckMsg, aCheckState) { - }, - - promptUsernameAndPassword: function(aParent, aDialogTitle, aText, aUsername, aPassword, aCheckMsg, aCheckState) { - }, - - promptPassword: function(aParent, aDialogTitle, aText, aPassword, aCheckMsg, aCheckState) { - }, - - select: function(aParent, aDialogTitle, aText, aCount, aSelectList, aOutSelection) { - }, - - QueryInterface: function(iid) { - if (iid.equals(Components.interfaces.nsIPromptService) - || iid.equals(Components.interfaces.nsISupports)) - return this; - - throw Components.results.NS_ERROR_NO_INTERFACE; - } -}; - -// This will be called to show the blocklist message, we just make it look like -// it was dismissed. -var WindowWatcher = { - openWindow: function(parent, url, name, features, arguments) { - }, - - QueryInterface: function(iid) { - if (iid.equals(Ci.nsIWindowWatcher) - || iid.equals(Ci.nsISupports)) - return this; - - throw Cr.NS_ERROR_NO_INTERFACE; - } -} - -var WindowWatcherFactory = { - createInstance: function createInstance(outer, iid) { - if (outer != null) - throw Components.results.NS_ERROR_NO_AGGREGATION; - return WindowWatcher.QueryInterface(iid); - } -}; - -var PromptServiceFactory = { - createInstance: function (outer, iid) { - if (outer != null) - throw Components.results.NS_ERROR_NO_AGGREGATION; - return promptService.QueryInterface(iid); - } -}; -var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar); -registrar.registerFactory(Components.ID("{6cc9c9fe-bc0b-432b-a410-253ef8bcc699}"), - "PromptService", - "@mozilla.org/embedcomp/prompt-service;1", PromptServiceFactory); -registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"), - "Fake Window Watcher", - "@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory); - -var gNextTest, gLastStatus; - -// nsIAddonInstallListener -var installListener = { - onDownloadStarted: function(aAddon) { - }, - - onDownloadEnded: function(aAddon) { - }, - - onInstallStarted: function(aAddon) { - }, - - onCompatibilityCheckStarted: function(aAddon) { - }, - - onCompatibilityCheckEnded: function(aAddon, aStatus) { - }, - - onInstallEnded: function(aAddon, aStatus) { - gLastStatus = aStatus; - }, - - onInstallsCompleted: function() { - gNextTest(); - }, - - onDownloadProgress: function onProgress(aAddon, aValue, aMaxValue) { - } -} - -function run_test() { - createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "1.9"); - - // Install the blocklist - var blocklist = do_get_file("data/test_bug463819.xml"); - blocklist.copyTo(gProfD, "blocklist.xml"); - - // Create and configure the HTTP server. - testserver = new HttpServer(); - testserver.registerDirectory("/", do_get_file("data")); - testserver.start(4444); - - startupEM(); - gEM.addInstallListener(installListener); - - // These add-ons require no update check so will complete installation immediately - dump("Installing add-on 1\n"); - gNextTest = test_addon_1; - gEM.installItemFromFile(do_get_addon("test_bug463819_1"), NS_INSTALL_LOCATION_APPPROFILE); - dump("Installing add-on 4\n"); - gNextTest = test_addon_4; - gEM.installItemFromFile(do_get_addon("test_bug463819_4"), NS_INSTALL_LOCATION_APPPROFILE); - dump("Installing add-on 7\n"); - gNextTest = test_addon_7; - gEM.installItemFromFile(do_get_addon("test_bug463819_7"), NS_INSTALL_LOCATION_APPPROFILE); - - do_test_pending(); - - // These add-ons will perform a compatibility check before responding. - dump("Installing add-on 2\n"); - gNextTest = test_addon_2; - gEM.installItemFromFile(do_get_addon("test_bug463819_2"), NS_INSTALL_LOCATION_APPPROFILE); -} - -// Compatible in install.rdf and not in blocklist -function test_addon_1() { - do_check_eq(gLastStatus, INSTALLERROR_SUCCESS); -} - -// Compatible in install.rdf and low severity in blocklist -function test_addon_4() { - do_check_eq(gLastStatus, INSTALLERROR_SOFTBLOCKED); -} - -// Compatible in install.rdf and high severity in blocklist -function test_addon_7() { - do_check_eq(gLastStatus, INSTALLERROR_BLOCKLISTED); -} - -// Incompatible in install.rdf, compatible in update.rdf, not in blocklist -function test_addon_2() { - do_check_eq(gLastStatus, INSTALLERROR_SUCCESS); - - dump("Installing add-on 3\n"); - gNextTest = test_addon_3; - gEM.installItemFromFile(do_get_addon("test_bug463819_3"), NS_INSTALL_LOCATION_APPPROFILE); -} - -// Incompatible in install.rdf, incompatible in update.rdf, not in blocklist -function test_addon_3() { - do_check_eq(gLastStatus, INSTALLERROR_INCOMPATIBLE_VERSION); - - dump("Installing add-on 5\n"); - gNextTest = test_addon_5; - gEM.installItemFromFile(do_get_addon("test_bug463819_5"), NS_INSTALL_LOCATION_APPPROFILE); -} - -// Incompatible in install.rdf, compatible in update.rdf, low severity in blocklist -function test_addon_5() { - do_check_eq(gLastStatus, INSTALLERROR_SOFTBLOCKED); - - dump("Installing add-on 6\n"); - gNextTest = test_addon_6; - gEM.installItemFromFile(do_get_addon("test_bug463819_6"), NS_INSTALL_LOCATION_APPPROFILE); -} - -// Incompatible in install.rdf, incompatible in update.rdf, low severity in blocklist -function test_addon_6() { - do_check_eq(gLastStatus, INSTALLERROR_INCOMPATIBLE_VERSION); - - dump("Installing add-on 8\n"); - gNextTest = test_addon_8; - gEM.installItemFromFile(do_get_addon("test_bug463819_8"), NS_INSTALL_LOCATION_APPPROFILE); -} - -// Incompatible in install.rdf, compatible in update.rdf, high severity in blocklist -function test_addon_8() { - do_check_eq(gLastStatus, INSTALLERROR_BLOCKLISTED); - - dump("Installing add-on 9\n"); - gNextTest = test_addon_9; - gEM.installItemFromFile(do_get_addon("test_bug463819_9"), NS_INSTALL_LOCATION_APPPROFILE); -} - -// Incompatible in install.rdf, incompatible in update.rdf, high severity in blocklist -function test_addon_9() { - do_check_eq(gLastStatus, INSTALLERROR_INCOMPATIBLE_VERSION); - - finish_test(); -} - -function finish_test() { - testserver.stop(do_test_finished); -} From 914816c553ef473ed4b717681ee7f6ebab7fbebd Mon Sep 17 00:00:00 2001 From: Blair McBride Date: Tue, 18 Sep 2012 16:49:42 +1200 Subject: [PATCH 06/10] Bug 788378 - Add guards to the AddonManager/AddonManagerInternal getters and setters, to ensure they're not used before startup/after shutdown. r=Mossop --- toolkit/mozapps/extensions/AddonManager.jsm | 56 +++++++++++ .../extensions/test/xpcshell/test_shutdown.js | 98 +++++++++++-------- .../test/xpcshell/test_updatecheck.js | 1 + 3 files changed, 115 insertions(+), 40 deletions(-) diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm index ceda1d4b50dc..2dceb4b85215 100644 --- a/toolkit/mozapps/extensions/AddonManager.jsm +++ b/toolkit/mozapps/extensions/AddonManager.jsm @@ -1932,14 +1932,26 @@ var AddonManagerInternal = { }, get addonTypes() { + if (!gStarted) + throw Components.Exception("AddonManager is not initialized", + Cr.NS_ERROR_NOT_INITIALIZED); + return this.typesProxy; }, get autoUpdateDefault() { + if (!gStarted) + throw Components.Exception("AddonManager is not initialized", + Cr.NS_ERROR_NOT_INITIALIZED); + return gAutoUpdateDefault; }, set autoUpdateDefault(aValue) { + if (!gStarted) + throw Components.Exception("AddonManager is not initialized", + Cr.NS_ERROR_NOT_INITIALIZED); + aValue = !!aValue; if (aValue != gAutoUpdateDefault) Services.prefs.setBoolPref(PREF_EM_AUTOUPDATE_DEFAULT, aValue); @@ -1947,10 +1959,18 @@ var AddonManagerInternal = { }, get checkCompatibility() { + if (!gStarted) + throw Components.Exception("AddonManager is not initialized", + Cr.NS_ERROR_NOT_INITIALIZED); + return gCheckCompatibility; }, set checkCompatibility(aValue) { + if (!gStarted) + throw Components.Exception("AddonManager is not initialized", + Cr.NS_ERROR_NOT_INITIALIZED); + aValue = !!aValue; if (aValue != gCheckCompatibility) { if (!aValue) @@ -1962,10 +1982,18 @@ var AddonManagerInternal = { }, get strictCompatibility() { + if (!gStarted) + throw Components.Exception("AddonManager is not initialized", + Cr.NS_ERROR_NOT_INITIALIZED); + return gStrictCompatibility; }, set strictCompatibility(aValue) { + if (!gStarted) + throw Components.Exception("AddonManager is not initialized", + Cr.NS_ERROR_NOT_INITIALIZED); + aValue = !!aValue; if (aValue != gStrictCompatibility) Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, aValue); @@ -1973,14 +2001,26 @@ var AddonManagerInternal = { }, get checkUpdateSecurityDefault() { + if (!gStarted) + throw Components.Exception("AddonManager is not initialized", + Cr.NS_ERROR_NOT_INITIALIZED); + return gCheckUpdateSecurityDefault; }, get checkUpdateSecurity() { + if (!gStarted) + throw Components.Exception("AddonManager is not initialized", + Cr.NS_ERROR_NOT_INITIALIZED); + return gCheckUpdateSecurity; }, set checkUpdateSecurity(aValue) { + if (!gStarted) + throw Components.Exception("AddonManager is not initialized", + Cr.NS_ERROR_NOT_INITIALIZED); + aValue = !!aValue; if (aValue != gCheckUpdateSecurity) { if (aValue != gCheckUpdateSecurityDefault) @@ -1992,10 +2032,18 @@ var AddonManagerInternal = { }, get updateEnabled() { + if (!gStarted) + throw Components.Exception("AddonManager is not initialized", + Cr.NS_ERROR_NOT_INITIALIZED); + return gUpdateEnabled; }, set updateEnabled(aValue) { + if (!gStarted) + throw Components.Exception("AddonManager is not initialized", + Cr.NS_ERROR_NOT_INITIALIZED); + aValue = !!aValue; if (aValue != gUpdateEnabled) Services.prefs.setBoolPref(PREF_EM_UPDATE_ENABLED, aValue); @@ -2003,6 +2051,10 @@ var AddonManagerInternal = { }, get hotfixID() { + if (!gStarted) + throw Components.Exception("AddonManager is not initialized", + Cr.NS_ERROR_NOT_INITIALIZED); + return gHotfixID; }, }; @@ -2340,6 +2392,10 @@ var AddonManager = { * @return true if the addon should auto-update, false otherwise. */ shouldAutoUpdate: function AM_shouldAutoUpdate(aAddon) { + if (!gStarted) + throw Components.Exception("AddonManager is not initialized", + Cr.NS_ERROR_NOT_INITIALIZED); + if (!aAddon || typeof aAddon != "object") throw Components.Exception("aAddon must be specified", Cr.NS_ERROR_INVALID_ARG); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js b/toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js index 60d74b4d8831..24385b75ea58 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js @@ -4,57 +4,75 @@ // Verify that API functions fail if the Add-ons Manager isn't initialised. -const IGNORE = ["escapeAddonURI", "shouldAutoUpdate", "getStartupChanges", - "addTypeListener", "removeTypeListener", - "addAddonListener", "removeAddonListener", - "addInstallListener", "removeInstallListener", - "addManagerListener", "removeManagerListener"]; +const IGNORE = { + funcs: ["escapeAddonURI", "getStartupChanges", "addTypeListener", + "removeTypeListener", "addAddonListener", "removeAddonListener", + "addInstallListener", "removeInstallListener", "addManagerListener", + "removeManagerListener"], + getters: [], + setters: [] +}; -const IGNORE_PRIVATE = ["AddonAuthor", "AddonCompatibilityOverride", - "AddonScreenshot", "AddonType", "startup", "shutdown", - "registerProvider", "unregisterProvider", - "addStartupChange", "removeStartupChange"]; +const IGNORE_PRIVATE = { + funcs: ["AddonAuthor", "AddonCompatibilityOverride", "AddonScreenshot", + "AddonType", "startup", "shutdown", "registerProvider", + "unregisterProvider", "addStartupChange", "removeStartupChange"], + getters: [], + setters: [] +}; -function test_functions() { - for (let prop in AddonManager) { - if (typeof AddonManager[prop] != "function") - continue; - if (IGNORE.indexOf(prop) != -1) - continue; - try { - do_print("AddonManager." + prop); - AddonManager[prop](); - do_throw(prop + " did not throw an exception"); - } - catch (e) { - if (e.result != Components.results.NS_ERROR_NOT_INITIALIZED) - do_throw(prop + " threw an unexpected exception: " + e); - } - } +function test_functions(aObjName, aIgnore) { + let obj = this[aObjName]; + for (let prop in obj) { + let desc = Object.getOwnPropertyDescriptor(obj, prop); - for (let prop in AddonManagerPrivate) { - if (typeof AddonManagerPrivate[prop] != "function") - continue; - if (IGNORE_PRIVATE.indexOf(prop) != -1) - continue; + if (typeof desc.value == "function") { + if (aIgnore.funcs.indexOf(prop) != -1) + continue; - try { - do_print("AddonManagerPrivate." + prop); - AddonManagerPrivate[prop](); - do_throw(prop + " did not throw an exception"); - } - catch (e) { - if (e.result != Components.results.NS_ERROR_NOT_INITIALIZED) - do_throw(prop + " threw an unexpected exception: " + e); + try { + do_print(aObjName + "." + prop + "()"); + obj[prop](); + do_throw(prop + " did not throw an exception"); + } + catch (e) { + if (e.result != Components.results.NS_ERROR_NOT_INITIALIZED) + do_throw(prop + " threw an unexpected exception: " + e); + } + } else { + if (typeof desc.get == "function" && aIgnore.getters.indexOf(prop) == -1) { + do_print(aObjName + "." + prop + " getter"); + try { + let temp = obj[prop]; + do_throw(prop + " did not throw an exception"); + } + catch (e) { + if (e.result != Components.results.NS_ERROR_NOT_INITIALIZED) + do_throw(prop + " threw an unexpected exception: " + e); + } + } + if (typeof desc.set == "function" && aIgnore.setters.indexOf(prop) == -1) { + do_print(aObjName + "." + prop + " setter"); + try { + obj[prop] = "i am the walrus"; + do_throw(prop + " did not throw an exception"); + } + catch (e) { + if (e.result != Components.results.NS_ERROR_NOT_INITIALIZED) + do_throw(prop + " threw an unexpected exception: " + e); + } + } } } } function run_test() { createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); - test_functions(); + test_functions("AddonManager", IGNORE); + test_functions("AddonManagerPrivate", IGNORE_PRIVATE); startupManager(); shutdownManager(); - test_functions(); + test_functions("AddonManager", IGNORE); + test_functions("AddonManagerPrivate", IGNORE_PRIVATE); } diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js b/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js index 8b7dc4cfbdfb..6d45833ad7c0 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js @@ -18,6 +18,7 @@ function run_test() { testserver.start(4444); do_test_pending(); + startupManager(); run_test_1(); } From db9586885f0db84769e8e36adafd1c01069081db Mon Sep 17 00:00:00 2001 From: Blair McBride Date: Tue, 18 Sep 2012 17:02:33 +1200 Subject: [PATCH 07/10] Bug 781689 - Remove usage of nsIDOMWindowUtils.goOnline() in mobile's netError.xhtml. r=mfinkle,f=bnicholson --- mobile/android/chrome/content/browser.js | 8 ++++++-- mobile/android/chrome/content/netError.xhtml | 8 ++------ mobile/xul/chrome/content/browser.js | 5 +++++ mobile/xul/chrome/content/content.js | 6 +++++- mobile/xul/chrome/content/netError.xhtml | 8 ++------ 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index 58e62dce7d0f..8cd98df49df4 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -2694,9 +2694,9 @@ Tab.prototype = { // require error page UI to do privileged things, without letting error // pages have any privilege themselves. if (/^about:/.test(target.documentURI)) { - this.browser.addEventListener("click", ErrorPageEventHandler, false); + this.browser.addEventListener("click", ErrorPageEventHandler, true); let listener = function() { - this.browser.removeEventListener("click", ErrorPageEventHandler, false); + this.browser.removeEventListener("click", ErrorPageEventHandler, true); this.browser.removeEventListener("pagehide", listener, true); }.bind(this); @@ -4068,6 +4068,10 @@ var ErrorPageEventHandler = { } else if (target == errorDoc.getElementById("getMeOutOfHereButton")) { errorDoc.location = "about:home"; } + } else if (/^about:neterror\?e=netOffline/.test(ownerDoc.documentURI)) { + let tryAgain = errorDoc.getElementById("errorTryAgain"); + if (target == tryAgain) + Services.io.offline = false; } break; } diff --git a/mobile/android/chrome/content/netError.xhtml b/mobile/android/chrome/content/netError.xhtml index 089943b48d9e..3728306ef30c 100644 --- a/mobile/android/chrome/content/netError.xhtml +++ b/mobile/android/chrome/content/netError.xhtml @@ -76,12 +76,8 @@ function retryThis(buttonEl) { - // If this is the "Offline mode" page, go online! - if (getErrorCode() == "netOffline") { - window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(Components.interfaces.nsIDOMWindowUtils) - .goOnline(); - } + // Note: The application may wish to handle switching off "offline mode" + // before this event handler runs, but using a capturing event handler. // Session history has the URL of the page that failed // to load, not the one of the error page. So, just call diff --git a/mobile/xul/chrome/content/browser.js b/mobile/xul/chrome/content/browser.js index a247dad8cb74..a2890d6ca4ef 100644 --- a/mobile/xul/chrome/content/browser.js +++ b/mobile/xul/chrome/content/browser.js @@ -385,6 +385,7 @@ var Browser = { messageManager.addMessageListener("Browser:CertException", this); messageManager.addMessageListener("Browser:BlockedSite", this); messageManager.addMessageListener("Browser:ErrorPage", this); + messageManager.addMessageListener("Browser:GoOnline", this); messageManager.addMessageListener("Browser:PluginClickToPlayClicked", this); // Broadcast a UIReady message so add-ons know we are finished with startup @@ -484,6 +485,7 @@ var Browser = { messageManager.removeMessageListener("Browser:CertException", this); messageManager.removeMessageListener("Browser:BlockedSite", this); messageManager.removeMessageListener("Browser:ErrorPage", this); + messageManager.removeMessageListener("Browser:GoOnline", this); messageManager.removeMessageListener("Browser:PluginClickToPlayClicked", this); var os = Services.obs; @@ -1265,6 +1267,9 @@ var Browser = { case "Browser:ErrorPage": this._handleErrorPage(aMessage); break; + case "Browser:GoOnline": + Services.io.offline = false; + break; case "Browser:PluginClickToPlayClicked": { // Save off session history let parent = browser.parentNode; diff --git a/mobile/xul/chrome/content/content.js b/mobile/xul/chrome/content/content.js index 0126afd17f73..07908bbc079b 100644 --- a/mobile/xul/chrome/content/content.js +++ b/mobile/xul/chrome/content/content.js @@ -292,7 +292,7 @@ let Content = { // pages and other similar page. This lets us fix bugs like 401575 which // require error page UI to do privileged things, without letting error // pages have any privilege themselves. - addEventListener("click", this, false); + addEventListener("click", this, true); docShell.QueryInterface(Ci.nsIDocShellHistory).useGlobalHistory = true; }, @@ -384,6 +384,10 @@ let Content = { // http://hg.mozilla.org/mozilla-central/file/855e5cd3c884/browser/base/content/browser.js#l2672 // http://hg.mozilla.org/mozilla-central/file/855e5cd3c884/browser/components/safebrowsing/content/globalstore.js } + } else if (/^about:neterror\?e=netOffline/.test(ownerDoc.documentURI)) { + let tryAgain = errorDoc.getElementById("errorTryAgain"); + if (target == tryAgain) + sendSyncMessage("Browser:GoOnline", { }); } break; } diff --git a/mobile/xul/chrome/content/netError.xhtml b/mobile/xul/chrome/content/netError.xhtml index 089943b48d9e..3728306ef30c 100644 --- a/mobile/xul/chrome/content/netError.xhtml +++ b/mobile/xul/chrome/content/netError.xhtml @@ -76,12 +76,8 @@ function retryThis(buttonEl) { - // If this is the "Offline mode" page, go online! - if (getErrorCode() == "netOffline") { - window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(Components.interfaces.nsIDOMWindowUtils) - .goOnline(); - } + // Note: The application may wish to handle switching off "offline mode" + // before this event handler runs, but using a capturing event handler. // Session history has the URL of the page that failed // to load, not the one of the error page. So, just call From 34d5f5c6d53db221474089dd94064e3509e0cf3d Mon Sep 17 00:00:00 2001 From: Girish Sharma Date: Mon, 17 Sep 2012 21:59:58 +0530 Subject: [PATCH 08/10] Bug 789578 - The new HTML panel missing the arrows for collapsing elements' children on Windows, r=paul --HG-- extra : rebase_source : 8128e70f69b2d8335e48944dc1b16bf3c602bc93 --- browser/themes/winstripe/devtools/markup-view.css | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/browser/themes/winstripe/devtools/markup-view.css b/browser/themes/winstripe/devtools/markup-view.css index ef3483d2db2a..fbf8b644bb30 100644 --- a/browser/themes/winstripe/devtools/markup-view.css +++ b/browser/themes/winstripe/devtools/markup-view.css @@ -55,15 +55,17 @@ li.container { .expander { position: absolute; - -moz-appearance: treetwisty; - top: 0; + top: 5px; left: 0; width: 14px; height: 14px; + background-repeat: no-repeat; + background-position: center; + background-image: url("chrome://global/skin/tree/twisty-clsd.png"); } .expander[expanded] { - -moz-appearance: treetwistyopen; + background-image: url("chrome://global/skin/tree/twisty-open.png"); } .styleinspector-propertyeditor { From 62800a36c36fb9a4bcee989614725cac9d1a4bdb Mon Sep 17 00:00:00 2001 From: Blair McBride Date: Tue, 18 Sep 2012 19:27:55 +1200 Subject: [PATCH 09/10] Backout 7209f50695da (bug 788378) due to debug xpcshell orange --- toolkit/mozapps/extensions/AddonManager.jsm | 56 ----------- .../extensions/test/xpcshell/test_shutdown.js | 98 ++++++++----------- .../test/xpcshell/test_updatecheck.js | 1 - 3 files changed, 40 insertions(+), 115 deletions(-) diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm index 2dceb4b85215..ceda1d4b50dc 100644 --- a/toolkit/mozapps/extensions/AddonManager.jsm +++ b/toolkit/mozapps/extensions/AddonManager.jsm @@ -1932,26 +1932,14 @@ var AddonManagerInternal = { }, get addonTypes() { - if (!gStarted) - throw Components.Exception("AddonManager is not initialized", - Cr.NS_ERROR_NOT_INITIALIZED); - return this.typesProxy; }, get autoUpdateDefault() { - if (!gStarted) - throw Components.Exception("AddonManager is not initialized", - Cr.NS_ERROR_NOT_INITIALIZED); - return gAutoUpdateDefault; }, set autoUpdateDefault(aValue) { - if (!gStarted) - throw Components.Exception("AddonManager is not initialized", - Cr.NS_ERROR_NOT_INITIALIZED); - aValue = !!aValue; if (aValue != gAutoUpdateDefault) Services.prefs.setBoolPref(PREF_EM_AUTOUPDATE_DEFAULT, aValue); @@ -1959,18 +1947,10 @@ var AddonManagerInternal = { }, get checkCompatibility() { - if (!gStarted) - throw Components.Exception("AddonManager is not initialized", - Cr.NS_ERROR_NOT_INITIALIZED); - return gCheckCompatibility; }, set checkCompatibility(aValue) { - if (!gStarted) - throw Components.Exception("AddonManager is not initialized", - Cr.NS_ERROR_NOT_INITIALIZED); - aValue = !!aValue; if (aValue != gCheckCompatibility) { if (!aValue) @@ -1982,18 +1962,10 @@ var AddonManagerInternal = { }, get strictCompatibility() { - if (!gStarted) - throw Components.Exception("AddonManager is not initialized", - Cr.NS_ERROR_NOT_INITIALIZED); - return gStrictCompatibility; }, set strictCompatibility(aValue) { - if (!gStarted) - throw Components.Exception("AddonManager is not initialized", - Cr.NS_ERROR_NOT_INITIALIZED); - aValue = !!aValue; if (aValue != gStrictCompatibility) Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, aValue); @@ -2001,26 +1973,14 @@ var AddonManagerInternal = { }, get checkUpdateSecurityDefault() { - if (!gStarted) - throw Components.Exception("AddonManager is not initialized", - Cr.NS_ERROR_NOT_INITIALIZED); - return gCheckUpdateSecurityDefault; }, get checkUpdateSecurity() { - if (!gStarted) - throw Components.Exception("AddonManager is not initialized", - Cr.NS_ERROR_NOT_INITIALIZED); - return gCheckUpdateSecurity; }, set checkUpdateSecurity(aValue) { - if (!gStarted) - throw Components.Exception("AddonManager is not initialized", - Cr.NS_ERROR_NOT_INITIALIZED); - aValue = !!aValue; if (aValue != gCheckUpdateSecurity) { if (aValue != gCheckUpdateSecurityDefault) @@ -2032,18 +1992,10 @@ var AddonManagerInternal = { }, get updateEnabled() { - if (!gStarted) - throw Components.Exception("AddonManager is not initialized", - Cr.NS_ERROR_NOT_INITIALIZED); - return gUpdateEnabled; }, set updateEnabled(aValue) { - if (!gStarted) - throw Components.Exception("AddonManager is not initialized", - Cr.NS_ERROR_NOT_INITIALIZED); - aValue = !!aValue; if (aValue != gUpdateEnabled) Services.prefs.setBoolPref(PREF_EM_UPDATE_ENABLED, aValue); @@ -2051,10 +2003,6 @@ var AddonManagerInternal = { }, get hotfixID() { - if (!gStarted) - throw Components.Exception("AddonManager is not initialized", - Cr.NS_ERROR_NOT_INITIALIZED); - return gHotfixID; }, }; @@ -2392,10 +2340,6 @@ var AddonManager = { * @return true if the addon should auto-update, false otherwise. */ shouldAutoUpdate: function AM_shouldAutoUpdate(aAddon) { - if (!gStarted) - throw Components.Exception("AddonManager is not initialized", - Cr.NS_ERROR_NOT_INITIALIZED); - if (!aAddon || typeof aAddon != "object") throw Components.Exception("aAddon must be specified", Cr.NS_ERROR_INVALID_ARG); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js b/toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js index 24385b75ea58..60d74b4d8831 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js @@ -4,75 +4,57 @@ // Verify that API functions fail if the Add-ons Manager isn't initialised. -const IGNORE = { - funcs: ["escapeAddonURI", "getStartupChanges", "addTypeListener", - "removeTypeListener", "addAddonListener", "removeAddonListener", - "addInstallListener", "removeInstallListener", "addManagerListener", - "removeManagerListener"], - getters: [], - setters: [] -}; +const IGNORE = ["escapeAddonURI", "shouldAutoUpdate", "getStartupChanges", + "addTypeListener", "removeTypeListener", + "addAddonListener", "removeAddonListener", + "addInstallListener", "removeInstallListener", + "addManagerListener", "removeManagerListener"]; -const IGNORE_PRIVATE = { - funcs: ["AddonAuthor", "AddonCompatibilityOverride", "AddonScreenshot", - "AddonType", "startup", "shutdown", "registerProvider", - "unregisterProvider", "addStartupChange", "removeStartupChange"], - getters: [], - setters: [] -}; +const IGNORE_PRIVATE = ["AddonAuthor", "AddonCompatibilityOverride", + "AddonScreenshot", "AddonType", "startup", "shutdown", + "registerProvider", "unregisterProvider", + "addStartupChange", "removeStartupChange"]; +function test_functions() { + for (let prop in AddonManager) { + if (typeof AddonManager[prop] != "function") + continue; + if (IGNORE.indexOf(prop) != -1) + continue; -function test_functions(aObjName, aIgnore) { - let obj = this[aObjName]; - for (let prop in obj) { - let desc = Object.getOwnPropertyDescriptor(obj, prop); + try { + do_print("AddonManager." + prop); + AddonManager[prop](); + do_throw(prop + " did not throw an exception"); + } + catch (e) { + if (e.result != Components.results.NS_ERROR_NOT_INITIALIZED) + do_throw(prop + " threw an unexpected exception: " + e); + } + } - if (typeof desc.value == "function") { - if (aIgnore.funcs.indexOf(prop) != -1) - continue; + for (let prop in AddonManagerPrivate) { + if (typeof AddonManagerPrivate[prop] != "function") + continue; + if (IGNORE_PRIVATE.indexOf(prop) != -1) + continue; - try { - do_print(aObjName + "." + prop + "()"); - obj[prop](); - do_throw(prop + " did not throw an exception"); - } - catch (e) { - if (e.result != Components.results.NS_ERROR_NOT_INITIALIZED) - do_throw(prop + " threw an unexpected exception: " + e); - } - } else { - if (typeof desc.get == "function" && aIgnore.getters.indexOf(prop) == -1) { - do_print(aObjName + "." + prop + " getter"); - try { - let temp = obj[prop]; - do_throw(prop + " did not throw an exception"); - } - catch (e) { - if (e.result != Components.results.NS_ERROR_NOT_INITIALIZED) - do_throw(prop + " threw an unexpected exception: " + e); - } - } - if (typeof desc.set == "function" && aIgnore.setters.indexOf(prop) == -1) { - do_print(aObjName + "." + prop + " setter"); - try { - obj[prop] = "i am the walrus"; - do_throw(prop + " did not throw an exception"); - } - catch (e) { - if (e.result != Components.results.NS_ERROR_NOT_INITIALIZED) - do_throw(prop + " threw an unexpected exception: " + e); - } - } + try { + do_print("AddonManagerPrivate." + prop); + AddonManagerPrivate[prop](); + do_throw(prop + " did not throw an exception"); + } + catch (e) { + if (e.result != Components.results.NS_ERROR_NOT_INITIALIZED) + do_throw(prop + " threw an unexpected exception: " + e); } } } function run_test() { createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); - test_functions("AddonManager", IGNORE); - test_functions("AddonManagerPrivate", IGNORE_PRIVATE); + test_functions(); startupManager(); shutdownManager(); - test_functions("AddonManager", IGNORE); - test_functions("AddonManagerPrivate", IGNORE_PRIVATE); + test_functions(); } diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js b/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js index 6d45833ad7c0..8b7dc4cfbdfb 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js @@ -18,7 +18,6 @@ function run_test() { testserver.start(4444); do_test_pending(); - startupManager(); run_test_1(); } From 896f520d2f52dc4445430f3539b8ced538969dae Mon Sep 17 00:00:00 2001 From: Panos Astithas Date: Tue, 18 Sep 2012 10:30:02 +0300 Subject: [PATCH 10/10] Remove redundant check for Debugger.Object.displayName property (bug 786711). r=jimb --- toolkit/devtools/debugger/server/dbg-script-actors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkit/devtools/debugger/server/dbg-script-actors.js b/toolkit/devtools/debugger/server/dbg-script-actors.js index 1f8018cb31e1..caccf75def45 100644 --- a/toolkit/devtools/debugger/server/dbg-script-actors.js +++ b/toolkit/devtools/debugger/server/dbg-script-actors.js @@ -1826,7 +1826,7 @@ function getFunctionName(aFunction) { let desc = aFunction.getOwnPropertyDescriptor("displayName"); if (desc && desc.value && typeof desc.value == "string") { name = desc.value; - } else if ("displayName" in aFunction) { + } else { // Otherwise use SpiderMonkey's inferred name. name = aFunction.displayName; }