--- a/browser/base/content/test/social/browser_aboutHome_activation.js
+++ b/browser/base/content/test/social/browser_aboutHome_activation.js
@@ -1,13 +1,13 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-var SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
+var SocialService = Cu.import("resource:///modules/SocialService.jsm", {}).SocialService;
XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AboutHomeUtils",
"resource:///modules/AboutHome.jsm");
var snippet =
' <script>' +
--- a/browser/base/content/test/social/browser_addons.js
+++ b/browser/base/content/test/social/browser_addons.js
@@ -1,10 +1,10 @@
var AddonManager = Cu.import("resource://gre/modules/AddonManager.jsm", {}).AddonManager;
-var SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
+var SocialService = Cu.import("resource:///modules/SocialService.jsm", {}).SocialService;
var manifest = {
name: "provider 1",
origin: "https://example.com",
shareURL: "https://example.com/browser/browser/base/content/test/social/social_share.html",
iconURL: "https://example.com/browser/browser/base/content/test/general/moz.png"
};
var manifest2 = { // used for testing install
--- a/browser/base/content/test/social/browser_blocklist.js
+++ b/browser/base/content/test/social/browser_blocklist.js
@@ -1,15 +1,15 @@
/* 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/. */
// a place for miscellaneous social tests
-var SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
+var SocialService = Cu.import("resource:///modules/SocialService.jsm", {}).SocialService;
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
var blocklistURL = "http://example.com/browser/browser/base/content/test/social/blocklist.xml";
var manifest = { // normal provider
name: "provider ok",
origin: "https://example.com",
shareURL: "https://example.com/browser/browser/base/content/test/social/social_share.html",
--- a/browser/base/content/test/social/browser_share.js
+++ b/browser/base/content/test/social/browser_share.js
@@ -1,10 +1,10 @@
-var SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
+var SocialService = Cu.import("resource:///modules/SocialService.jsm", {}).SocialService;
var baseURL = "https://example.com/browser/browser/base/content/test/social/";
var manifest = { // normal provider
name: "provider 1",
origin: "https://example.com",
iconURL: "https://example.com/browser/browser/base/content/test/general/moz.png",
shareURL: "https://example.com/browser/browser/base/content/test/social/share.html"
--- a/browser/base/content/test/social/browser_social_activation.js
+++ b/browser/base/content/test/social/browser_social_activation.js
@@ -5,17 +5,17 @@
///////////////////
//
// Whitelisting this test.
// As part of bug 1077403, the leaking uncaught rejection should be fixed.
//
thisTestLeaksUncaughtRejectionsAndShouldBeFixed("TypeError: Assert is null");
-var SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
+var SocialService = Cu.import("resource:///modules/SocialService.jsm", {}).SocialService;
var tabsToRemove = [];
function removeProvider(provider) {
return new Promise(resolve => {
// a full install sets the manifest into a pref, addProvider alone doesn't,
// make sure we uninstall if the manifest was added.
if (provider.manifest) {
--- a/browser/base/content/test/social/head.js
+++ b/browser/base/content/test/social/head.js
@@ -51,17 +51,17 @@ function checkProviderPrefsEmpty(isError
function defaultFinishChecks() {
checkProviderPrefsEmpty(true);
finish();
}
function runSocialTestWithProvider(manifest, callback, finishcallback) {
- let SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
+ let SocialService = Cu.import("resource:///modules/SocialService.jsm", {}).SocialService;
let manifests = Array.isArray(manifest) ? manifest : [manifest];
// Check that none of the provider's content ends up in history.
function finishCleanUp() {
for (let i = 0; i < manifests.length; i++) {
let m = manifests[i];
for (let what of ['iconURL', 'shareURL']) {
@@ -188,17 +188,17 @@ function runSocialTests(tests, cbPreTest
});
}
runNextTest();
}
// A fairly large hammer which checks all aspects of the SocialUI for
// internal consistency.
function checkSocialUI(win) {
- let SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
+ let SocialService = Cu.import("resource:///modules/SocialService.jsm", {}).SocialService;
// if we have enabled providers, we should also have instances of those
// providers
if (SocialService.hasEnabledProviders) {
ok(Social.providers.length > 0, "providers are enabled");
} else {
is(Social.providers.length, 0, "providers are not enabled");
}
}
--- a/browser/modules/Social.jsm
+++ b/browser/modules/Social.jsm
@@ -17,17 +17,17 @@ const PANEL_MIN_HEIGHT = 190;
const PANEL_MIN_WIDTH = 330;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
"resource:///modules/CustomizableUI.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SocialService",
- "resource://gre/modules/SocialService.jsm");
+ "resource:///modules/SocialService.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PageMetadata",
"resource://gre/modules/PageMetadata.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
"resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/Promise.jsm");
rename from toolkit/components/social/SocialService.jsm
rename to browser/modules/SocialService.jsm
--- a/browser/modules/moz.build
+++ b/browser/modules/moz.build
@@ -38,16 +38,17 @@ EXTRA_JS_MODULES += [
'ProcessHangMonitor.jsm',
'ReaderParent.jsm',
'RecentWindow.jsm',
'RemotePrompt.jsm',
'Sanitizer.jsm',
'SelfSupportBackend.jsm',
'SitePermissions.jsm',
'Social.jsm',
+ 'SocialService.jsm',
'TabGroupsMigrator.jsm',
'TransientPrefs.jsm',
'URLBarZoom.jsm',
'webrtcUI.jsm',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
EXTRA_JS_MODULES += [
--- a/browser/modules/test/unit/social/head.js
+++ b/browser/modules/test/unit/social/head.js
@@ -111,17 +111,100 @@ function do_initialize_social(enabledOnS
// expecting 2 providers installed
do_wait_observer("social:providers-changed", function() {
do_check_eq(Social.providers.length, 2, "2 providers installed");
do_execute_soon(cb);
});
}
// import and initialize everything
- SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
+ SocialService = Cu.import("resource:///modules/SocialService.jsm", {}).SocialService;
do_check_eq(enabledOnStartup, SocialService.hasEnabledProviders, "Service has enabled providers");
Social = Cu.import("resource:///modules/Social.jsm", {}).Social;
do_check_false(Social.initialized, "Social is not initialized");
Social.init();
do_check_true(Social.initialized, "Social is initialized");
if (!enabledOnStartup)
do_execute_soon(cb);
}
+
+function AsyncRunner() {
+ do_test_pending();
+ do_register_cleanup(() => this.destroy());
+
+ this._callbacks = {
+ done: do_test_finished,
+ error: function (err) {
+ // xpcshell test functions like do_check_eq throw NS_ERROR_ABORT on
+ // failure. Ignore those so they aren't rethrown here.
+ if (err !== Cr.NS_ERROR_ABORT) {
+ if (err.stack) {
+ err = err + " - See following stack:\n" + err.stack +
+ "\nUseless do_throw stack";
+ }
+ do_throw(err);
+ }
+ },
+ consoleError: function (scriptErr) {
+ // Try to ensure the error is related to the test.
+ let filename = scriptErr.sourceName || scriptErr.toString() || "";
+ if (filename.indexOf("/toolkit/components/social/") >= 0)
+ do_throw(scriptErr);
+ },
+ };
+ this._iteratorQueue = [];
+
+ // This catches errors reported to the console, e.g., via Cu.reportError, but
+ // not on the runner's stack.
+ Cc["@mozilla.org/consoleservice;1"].
+ getService(Ci.nsIConsoleService).
+ registerListener(this);
+}
+
+AsyncRunner.prototype = {
+
+ appendIterator: function appendIterator(iter) {
+ this._iteratorQueue.push(iter);
+ },
+
+ next: function next(arg) {
+ if (!this._iteratorQueue.length) {
+ this.destroy();
+ this._callbacks.done();
+ return;
+ }
+
+ try {
+ var { done, value: val } = this._iteratorQueue[0].next(arg);
+ if (done) {
+ this._iteratorQueue.shift();
+ this.next();
+ return;
+ }
+ }
+ catch (err) {
+ this._callbacks.error(err);
+ }
+
+ // val is an iterator => prepend it to the queue and start on it
+ // val is otherwise truthy => call next
+ if (val) {
+ if (typeof(val) != "boolean")
+ this._iteratorQueue.unshift(val);
+ this.next();
+ }
+ },
+
+ destroy: function destroy() {
+ Cc["@mozilla.org/consoleservice;1"].
+ getService(Ci.nsIConsoleService).
+ unregisterListener(this);
+ this.destroy = function alreadyDestroyed() {};
+ },
+
+ observe: function observe(msg) {
+ if (msg instanceof Ci.nsIScriptError &&
+ !(msg.flags & Ci.nsIScriptError.warningFlag))
+ {
+ this._callbacks.consoleError(msg);
+ }
+ },
+};
rename from toolkit/components/social/test/xpcshell/test_SocialService.js
rename to browser/modules/test/unit/social/test_SocialService.js
--- a/toolkit/components/social/test/xpcshell/test_SocialService.js
+++ b/browser/modules/test/unit/social/test_SocialService.js
@@ -20,17 +20,17 @@ function run_test() {
},
{ // provider without workerURL
name: "provider 2",
origin: "https://example2.com",
shareURL: "https://example2.com/share/",
}
];
- Cu.import("resource://gre/modules/SocialService.jsm");
+ Cu.import("resource:///modules/SocialService.jsm");
let runner = new AsyncRunner();
let next = runner.next.bind(runner);
runner.appendIterator(testAddProviders(manifests, next));
runner.appendIterator(testGetProvider(manifests, next));
runner.appendIterator(testGetProviderList(manifests, next));
runner.appendIterator(testAddRemoveProvider(manifests, next));
runner.appendIterator(testIsSameOrigin(manifests, next));
rename from toolkit/components/social/test/xpcshell/test_SocialServiceMigration21.js
rename to browser/modules/test/unit/social/test_SocialServiceMigration21.js
--- a/toolkit/components/social/test/xpcshell/test_SocialServiceMigration21.js
+++ b/browser/modules/test/unit/social/test_SocialServiceMigration21.js
@@ -17,17 +17,17 @@ function run_test() {
name: "provider 1",
origin: "https://example1.com",
builtin: true // as of fx22 this should be true for default prefs
};
DEFAULT_PREFS.setCharPref(manifest.origin, JSON.stringify(manifest));
Services.prefs.setBoolPref("social.active", true);
- Cu.import("resource://gre/modules/SocialService.jsm");
+ Cu.import("resource:///modules/SocialService.jsm");
let runner = new AsyncRunner();
let next = runner.next.bind(runner);
runner.appendIterator(testMigration(manifest, next));
runner.next();
}
function* testMigration(manifest, next) {
rename from toolkit/components/social/test/xpcshell/test_SocialServiceMigration22.js
rename to browser/modules/test/unit/social/test_SocialServiceMigration22.js
--- a/toolkit/components/social/test/xpcshell/test_SocialServiceMigration22.js
+++ b/browser/modules/test/unit/social/test_SocialServiceMigration22.js
@@ -27,17 +27,17 @@ function run_test() {
let active = {};
active[manifest.origin] = 1;
// bad.origin tests that a missing manifest does not break migration, bug 859715
active["bad.origin"] = 1;
activeVal.data = JSON.stringify(active);
Services.prefs.setComplexValue("social.activeProviders",
Ci.nsISupportsString, activeVal);
- Cu.import("resource://gre/modules/SocialService.jsm");
+ Cu.import("resource:///modules/SocialService.jsm");
let runner = new AsyncRunner();
let next = runner.next.bind(runner);
runner.appendIterator(testMigration(manifest, next));
runner.next();
}
function* testMigration(manifest, next) {
rename from toolkit/components/social/test/xpcshell/test_SocialServiceMigration29.js
rename to browser/modules/test/unit/social/test_SocialServiceMigration29.js
--- a/toolkit/components/social/test/xpcshell/test_SocialServiceMigration29.js
+++ b/browser/modules/test/unit/social/test_SocialServiceMigration29.js
@@ -28,17 +28,17 @@ function run_test() {
Services.prefs.setComplexValue("social.activeProviders",
Ci.nsISupportsString, activeVal);
// social.enabled pref is the key focus of this test. We set the user pref,
// and then migration should a) remove the provider from activeProviders and
// b) unset social.enabled
Services.prefs.setBoolPref("social.enabled", false);
- Cu.import("resource://gre/modules/SocialService.jsm");
+ Cu.import("resource:///modules/SocialService.jsm");
let runner = new AsyncRunner();
let next = runner.next.bind(runner);
runner.appendIterator(testMigration(manifest, next));
runner.next();
}
function* testMigration(manifest, next) {
--- a/browser/modules/test/unit/social/test_social.js
+++ b/browser/modules/test/unit/social/test_social.js
@@ -14,17 +14,17 @@ function testStartupEnabled() {
// wait on startup before continuing
do_check_eq(Social.providers.length, 2, "two social providers enabled");
do_check_true(Social.providers[0].enabled, "provider 0 is enabled");
do_check_true(Social.providers[1].enabled, "provider 1 is enabled");
run_next_test();
}
function testDisableAfterStartup() {
- let SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
+ let SocialService = Cu.import("resource:///modules/SocialService.jsm", {}).SocialService;
SocialService.disableProvider(Social.providers[0].origin, function() {
do_wait_observer("social:providers-changed", function() {
do_check_eq(Social.enabled, false, "Social is disabled");
do_check_eq(Social.providers.length, 0, "no social providers available");
do_test_finished();
run_next_test();
});
SocialService.disableProvider(Social.providers[0].origin)
--- a/browser/modules/test/unit/social/xpcshell.ini
+++ b/browser/modules/test/unit/social/xpcshell.ini
@@ -2,8 +2,12 @@
head = head.js
tail =
firefox-appdir = browser
skip-if = toolkit == 'android' || toolkit == 'gonk'
support-files = blocklist.xml
[test_social.js]
[test_socialDisabledStartup.js]
+[test_SocialService.js]
+[test_SocialServiceMigration21.js]
+[test_SocialServiceMigration22.js]
+[test_SocialServiceMigration29.js]
--- a/toolkit/components/moz.build
+++ b/toolkit/components/moz.build
@@ -70,19 +70,16 @@ if CONFIG['MOZ_BUILD_APP'] != 'mobile/an
DIRS += ['narrate', 'viewsource'];
if CONFIG['NS_PRINTING']:
DIRS += ['printing']
if CONFIG['MOZ_CRASHREPORTER']:
DIRS += ['crashes']
-if CONFIG['MOZ_SOCIAL']:
- DIRS += ['social']
-
if CONFIG['BUILD_CTYPES']:
DIRS += ['ctypes']
if CONFIG['MOZ_FEEDS']:
DIRS += ['feeds']
if CONFIG['MOZ_XUL']:
DIRS += ['autocomplete', 'satchel']
deleted file mode 100644
--- a/toolkit/components/social/moz.build
+++ /dev/null
@@ -1,16 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell/xpcshell.ini']
-
-if CONFIG['MOZ_SOCIAL']:
- # social is turned off for android
- EXTRA_JS_MODULES += [
- 'SocialService.jsm',
- ]
-
-with Files('**'):
- BUG_COMPONENT = ('Firefox', 'SocialAPI')
deleted file mode 100644
--- a/toolkit/components/social/test/xpcshell/blocklist.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0"?>
-<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">
- <emItems>
- <emItem blockID="s1" id="bad.com@services.mozilla.org"></emItem>
- </emItems>
-</blocklist>
deleted file mode 100644
--- a/toolkit/components/social/test/xpcshell/head.js
+++ /dev/null
@@ -1,125 +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/. */
-
-var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
-XPCOMUtils.defineLazyModuleGetter(this, "Promise",
- "resource://gre/modules/Promise.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
- "resource://gre/modules/PlacesUtils.jsm");
-
-const MANIFEST_PREFS = Services.prefs.getBranch("social.manifest.");
-const gProfD = do_get_profile();
-
-const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";
-const XULAPPINFO_CID = Components.ID("{c763b610-9d49-455a-bbd2-ede71682a1ac}");
-
-var gAppInfo = null;
-
-function createAppInfo(ID, name, version, platformVersion="1.0") {
- let tmp = {};
- Cu.import("resource://testing-common/AppInfo.jsm", tmp);
- tmp.updateAppInfo({
- ID, name, version, platformVersion,
- crashReporter: true,
- });
- gAppInfo = tmp.getAppInfo();
-}
-
-function initApp() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
- // prepare a blocklist file for the blocklist service
- var blocklistFile = gProfD.clone();
- blocklistFile.append("blocklist.xml");
- if (blocklistFile.exists())
- blocklistFile.remove(false);
- var source = do_get_file("blocklist.xml");
- source.copyTo(gProfD, "blocklist.xml");
- blocklistFile.lastModifiedTime = Date.now();
-}
-
-function AsyncRunner() {
- do_test_pending();
- do_register_cleanup(() => this.destroy());
-
- this._callbacks = {
- done: do_test_finished,
- error: function (err) {
- // xpcshell test functions like do_check_eq throw NS_ERROR_ABORT on
- // failure. Ignore those so they aren't rethrown here.
- if (err !== Cr.NS_ERROR_ABORT) {
- if (err.stack) {
- err = err + " - See following stack:\n" + err.stack +
- "\nUseless do_throw stack";
- }
- do_throw(err);
- }
- },
- consoleError: function (scriptErr) {
- // Try to ensure the error is related to the test.
- let filename = scriptErr.sourceName || scriptErr.toString() || "";
- if (filename.indexOf("/toolkit/components/social/") >= 0)
- do_throw(scriptErr);
- },
- };
- this._iteratorQueue = [];
-
- // This catches errors reported to the console, e.g., via Cu.reportError, but
- // not on the runner's stack.
- Cc["@mozilla.org/consoleservice;1"].
- getService(Ci.nsIConsoleService).
- registerListener(this);
-}
-
-AsyncRunner.prototype = {
-
- appendIterator: function appendIterator(iter) {
- this._iteratorQueue.push(iter);
- },
-
- next: function next(arg) {
- if (!this._iteratorQueue.length) {
- this.destroy();
- this._callbacks.done();
- return;
- }
-
- try {
- var { done, value: val } = this._iteratorQueue[0].next(arg);
- if (done) {
- this._iteratorQueue.shift();
- this.next();
- return;
- }
- }
- catch (err) {
- this._callbacks.error(err);
- }
-
- // val is an iterator => prepend it to the queue and start on it
- // val is otherwise truthy => call next
- if (val) {
- if (typeof(val) != "boolean")
- this._iteratorQueue.unshift(val);
- this.next();
- }
- },
-
- destroy: function destroy() {
- Cc["@mozilla.org/consoleservice;1"].
- getService(Ci.nsIConsoleService).
- unregisterListener(this);
- this.destroy = function alreadyDestroyed() {};
- },
-
- observe: function observe(msg) {
- if (msg instanceof Ci.nsIScriptError &&
- !(msg.flags & Ci.nsIScriptError.warningFlag))
- {
- this._callbacks.consoleError(msg);
- }
- },
-};
deleted file mode 100644
--- a/toolkit/components/social/test/xpcshell/xpcshell.ini
+++ /dev/null
@@ -1,13 +0,0 @@
-[DEFAULT]
-head = head.js
-tail =
-skip-if = toolkit == 'android' || toolkit == 'gonk'
-support-files = blocklist.xml
-
-[test_SocialService.js]
-
-[test_SocialServiceMigration21.js]
-
-[test_SocialServiceMigration22.js]
-
-[test_SocialServiceMigration29.js]