From d58917713be3570287f2f992b7f6549845217f3e Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 7 Jul 2017 18:54:37 -0700 Subject: [PATCH] Bug 1357490: Part 1: Run toolkit xpcshell tests in both in-process and OOP modes. r=aswan MozReview-Commit-ID: 7YYO8ldupn3 --HG-- rename : toolkit/components/extensions/test/xpcshell/head_remote.js => toolkit/components/extensions/test/xpcshell/head_e10s.js rename : toolkit/components/extensions/test/xpcshell/xpcshell-remote.ini => toolkit/components/extensions/test/xpcshell/xpcshell-e10s.ini extra : source : 33f6f0354aded142e7a41d5a6209d0d95c4c7521 extra : intermediate-source : 663351357fa7791bb6d08bf7b470ca5fcdccb77e extra : histedit_source : b0eeaa1bbcd7e5ef729c5b1c26003a7d1af2af7e%2C0ee5000a87ebb9717ff007608620739e0ae1ee30 --- toolkit/components/extensions/Extension.jsm | 5 + .../extensions/ExtensionXPCShellUtils.jsm | 16 +++- toolkit/components/extensions/moz.build | 1 + .../extensions/test/xpcshell/head.js | 5 +- .../extensions/test/xpcshell/head_e10s.js | 5 + .../extensions/test/xpcshell/head_remote.js | 5 +- .../test/xpcshell/xpcshell-common.ini | 1 - .../test/xpcshell/xpcshell-e10s.ini | 12 +++ .../test/xpcshell/xpcshell-remote.ini | 5 +- .../extensions/test/xpcshell/xpcshell.ini | 95 ++++++------------- 10 files changed, 73 insertions(+), 77 deletions(-) create mode 100644 toolkit/components/extensions/test/xpcshell/head_e10s.js create mode 100644 toolkit/components/extensions/test/xpcshell/xpcshell-e10s.ini diff --git a/toolkit/components/extensions/Extension.jsm b/toolkit/components/extensions/Extension.jsm index b9d82130f907..95d7c28ee3e6 100644 --- a/toolkit/components/extensions/Extension.jsm +++ b/toolkit/components/extensions/Extension.jsm @@ -1161,6 +1161,11 @@ this.Extension = class extends ExtensionData { return; } + if (this.rootURI instanceof Ci.nsIJARURI) { + let file = this.rootURI.JARFile.QueryInterface(Ci.nsIFileURL).file; + Services.ppmm.broadcastAsyncMessage("Extension:FlushJarCache", {path: file.path}); + } + if (this.cleanupFile || ["ADDON_INSTALL", "ADDON_UNINSTALL", "ADDON_UPGRADE", "ADDON_DOWNGRADE"].includes(reason)) { StartupCache.clearAddonData(this.id); diff --git a/toolkit/components/extensions/ExtensionXPCShellUtils.jsm b/toolkit/components/extensions/ExtensionXPCShellUtils.jsm index e55705ca2ade..49fe9f60d217 100644 --- a/toolkit/components/extensions/ExtensionXPCShellUtils.jsm +++ b/toolkit/components/extensions/ExtensionXPCShellUtils.jsm @@ -523,6 +523,13 @@ class AOMExtensionWrapper extends ExtensionWrapper { } } + async _flushCache() { + if (this.extension && this.extension.rootURI instanceof Ci.nsIJARURI) { + let file = this.extension.rootURI.JARFile.QueryInterface(Ci.nsIFileURL).file; + await Services.ppmm.broadcastAsyncMessage("Extension:FlushJarCache", {path: file.path}); + } + } + get version() { return this.addon && this.addon.version; } @@ -540,12 +547,19 @@ class AOMExtensionWrapper extends ExtensionWrapper { return this._install(this.file); } - upgrade(data) { + async unload() { + await this._flushCache(); + return super.unload(); + } + + async upgrade(data) { this.startupPromise = new Promise(resolve => { this.resolveStartup = resolve; }); this.state = "restarting"; + await this._flushCache(); + let xpiFile = Extension.generateXPI(data); this.cleanupFiles.push(xpiFile); diff --git a/toolkit/components/extensions/moz.build b/toolkit/components/extensions/moz.build index bdd8a95ecc6e..7c142cee3b9a 100644 --- a/toolkit/components/extensions/moz.build +++ b/toolkit/components/extensions/moz.build @@ -84,6 +84,7 @@ MOCHITEST_MANIFESTS += [ MOCHITEST_CHROME_MANIFESTS += ['test/mochitest/chrome.ini'] XPCSHELL_TESTS_MANIFESTS += [ 'test/xpcshell/native_messaging.ini', + 'test/xpcshell/xpcshell-e10s.ini', 'test/xpcshell/xpcshell-remote.ini', 'test/xpcshell/xpcshell.ini', ] diff --git a/toolkit/components/extensions/test/xpcshell/head.js b/toolkit/components/extensions/test/xpcshell/head.js index 2fe5160d19d0..96bf15cc9476 100644 --- a/toolkit/components/extensions/test/xpcshell/head.js +++ b/toolkit/components/extensions/test/xpcshell/head.js @@ -5,6 +5,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; /* exported createHttpServer, promiseConsoleOutput, cleanupDir */ Components.utils.import("resource://gre/modules/AppConstants.jsm"); +Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); Components.utils.import("resource://gre/modules/Timer.jsm"); Components.utils.import("resource://testing-common/AddonTestUtils.jsm"); @@ -25,8 +26,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "NetUtil", "resource://gre/modules/NetUtil.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "Schemas", "resource://gre/modules/Schemas.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "Services", - "resource://gre/modules/Services.jsm"); + +Services.prefs.setBoolPref("extensions.webextensions.remote", false); ExtensionTestUtils.init(this); diff --git a/toolkit/components/extensions/test/xpcshell/head_e10s.js b/toolkit/components/extensions/test/xpcshell/head_e10s.js new file mode 100644 index 000000000000..55ff2164a10e --- /dev/null +++ b/toolkit/components/extensions/test/xpcshell/head_e10s.js @@ -0,0 +1,5 @@ +"use strict"; + +/* globals ExtensionTestUtils */ + +ExtensionTestUtils.remoteContentScripts = true; diff --git a/toolkit/components/extensions/test/xpcshell/head_remote.js b/toolkit/components/extensions/test/xpcshell/head_remote.js index 55ff2164a10e..35eb498f5083 100644 --- a/toolkit/components/extensions/test/xpcshell/head_remote.js +++ b/toolkit/components/extensions/test/xpcshell/head_remote.js @@ -1,5 +1,4 @@ "use strict"; -/* globals ExtensionTestUtils */ - -ExtensionTestUtils.remoteContentScripts = true; +Services.prefs.setBoolPref("extensions.webextensions.remote", true); +Services.prefs.setIntPref("dom.ipc.keepProcessesAlive.extension", 1); diff --git a/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini b/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini index f8f012ee00eb..ecd6af55e0a8 100644 --- a/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini +++ b/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini @@ -42,7 +42,6 @@ skip-if = true # This test no longer tests what it is meant to test. [test_ext_runtime_getPlatformInfo.js] [test_ext_runtime_onInstalled_and_onStartup.js] [test_ext_runtime_sendMessage.js] -[test_ext_runtime_sendMessage_args.js] [test_ext_runtime_sendMessage_errors.js] [test_ext_runtime_sendMessage_no_receiver.js] [test_ext_runtime_sendMessage_self.js] diff --git a/toolkit/components/extensions/test/xpcshell/xpcshell-e10s.ini b/toolkit/components/extensions/test/xpcshell/xpcshell-e10s.ini new file mode 100644 index 000000000000..4c4737bf4758 --- /dev/null +++ b/toolkit/components/extensions/test/xpcshell/xpcshell-e10s.ini @@ -0,0 +1,12 @@ +[DEFAULT] +head = head.js head_e10s.js +tail = +firefox-appdir = browser +skip-if = appname == "thunderbird" || os == "android" +dupe-manifest = +support-files = + data/** + xpcshell-content.ini +tags = webextensions webextensions-e10s + +[include:xpcshell-content.ini] diff --git a/toolkit/components/extensions/test/xpcshell/xpcshell-remote.ini b/toolkit/components/extensions/test/xpcshell/xpcshell-remote.ini index 7a0452810026..8af28a476edc 100644 --- a/toolkit/components/extensions/test/xpcshell/xpcshell-remote.ini +++ b/toolkit/components/extensions/test/xpcshell/xpcshell-remote.ini @@ -1,5 +1,5 @@ [DEFAULT] -head = head.js head_remote.js +head = head.js head_remote.js head_e10s.js tail = firefox-appdir = browser skip-if = appname == "thunderbird" || os == "android" @@ -7,6 +7,7 @@ dupe-manifest = support-files = data/** xpcshell-content.ini -tags = webextensions webextensions-e10s +tags = webextensions remote-webextensions +[include:xpcshell-common.ini] [include:xpcshell-content.ini] diff --git a/toolkit/components/extensions/test/xpcshell/xpcshell.ini b/toolkit/components/extensions/test/xpcshell/xpcshell.ini index c482cc94b674..2f09e7b4057e 100644 --- a/toolkit/components/extensions/test/xpcshell/xpcshell.ini +++ b/toolkit/components/extensions/test/xpcshell/xpcshell.ini @@ -7,7 +7,24 @@ support-files = data/** head_sync.js xpcshell-content.ini -tags = webextensions +tags = webextensions in-process-webextensions + +# This file contains tests which are not affected by multi-process +# configuration, or do not support out-of-process content or extensions +# for one reason or another. +# +# Tests which are affected by remote content or remote extensions should +# go in one of: +# +# - xpcshell-common.ini +# For tests which should run in all configurations. +# - xpcshell-remote.ini +# For tests which should only run with both remote extensions and remote content. +# - xpcshell-content.ini +# For tests which rely on content pages, and should run in all configurations. +# - xpcshell-e10s.ini +# For tests which rely on conetn pages, and should only run with remote content +# but in-process extensions. [test_MatchPattern.js] [test_WebExtensionContentScript.js] @@ -15,86 +32,28 @@ tags = webextensions [test_csp_custom_policies.js] [test_csp_validator.js] -[test_ext_alarms.js] -[test_ext_alarms_does_not_fire.js] -[test_ext_alarms_periodic.js] -[test_ext_alarms_replaces.js] -[test_ext_api_permissions.js] -[test_ext_background_generated_load_events.js] -[test_ext_background_generated_reload.js] -[test_ext_background_global_history.js] -skip-if = os == "android" # Android does not use Places for history. -[test_ext_background_private_browsing.js] -[test_ext_background_runtime_connect_params.js] -[test_ext_background_sub_windows.js] -[test_ext_background_window_properties.js] -skip-if = os == "android" -[test_ext_browserSettings.js] [test_ext_contexts.js] -[test_ext_contextual_identities.js] -skip-if = os == "android" # Containers are not exposed to android. -[test_ext_debugging_utils.js] -[test_ext_downloads.js] -[test_ext_downloads_download.js] -skip-if = os == "android" -[test_ext_downloads_misc.js] -skip-if = os == "android" || (os=='linux' && bits==32) # linux32: bug 1324870 -[test_ext_downloads_search.js] -skip-if = os == "android" -[test_ext_experiments.js] -[test_ext_extension.js] -[test_ext_extension_content_telemetry.js] -[test_ext_extension_startup_telemetry.js] -[test_ext_extensionPreferencesManager.js] -[test_ext_extensionSettingsStore.js] -[test_ext_idle.js] [test_ext_json_parser.js] -[test_ext_localStorage.js] -[test_ext_management.js] -[test_ext_management_uninstall_self.js] [test_ext_manifest_content_security_policy.js] [test_ext_manifest_incognito.js] [test_ext_manifest_minimum_chrome_version.js] [test_ext_manifest_themes.js] -[test_ext_onmessage_removelistener.js] -skip-if = true # This test no longer tests what it is meant to test. -[test_ext_permissions.js] -skip-if = os == "android" # Bug 1350559 -[test_ext_privacy.js] -[test_ext_privacy_disable.js] -[test_ext_privacy_update.js] -[test_ext_runtime_connect_no_receiver.js] -[test_ext_runtime_getBrowserInfo.js] -[test_ext_runtime_getPlatformInfo.js] -[test_ext_runtime_onInstalled_and_onStartup.js] -[test_ext_runtime_sendMessage.js] -[test_ext_runtime_sendMessage_args.js] -[test_ext_runtime_sendMessage_errors.js] -[test_ext_runtime_sendMessage_no_receiver.js] -[test_ext_runtime_sendMessage_self.js] [test_ext_schemas.js] [test_ext_schemas_async.js] [test_ext_schemas_allowed_contexts.js] [test_ext_schemas_revoke.js] -[test_ext_shutdown_cleanup.js] -[test_ext_simple.js] -[test_ext_startup_cache.js] -[test_ext_storage.js] -[test_ext_storage_sync.js] -head = head.js head_sync.js -skip-if = os == "android" -[test_ext_storage_sync_crypto.js] -skip-if = os == "android" -[test_ext_storage_telemetry.js] [test_ext_themes_supported_properties.js] -[test_ext_topSites.js] -skip-if = os == "android" [test_ext_unknown_permissions.js] -[test_ext_legacy_extension_context.js] -[test_ext_legacy_extension_embedding.js] [test_locale_converter.js] [test_locale_data.js] -[test_native_messaging.js] -skip-if = os == "android" + +[test_ext_permissions.js] +skip-if = os == "android" # Bug 1350559 +[test_ext_runtime_sendMessage_args.js] + +[test_ext_legacy_extension_context.js] +[test_ext_legacy_extension_embedding.js] [test_proxy_scripts.js] + +[include:xpcshell-common.ini] [include:xpcshell-content.ini]