зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1289549 P3 socialapi move toolkit component to browser, r=florian
MozReview-Commit-ID: EpOEnm17nBe --HG-- rename : toolkit/components/social/SocialService.jsm => browser/modules/SocialService.jsm rename : toolkit/components/social/test/xpcshell/test_SocialService.js => browser/modules/test/unit/social/test_SocialService.js rename : toolkit/components/social/test/xpcshell/test_SocialServiceMigration21.js => browser/modules/test/unit/social/test_SocialServiceMigration21.js rename : toolkit/components/social/test/xpcshell/test_SocialServiceMigration22.js => browser/modules/test/unit/social/test_SocialServiceMigration22.js rename : toolkit/components/social/test/xpcshell/test_SocialServiceMigration29.js => browser/modules/test/unit/social/test_SocialServiceMigration29.js
This commit is contained in:
Родитель
e055a24727
Коммит
bd49ab8f31
|
@ -2,7 +2,7 @@
|
|||
* 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");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// 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";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
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/";
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
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 = [];
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ function defaultFinishChecks() {
|
|||
|
||||
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];
|
||||
|
||||
|
@ -193,7 +193,7 @@ function runSocialTests(tests, cbPreTest, cbPostTest, cbFinish) {
|
|||
// 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) {
|
||||
|
|
|
@ -22,7 +22,7 @@ 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",
|
||||
|
|
|
@ -42,6 +42,7 @@ EXTRA_JS_MODULES += [
|
|||
'SelfSupportBackend.jsm',
|
||||
'SitePermissions.jsm',
|
||||
'Social.jsm',
|
||||
'SocialService.jsm',
|
||||
'TabGroupsMigrator.jsm',
|
||||
'TransientPrefs.jsm',
|
||||
'webrtcUI.jsm',
|
||||
|
|
|
@ -116,7 +116,7 @@ function do_initialize_social(enabledOnStartup, 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");
|
||||
|
@ -125,3 +125,86 @@ function do_initialize_social(enabledOnStartup, cb) {
|
|||
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);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -25,8 +25,7 @@ function run_test() {
|
|||
}
|
||||
];
|
||||
|
||||
Cu.import("resource://gre/modules/SocialService.jsm");
|
||||
Cu.import("resource://gre/modules/MozSocialAPI.jsm");
|
||||
Cu.import("resource:///modules/SocialService.jsm");
|
||||
|
||||
let runner = new AsyncRunner();
|
||||
let next = runner.next.bind(runner);
|
||||
|
@ -45,7 +44,6 @@ function* testAddProviders(manifests, next) {
|
|||
do_check_false(SocialService.enabled);
|
||||
let provider = yield SocialService.addProvider(manifests[0], next);
|
||||
do_check_true(SocialService.enabled);
|
||||
do_check_true(MozSocialAPI._enabled);
|
||||
do_check_false(provider.enabled);
|
||||
provider = yield SocialService.addProvider(manifests[1], next);
|
||||
do_check_false(provider.enabled);
|
|
@ -22,7 +22,7 @@ function run_test() {
|
|||
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);
|
|
@ -32,7 +32,7 @@ function run_test() {
|
|||
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);
|
|
@ -33,7 +33,7 @@ function run_test() {
|
|||
// 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);
|
|
@ -19,7 +19,7 @@ function testStartupEnabled() {
|
|||
}
|
||||
|
||||
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");
|
||||
|
|
|
@ -7,3 +7,7 @@ support-files = blocklist.xml
|
|||
|
||||
[test_social.js]
|
||||
[test_socialDisabledStartup.js]
|
||||
[test_SocialService.js]
|
||||
[test_SocialServiceMigration21.js]
|
||||
[test_SocialServiceMigration22.js]
|
||||
[test_SocialServiceMigration29.js]
|
||||
|
|
|
@ -75,9 +75,6 @@ if CONFIG['MOZ_BUILD_APP'] != 'mobile/android':
|
|||
if CONFIG['MOZ_CRASHREPORTER']:
|
||||
DIRS += ['crashes']
|
||||
|
||||
if CONFIG['MOZ_SOCIAL']:
|
||||
DIRS += ['social']
|
||||
|
||||
if CONFIG['BUILD_CTYPES']:
|
||||
DIRS += ['ctypes']
|
||||
|
||||
|
|
|
@ -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')
|
|
@ -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>
|
|
@ -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);
|
||||
}
|
||||
},
|
||||
};
|
|
@ -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]
|
Загрузка…
Ссылка в новой задаче