Backed out 6 changesets (bug 1464542) for xpcshell failures on test_Services.js. CLOSED TREE

Backed out changeset b50af9005851 (bug 1464542)
Backed out changeset 9d3a0ea2cf65 (bug 1464542)
Backed out changeset 71c3475fcbc2 (bug 1464542)
Backed out changeset 51ff93220a95 (bug 1464542)
Backed out changeset e84de1547c09 (bug 1464542)
Backed out changeset bbecc16d08eb (bug 1464542)
This commit is contained in:
Csoregi Natalia 2020-07-09 23:19:26 +03:00
Родитель 595a699c3e
Коммит b355fcc4bf
82 изменённых файлов: 340 добавлений и 643 удалений

Просмотреть файл

@ -5,7 +5,18 @@
const { UrlClassifierTestUtils } = ChromeUtils.import(
"resource://testing-common/UrlClassifierTestUtils.jsm"
);
Services.cookies.QueryInterface(Ci.nsICookieService);
XPCOMUtils.defineLazyServiceGetter(
Services,
"cookies",
"@mozilla.org/cookieService;1",
"nsICookieService"
);
XPCOMUtils.defineLazyServiceGetter(
Services,
"cookiemgr",
"@mozilla.org/cookiemanager;1",
"nsICookieManager"
);
function restore_prefs() {
Services.prefs.clearUserPref("network.cookie.cookieBehavior");
@ -70,12 +81,12 @@ async function test_cookie_settings({
expectedThirdPartyCookies = 0;
}
is(
Services.cookies.countCookiesFromHost(firstPartyURI.host),
Services.cookiemgr.countCookiesFromHost(firstPartyURI.host),
expectedFirstPartyCookies,
"Number of first-party cookies should match expected"
);
is(
Services.cookies.countCookiesFromHost(thirdPartyURI.host),
Services.cookiemgr.countCookiesFromHost(thirdPartyURI.host),
expectedThirdPartyCookies,
"Number of third-party cookies should match expected"
);

Просмотреть файл

@ -193,7 +193,7 @@ const clearLocalStorage = async function(options) {
Services.obs.notifyObservers(null, "extension:purge-localStorage");
}
if (Services.domStorageManager.nextGenLocalStorageEnabled) {
if (Services.lsm.nextGenLocalStorageEnabled) {
// Ideally we could reuse the logic in Sanitizer.jsm or nsIClearDataService,
// but this API exposes an ability to wipe data at a much finger granularity
// than those APIs. So custom logic is used here to wipe only the QM

Просмотреть файл

@ -56,10 +56,7 @@ add_task(async function testLocalStorage() {
await browser.tabs.sendMessage(tabs[0].id, "checkLocalStorageCleared");
await browser.tabs.sendMessage(tabs[1].id, "checkLocalStorageSet");
if (
SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled ===
false
) {
if (SpecialPowers.Services.lsm.nextGenLocalStorageEnabled === false) {
// This assertion fails when localStorage is using the legacy
// implementation (See Bug 1595431).
browser.test.log("Skipped assertion on nextGenLocalStorageEnabled=false");

Просмотреть файл

@ -173,6 +173,9 @@
; JavaScript components
@RESPATH@/browser/components/BrowserComponents.manifest
@RESPATH@/components/EnterprisePolicies.js
@RESPATH@/components/EnterprisePoliciesContent.js
@RESPATH@/components/EnterprisePolicies.manifest
@RESPATH@/components/toolkitsearch.manifest
@RESPATH@/components/extensions.manifest
#ifdef MOZ_UPDATER

Просмотреть файл

@ -29,11 +29,8 @@ idl_deps_dir := .deps
dist_idl_dir := $(DIST)/idl
dist_include_dir := $(DIST)/include
dist_xpcrs_dir := $(DIST)/xpcrs
stub_file := xptdata.stub
process_py := $(topsrcdir)/python/mozbuild/mozbuild/action/xpidl-process.py
target_file := $(topobjdir)/xpcom/reflect/xptinfo/xptdata.cpp
xptdata_h := $(dist_include_dir)/xptdata.h
generated_files := $(target_file) $(xptdata_h)
generated_file := $(topobjdir)/xpcom/reflect/xptinfo/xptdata.cpp
code_gen_py := $(topsrcdir)/xpcom/reflect/xptinfo/xptcodegen.py
code_gen_deps := $(topsrcdir)/xpcom/ds/tools/perfecthash.py
@ -62,21 +59,17 @@ xpt_files := $(addsuffix .xpt,$(xpidl_modules))
depends_files := $(foreach root,$(xpidl_modules),$(idl_deps_dir)/$(root).pp)
GARBAGE += $(stub_file) $(xpt_files) $(depends_files) $(target_file)
GARBAGE += $(xpt_files) $(depends_files) $(generated_file)
ifdef COMPILE_ENVIRONMENT
xpidl:: $(generated_files)
xpidl:: $(generated_file)
endif
# See bug 1420119 for why we need the semicolon.
$(target_file) $(xptdata_h) : $(stub_file) ;
$(xpt_files): $(process_py) $(call mkdir_deps,$(idl_deps_dir) $(dist_include_dir) $(dist_xpcrs_dir))
$(stub_file) : $(xpt_files) $(code_gen_py) $(code_gen_deps)
$(generated_file): $(xpt_files) $(code_gen_py) $(code_gen_deps)
$(REPORT_BUILD)
$(PYTHON3) $(code_gen_py) $(generated_files) $(xpt_files)
@touch $@
$(PYTHON3) $(code_gen_py) $(generated_file) $(xpt_files)
-include $(depends_files)

Просмотреть файл

@ -56,10 +56,8 @@ Classes = [
},
{
'name': 'URIFixup',
'js_name': 'uriFixup',
'cid': '{c6cf88b7-452e-47eb-bdc9-86e3561648ef}',
'contract_ids': ['@mozilla.org/docshell/uri-fixup;1'],
'interfaces': ['nsIURIFixup'],
'jsm': 'resource://gre/modules/URIFixup.jsm',
'constructor': 'URIFixup',
},

Просмотреть файл

@ -6,10 +6,8 @@
Classes = [
{
'js_name': 'droppedLinkHandler',
'cid': '{1f34bc80-1bc7-11d6-a384-d705dd0746fc}',
'contract_ids': ['@mozilla.org/content/dropped-link-handler;1'],
'interfaces': ['nsIDroppedLinkHandler'],
'jsm': 'resource://gre/modules/ContentAreaDropListener.jsm',
'constructor': 'ContentAreaDropListener',
},

Просмотреть файл

@ -327,25 +327,6 @@ inline void AssignJSLinearString(nsAString& dest, JSLinearString* s) {
js::CopyLinearStringChars(dest.BeginWriting(), s, len);
}
inline void AssignJSLinearString(nsACString& dest, JSLinearString* s) {
size_t len = js::GetLinearStringLength(s);
static_assert(js::MaxStringLength < (1 << 30),
"Shouldn't overflow here or in SetCapacity");
dest.SetLength(len);
js::CopyLinearStringChars(dest.BeginWriting(), s, len);
}
template <typename T>
class nsTAutoJSLinearString : public nsTAutoString<T> {
public:
explicit nsTAutoJSLinearString(JSLinearString* str) {
AssignJSLinearString(*this, str);
}
};
using nsAutoJSLinearString = nsTAutoJSLinearString<char16_t>;
using nsAutoJSLinearCString = nsTAutoJSLinearString<char>;
template <typename T>
class nsTAutoJSString : public nsTAutoString<T> {
public:

Просмотреть файл

@ -133,7 +133,7 @@ TestInterfaceJS.prototype = {
testThrowNsresultFromNative(x) {
// We want to throw an exception that we generate from an nsresult thrown
// by a C++ component.
Services.io.notImplemented();
Services.netUtils.notImplemented();
},
testThrowCallbackError(callback) {

Просмотреть файл

@ -10,7 +10,7 @@ async function testSteps() {
];
async function isPreloaded(principal) {
return Services.domStorageManager.isPreloaded(principal);
return Services.lsm.isPreloaded(principal);
}
info("Setting prefs");

Просмотреть файл

@ -185,7 +185,11 @@ ImageObjectProcessor.prototype.process = function(
};
let value = extractor.extractValue(spec);
if (value) {
value = Services.io.parseRequestContentType(value, charset, hadCharset);
value = Services.netUtils.parseRequestContentType(
value,
charset,
hadCharset
);
}
return value || undefined;
}

Просмотреть файл

@ -19,7 +19,7 @@ Services.scriptloader.loadSubScript(
/* import-globals-from helper_localStorage_e10s.js */
function waitForLocalStorageFlush() {
if (Services.domStorageManager.nextGenLocalStorageEnabled) {
if (Services.lsm.nextGenLocalStorageEnabled) {
return new Promise(resolve => executeSoon(resolve));
}
@ -45,7 +45,7 @@ function waitForLocalStorageFlush() {
* notifications, but correctness is guaranteed after the second notification.
*/
function triggerAndWaitForLocalStorageFlush() {
if (Services.domStorageManager.nextGenLocalStorageEnabled) {
if (Services.lsm.nextGenLocalStorageEnabled) {
return new Promise(resolve => executeSoon(resolve));
}
@ -76,7 +76,7 @@ function clearOriginStorageEnsuringNoPreload() {
HELPER_PAGE_ORIGIN
);
if (Services.domStorageManager.nextGenLocalStorageEnabled) {
if (Services.lsm.nextGenLocalStorageEnabled) {
let request = Services.qms.clearStoragesForPrincipal(
principal,
"default",
@ -114,8 +114,8 @@ async function verifyTabPreload(knownTab, expectStorageExists) {
let principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin(
origin
);
if (Services.domStorageManager.nextGenLocalStorageEnabled) {
return Services.domStorageManager.isPreloaded(principal);
if (Services.lsm.nextGenLocalStorageEnabled) {
return Services.lsm.isPreloaded(principal);
}
return !!Services.domStorageManager.getStorage(
null,

Просмотреть файл

@ -87,7 +87,7 @@ requestLongerTimeout(4);
* Verify snapshotting of our localStorage implementation in multi-e10s setup.
*/
add_task(async function() {
if (!Services.domStorageManager.nextGenLocalStorageEnabled) {
if (!Services.lsm.nextGenLocalStorageEnabled) {
ok(true, "Test ignored when the next gen local storage is not enabled.");
return;
}

Просмотреть файл

@ -1,5 +1,5 @@
function localStorageFlush(cb) {
if (SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled) {
if (SpecialPowers.Services.lsm.nextGenLocalStorageEnabled) {
SimpleTest.executeSoon(function() {
cb();
});
@ -17,7 +17,7 @@ function localStorageFlush(cb) {
}
function localStorageReload(callback) {
if (SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled) {
if (SpecialPowers.Services.lsm.nextGenLocalStorageEnabled) {
localStorage.close();
let qms = SpecialPowers.Services.qms;
let principal = SpecialPowers.wrap(document).nodePrincipal;
@ -36,7 +36,7 @@ function localStorageReload(callback) {
}
function localStorageFlushAndReload(callback) {
if (SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled) {
if (SpecialPowers.Services.lsm.nextGenLocalStorageEnabled) {
localStorage.close();
let qms = SpecialPowers.Services.qms;
let principal = SpecialPowers.wrap(document).nodePrincipal;
@ -54,7 +54,7 @@ function localStorageFlushAndReload(callback) {
}
function localStorageClearAll(callback) {
if (SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled) {
if (SpecialPowers.Services.lsm.nextGenLocalStorageEnabled) {
let qms = SpecialPowers.Services.qms;
let ssm = SpecialPowers.Services.scriptSecurityManager;
@ -92,7 +92,7 @@ function localStorageClearAll(callback) {
}
function localStorageClearDomain(domain, callback) {
if (SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled) {
if (SpecialPowers.Services.lsm.nextGenLocalStorageEnabled) {
let qms = SpecialPowers.Services.qms;
let principal = SpecialPowers.wrap(document).nodePrincipal;
let request = qms.clearStoragesForPrincipal(principal, "default", "ls");

Просмотреть файл

@ -89,7 +89,7 @@ function startTest()
localStorageReload(function() {
is(localStorage.length, 0, "localStorage clean in case 4");
if (!SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled &&
if (!SpecialPowers.Services.lsm.nextGenLocalStorageEnabled &&
SpecialPowers.Cc["@mozilla.org/xre/app-info;1"].getService(
SpecialPowers.Ci.nsIXULRuntime).processType != SpecialPowers.Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT) {
// Following tests cannot be run in a child/plugin process type

Просмотреть файл

@ -9,7 +9,7 @@
function startTest()
{
if (SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled) {
if (SpecialPowers.Services.lsm.nextGenLocalStorageEnabled) {
ok(true, "Test ignored when the next gen local storage is enabled.");
SimpleTest.finish();
return;

Просмотреть файл

@ -18,7 +18,7 @@ function doNextTest()
switch (currentTest)
{
case 1:
if (SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled) {
if (SpecialPowers.Services.lsm.nextGenLocalStorageEnabled) {
slaveOrigin = "http://test1.example.com";
} else {
slaveOrigin = "http://example.com";
@ -50,7 +50,7 @@ function doNextTest()
// Try to set a new 500 bytes key and check we fail because we are over the
// quota.
case 5:
if (SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled) {
if (SpecialPowers.Services.lsm.nextGenLocalStorageEnabled) {
slaveOrigin = "http://test1.example.com";
} else {
slaveOrigin = "https://test2.example.com";
@ -67,7 +67,7 @@ function doNextTest()
// Now try again to set 500 bytes key, it must succeed.
case 7:
if (SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled) {
if (SpecialPowers.Services.lsm.nextGenLocalStorageEnabled) {
slaveOrigin = "http://test1.example.com";
} else {
slaveOrigin = "https://test2.example.com";
@ -76,7 +76,7 @@ function doNextTest()
break;
case 8:
if (SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled) {
if (SpecialPowers.Services.lsm.nextGenLocalStorageEnabled) {
SimpleTest.executeSoon(doNextTest);
} else {
// Do a clean up...
@ -92,7 +92,7 @@ function doNextTest()
break;
case 10:
if (SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled) {
if (SpecialPowers.Services.lsm.nextGenLocalStorageEnabled) {
SimpleTest.executeSoon(doNextTest);
} else {
// Do a clean up...

Просмотреть файл

@ -42,7 +42,7 @@ function doNextTest(aWindow) {
// Initialy setup the quota to testing value of 1024B and
// set a 500 bytes key with name length 1 (allocate 501 bytes)
case 1:
if (SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled) {
if (SpecialPowers.Services.lsm.nextGenLocalStorageEnabled) {
slaveOrigin = "http://test1.example.com";
} else {
slaveOrigin = "http://example.com";
@ -74,7 +74,7 @@ function doNextTest(aWindow) {
// Try to set a new 500 bytes key and check we fail because we are over the
// quota.
case 5:
if (SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled) {
if (SpecialPowers.Services.lsm.nextGenLocalStorageEnabled) {
slaveOrigin = "http://test1.example.com";
} else {
slaveOrigin = "https://test2.example.com";
@ -91,7 +91,7 @@ function doNextTest(aWindow) {
// Now try again to set 500 bytes key, it must succeed.
case 7:
if (SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled) {
if (SpecialPowers.Services.lsm.nextGenLocalStorageEnabled) {
slaveOrigin = "http://test1.example.com";
} else {
slaveOrigin = "https://test2.example.com";
@ -100,7 +100,7 @@ function doNextTest(aWindow) {
break;
case 8:
if (SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled) {
if (SpecialPowers.Services.lsm.nextGenLocalStorageEnabled) {
SimpleTest.executeSoon(() => doNextTest(aWindow));
} else {
// Do a clean up...
@ -116,7 +116,7 @@ function doNextTest(aWindow) {
break;
case 10:
if (SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled) {
if (SpecialPowers.Services.lsm.nextGenLocalStorageEnabled) {
SimpleTest.executeSoon(() => doNextTest(aWindow));
} else {
// Do a clean up...

Просмотреть файл

@ -96,7 +96,7 @@ function doStep()
SimpleTest.waitForExplicitFinish();
function startTest() {
if (SpecialPowers.Services.domStorageManager.nextGenLocalStorageEnabled) {
if (SpecialPowers.Services.lsm.nextGenLocalStorageEnabled) {
ok(true, "Test ignored when the next gen local storage is enabled.");
SimpleTest.finish();
return;

Просмотреть файл

@ -6,10 +6,8 @@
Classes = [
{
'js_name': 'perms',
'cid': '{4f6b5e00-0c36-11d5-a535-0010a401eb10}',
'contract_ids': ['@mozilla.org/permissionmanager;1'],
'interfaces': ['nsIPermissionManager'],
'singleton': True,
'type': 'nsIPermissionManager',
'constructor': 'mozilla::PermissionManager::GetXPCOMSingleton',

Просмотреть файл

@ -6,10 +6,8 @@
Classes = [
{
'js_name': 'strings',
'cid': '{d85a17c1-aa7c-11d2-9b8c-00805f8a16d9}',
'contract_ids': ['@mozilla.org/intl/stringbundle;1'],
'interfaces': ['nsIStringBundleService'],
'type': 'nsStringBundleService',
'headers': ['/intl/strres/nsStringBundleService.h'],
'init_method': 'Init',

Просмотреть файл

@ -6,10 +6,8 @@
Classes = [
{
'js_name': 'locale',
'cid': '{92735ff4-6384-4ad6-8508-757010e149ee}',
'contract_ids': ['@mozilla.org/intl/localeservice;1'],
'interfaces': ['mozILocaleService'],
'singleton': True,
'type': 'mozilla::intl::LocaleService',
'headers': ['mozilla/intl/LocaleService.h'],

Просмотреть файл

@ -24,10 +24,8 @@ Classes = [
'headers': ['/intl/uconv/nsScriptableUConv.h'],
},
{
'js_name': 'textToSubURI',
'cid': '{8b042e22-6f87-11d3-b3c8-00805f8a6670}',
'contract_ids': ['@mozilla.org/intl/texttosuburi;1'],
'interfaces': ['nsITextToSubURI'],
'type': 'nsTextToSubURI',
'headers': ['/intl/uconv/nsTextToSubURI.h'],
},

Просмотреть файл

@ -120,9 +120,6 @@ interface nsIXPCComponents_Utils : nsISupports
readonly attribute nsIXPCComponents_utils_Sandbox Sandbox;
[implicit_jscontext]
jsval createServicesCache();
/*
* evalInSandbox is designed to be called from JavaScript only.
*

Просмотреть файл

@ -1,157 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#include "xpcprivate.h"
#include "StaticComponents.h"
#include "mozilla/ErrorResult.h"
#include "nsJSUtils.h"
using namespace mozilla;
using namespace JS;
namespace xpc {
static bool Services_NewEnumerate(JSContext* cx, HandleObject obj,
MutableHandleIdVector properties,
bool enumerableOnly);
static bool Services_Resolve(JSContext* cx, HandleObject obj, HandleId id,
bool* resolvedp);
static bool Services_MayResolve(const JSAtomState& names, jsid id,
JSObject* maybeObj);
static const JSClassOps sServices_ClassOps = {
nullptr, // addProperty
nullptr, // delProperty
nullptr, // enumerate
Services_NewEnumerate, // newEnumerate
Services_Resolve, // resolve
Services_MayResolve, // mayResolve
nullptr, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
nullptr, // trace
};
static const JSClass sServices_Class = {"JSServices", 0, &sServices_ClassOps};
JSObject* NewJSServices(JSContext* cx) {
return JS_NewObject(cx, &sServices_Class);
}
static bool Services_NewEnumerate(JSContext* cx, HandleObject obj,
MutableHandleIdVector properties,
bool enumerableOnly) {
auto services = xpcom::StaticComponents::GetJSServices();
if (!properties.reserve(services.Length())) {
JS_ReportOutOfMemory(cx);
return false;
}
RootedId id(cx);
RootedString name(cx);
for (const auto& service : services) {
name = JS_AtomizeString(cx, service.Name().get());
if (!name || !JS_StringToId(cx, name, &id)) {
return false;
}
properties.infallibleAppend(id);
}
return true;
}
static JSLinearString* GetNameIfLatin1(jsid id) {
if (JSID_IS_STRING(id)) {
JSLinearString* name = JSID_TO_LINEAR_STRING(id);
if (js::LinearStringHasLatin1Chars(name)) {
return name;
}
}
return nullptr;
}
static JSObject* GetService(JSContext* cx, const xpcom::JSServiceEntry& service,
ErrorResult& aRv) {
nsresult rv;
nsCOMPtr<nsISupports> inst = service.Module().GetService(&rv);
if (!inst) {
aRv.Throw(rv);
return nullptr;
}
auto ifaces = service.Interfaces();
if (ifaces.Length() == 0) {
// If we weren't given any interfaces, we're expecting either a WebIDL
// object or a wrapped JS object. In the former case, the object will handle
// its own wrapping, and there's nothing to do. In the latter case, we want
// to unwrap the underlying JS object.
if (nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS = do_QueryInterface(inst)) {
return wrappedJS->GetJSObject();
}
}
JS::RootedValue val(cx);
const nsIID* iid = ifaces.Length() ? ifaces[0] : nullptr;
xpcObjectHelper helper(inst);
if (!XPCConvert::NativeInterface2JSObject(cx, &val, helper, iid,
/* allowNativeWrapper */ true,
&rv)) {
aRv.Throw(rv);
return nullptr;
}
if (ifaces.Length() > 1) {
auto* wn = XPCWrappedNative::Get(&val.toObject());
for (const nsIID* iid : Span(ifaces).From(1)) {
// Ignore any supplemental interfaces that aren't implemented. Tests do
// weird things with some services, and JS can generally handle the
// interfaces being absent.
Unused << wn->FindTearOff(cx, *iid);
}
}
return &val.toObject();
}
static bool Services_Resolve(JSContext* cx, HandleObject obj, HandleId id,
bool* resolvedp) {
*resolvedp = false;
JSLinearString* name = GetNameIfLatin1(id);
if (!name) {
return true;
}
nsAutoJSLinearCString nameStr(name);
if (const auto* service = xpcom::JSServiceEntry::Lookup(nameStr)) {
*resolvedp = true;
ErrorResult rv;
JS::RootedValue val(cx);
val.setObjectOrNull(GetService(cx, *service, rv));
if (rv.MaybeSetPendingException(cx)) {
return false;
}
return JS_DefinePropertyById(cx, obj, id, val, JSPROP_ENUMERATE);
}
return true;
}
static bool Services_MayResolve(const JSAtomState& names, jsid id,
JSObject* maybeObj) {
if (JSLinearString* name = GetNameIfLatin1(id)) {
nsAutoJSLinearCString nameStr(name);
return xpcom::JSServiceEntry::Lookup(nameStr);
}
return false;
}
} // namespace xpc

Просмотреть файл

@ -1,18 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef JSServices_h
#define JSServices_h
#include "jstypes.h"
namespace xpc {
JSObject* NewJSServices(JSContext* cx);
}
#endif // ifndef JSServices_h

Просмотреть файл

@ -8,7 +8,6 @@
#include "xpcprivate.h"
#include "xpc_make_class.h"
#include "JSServices.h"
#include "XPCJSWeakReference.h"
#include "WrapperFactory.h"
#include "nsJSUtils.h"
@ -1319,16 +1318,6 @@ nsXPCComponents_Utils::GetSandbox(nsIXPCComponents_utils_Sandbox** aSandbox) {
return NS_OK;
}
NS_IMETHODIMP
nsXPCComponents_Utils::CreateServicesCache(JSContext* aCx,
MutableHandleValue aServices) {
if (JSObject* services = NewJSServices(aCx)) {
aServices.setObject(*services);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsXPCComponents_Utils::ReportError(HandleValue error, HandleValue stack,
JSContext* cx) {

Просмотреть файл

@ -5,7 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "xpcprivate.h"
#include "xpc_make_class.h"
#include "nsContentUtils.h"
#include "BackstagePass.h"

Просмотреть файл

@ -6,10 +6,8 @@
Classes = [
{
'js_name': 'scriptloader',
'cid': '{929814d6-1dd2-11b2-8e08-82fa0a339b00}',
'contract_ids': ['@mozilla.org/moz/jssubscript-loader;1'],
'interfaces': ['mozIJSSubScriptLoader'],
'type': 'mozJSSubScriptLoader',
'headers': ['/js/xpconnect/loader/mozJSSubScriptLoader.h'],
},

Просмотреть файл

@ -13,7 +13,6 @@ EXPORTS += [
UNIFIED_SOURCES += [
'ExportHelpers.cpp',
'JSServices.cpp',
'nsXPConnect.cpp',
'Sandbox.cpp',
'XPCCallContext.cpp',
@ -54,7 +53,6 @@ include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul'
LOCAL_INCLUDES += [
'!/xpcom/components',
'../loader',
'../wrappers',
'/caps',
@ -65,7 +63,6 @@ LOCAL_INCLUDES += [
'/layout/base',
'/layout/style',
'/netwerk/base',
'/xpcom/components',
]
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):

Просмотреть файл

@ -87,7 +87,6 @@ Classes = [
'headers': ['mozilla/dom/BlobURL.h'],
},
{
'js_name': 'cpmm',
'cid': '{fe0ff7c3-8e97-448b-9a8a-86afdb9fbbb6}',
'contract_ids': ['@mozilla.org/childprocessmessagemanager;1'],
'legacy_constructor': 'CreateChildMessageManager',
@ -149,20 +148,16 @@ Classes = [
'headers': ['nsStructuredCloneContainer.h'],
},
{
'js_name': 'DOMRequest',
'cid': '{3160e271-138d-4cc7-9d63-6429f16957c7}',
'contract_ids': ['@mozilla.org/dom/dom-request-service;1'],
'interfaces': ['nsIDOMRequestService'],
'singleton': True,
'type': 'mozilla::dom::DOMRequestService',
'headers': ['mozilla/dom/DOMRequest.h'],
'constructor': 'mozilla::dom::DOMRequestService::FactoryCreate',
},
{
'js_name': 'domStorageManager',
'cid': '{656db07c-aa80-49e4-bce8-e431baae697d}',
'contract_ids': ['@mozilla.org/dom/localStorage-manager;1'],
'interfaces': ['nsIDOMStorageManager', 'nsILocalStorageManager'],
'legacy_constructor': 'LocalStorageManagerConstructor',
},
{
@ -171,10 +166,8 @@ Classes = [
'legacy_constructor': 'SessionStorageManagerConstructor',
},
{
'js_name': 'qms',
'cid': '{5a75c25a-5e7e-4d90-8f7c-07eb15cc0aa8}',
'contract_ids': ['@mozilla.org/dom/quota-manager-service;1'],
'interfaces': ['nsIQuotaManagerService'],
'singleton': True,
'type': 'mozilla::dom::quota::QuotaManagerService',
'headers': ['mozilla/dom/quota/QuotaManagerService.h'],
@ -196,10 +189,8 @@ Classes = [
'constructor': 'mozilla::dom::WorkerDebuggerManager::GetInstance',
},
{
'js_name': 'els',
'cid': '{baa34652-f1f1-4185-b224-244ee82a413a}',
'contract_ids': ['@mozilla.org/eventlistenerservice;1'],
'interfaces': ['nsIEventListenerService'],
'type': 'nsIEventListenerService',
},
{
@ -209,10 +200,8 @@ Classes = [
'headers': ['/caps/ExpandedPrincipal.h'],
},
{
'js_name': 'focus',
'cid': '{cf7fd51f-aba2-44c1-9ff0-11f7508efcd4}',
'contract_ids': ['@mozilla.org/focus-manager;1'],
'interfaces': ['nsIFocusManager'],
'type': 'nsIFocusManager',
},
{
@ -232,7 +221,6 @@ Classes = [
'constructor': 'mozilla::dom::Geolocation::NonWindowSingleton',
},
{
'js_name': 'mm',
'cid': '{130b016f-fad7-4526-bc7f-827dabf79265}',
'contract_ids': ['@mozilla.org/globalmessagemanager;1'],
'legacy_constructor': 'CreateGlobalMessageManager',
@ -328,7 +316,6 @@ Classes = [
'init_method': 'Init',
},
{
'js_name': 'ppmm',
'cid': '{2a058404-fb85-44ec-8cfd-e8cbdc988dc1}',
'contract_ids': ['@mozilla.org/parentprocessmessagemanager;1'],
'legacy_constructor': 'CreateParentMessageManager',
@ -386,10 +373,8 @@ Classes = [
'headers': ['/dom/bindings/nsScriptError.h'],
},
{
'js_name': 'scriptSecurityManager',
'cid': '{7ee2a4c0-4b93-17d3-ba18-0060b0f199a2}',
'contract_ids': ['@mozilla.org/scriptsecuritymanager;1'],
'interfaces': ['nsIScriptSecurityManager'],
'legacy_constructor': 'Construct_nsIScriptSecurityManager',
},
{

Просмотреть файл

@ -12,13 +12,11 @@ Classes = [
'constructor': 'PromptCollection',
},
{
'js_name': 'prompt',
'cid': '{076ac188-23c1-4390-aa08-7ef1f78ca5d9}',
'contract_ids': [
'@mozilla.org/prompter;1',
'@mozilla.org/embedcomp/prompt-service;1',
],
'interfaces': ['nsIPromptService'],
'jsm': 'resource://gre/modules/GeckoViewPrompt.jsm',
'constructor': 'PromptFactory',
},

Просмотреть файл

@ -12,10 +12,8 @@ UnloadFunc = 'mozilla::UnloadPrefsModule'
Classes = [
{
'js_name': 'prefs',
'cid': '{91ca2441-050f-4f7c-9df8-75b40ea40156}',
'contract_ids': ['@mozilla.org/preferences-service;1'],
'interfaces': ['nsIPrefService', 'nsIPrefBranch'],
'singleton': True,
'type': 'mozilla::Preferences',
'headers': ['mozilla/Preferences.h'],

Просмотреть файл

@ -19,21 +19,17 @@ Classes = [
'headers': ['/netwerk/base/ArrayBufferInputStream.h'],
},
{
'js_name': 'loadContextInfo',
'cid': '{62d4b190-3642-4450-b019-d1c1fba56025}',
'contract_ids': ['@mozilla.org/load-context-info-factory;1'],
'interfaces': ['nsILoadContextInfoFactory'],
'type': 'mozilla::net::LoadContextInfoFactory',
'headers': ['mozilla/LoadContextInfo.h'],
},
{
'js_name': 'cache2',
'cid': '{ea70b098-5014-4e21-aee1-75e6b2c4b8e0}',
'contract_ids': [
'@mozilla.org/netwerk/cache-storage-service;1',
'@mozilla.org/network/cache-storage-service;1',
],
'interfaces': ['nsICacheStorageService'],
'singleton': True,
'type': 'mozilla::net::CacheStorageService',
'headers': ['CacheStorageService.h'],
@ -132,10 +128,8 @@ Classes = [
'headers': ['/netwerk/base/nsDownloader.h'],
},
{
'js_name': 'eTLD',
'cid': '{cb9abbae-66b6-4609-8594-5c4ff300888e}',
'contract_ids': ['@mozilla.org/network/effective-tld-service;1'],
'interfaces': ['nsIEffectiveTLDService'],
'singleton': True,
'type': 'nsEffectiveTLDService',
'headers': ['/netwerk/dns/nsEffectiveTLDService.h'],
@ -199,13 +193,11 @@ Classes = [
'headers': ['nsInputStreamPump.h'],
},
{
'js_name': 'io',
'cid': '{9ac9e770-18bc-11d3-9337-00104ba0fd40}',
'contract_ids': [
'@mozilla.org/network/io-service;1',
'@mozilla.org/network/util;1',
],
'interfaces': ['nsIIOService', 'nsISpeculativeConnect', 'nsINetUtil'],
'singleton': True,
'type': 'mozilla::net::nsIOService',
'headers': ['/netwerk/base/nsIOService.h'],
@ -584,13 +576,11 @@ Classes = [
'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS,
},
{
'js_name': 'cookies',
'cid': '{c375fa80-150f-11d6-a618-0010a401eb10}',
'contract_ids': [
'@mozilla.org/cookieService;1',
'@mozilla.org/cookiemanager;1',
],
'interfaces': ['nsICookieManager'],
'singleton': True,
'type': 'nsICookieService',
'constructor': 'mozilla::net::CookieService::GetXPCOMSingleton',

Просмотреть файл

@ -18,7 +18,7 @@ CookieXPCShellUtils.init(this);
XPCOMUtils.defineLazyServiceGetter(
Services,
"cookiesvc",
"cookies",
"@mozilla.org/cookieService;1",
"nsICookieService"
);
@ -162,7 +162,7 @@ function do_load_profile(generator) {
// Set a single session cookie using http and test the cookie count
// against 'expected'
function do_set_single_http_cookie(uri, channel, expected) {
Services.cookiesvc.setCookieStringFromHttp(uri, "foo=bar", channel);
Services.cookies.setCookieStringFromHttp(uri, "foo=bar", channel);
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri.host), expected);
}
@ -198,7 +198,7 @@ async function do_set_cookies(uri, channel, session, expected) {
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri.host), expected[0]);
// via http request
Services.cookiesvc.setCookieStringFromHttp(uri, "hot=dog" + suffix, channel);
Services.cookies.setCookieStringFromHttp(uri, "hot=dog" + suffix, channel);
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri.host), expected[1]);
}

Просмотреть файл

@ -213,7 +213,7 @@ async function run_test_2() {
// Load the profile and populate it.
do_load_profile();
Services.cookiesvc.runInTransaction(_ => {
Services.cookies.runInTransaction(_ => {
let uri = NetUtil.newURI("http://foo.com/");
const channel = NetUtil.newChannel({
uri,
@ -223,7 +223,7 @@ async function run_test_2() {
for (let i = 0; i < 3000; ++i) {
let uri = NetUtil.newURI("http://" + i + ".com/");
Services.cookiesvc.setCookieStringFromHttp(
Services.cookies.setCookieStringFromHttp(
uri,
"oh=hai; max-age=1000",
channel
@ -278,7 +278,7 @@ async function run_test_3() {
// Load the profile and populate it.
do_load_profile();
Services.cookiesvc.runInTransaction(_ => {
Services.cookies.runInTransaction(_ => {
let uri = NetUtil.newURI("http://hither.com/");
let channel = NetUtil.newChannel({
uri,
@ -286,7 +286,7 @@ async function run_test_3() {
contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
});
for (let i = 0; i < 10; ++i) {
Services.cookiesvc.setCookieStringFromHttp(
Services.cookies.setCookieStringFromHttp(
uri,
"oh" + i + "=hai; max-age=1000",
channel
@ -299,7 +299,7 @@ async function run_test_3() {
contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
});
for (let i = 10; i < 3000; ++i) {
Services.cookiesvc.setCookieStringFromHttp(
Services.cookies.setCookieStringFromHttp(
uri,
"oh" + i + "=hai; max-age=1000",
channel
@ -368,7 +368,7 @@ async function run_test_3() {
async function run_test_4() {
// Load the profile and populate it.
do_load_profile();
Services.cookiesvc.runInTransaction(_ => {
Services.cookies.runInTransaction(_ => {
let uri = NetUtil.newURI("http://foo.com/");
let channel = NetUtil.newChannel({
uri,
@ -377,7 +377,7 @@ async function run_test_4() {
});
for (let i = 0; i < 3000; ++i) {
let uri = NetUtil.newURI("http://" + i + ".com/");
Services.cookiesvc.setCookieStringFromHttp(
Services.cookies.setCookieStringFromHttp(
uri,
"oh=hai; max-age=1000",
channel
@ -437,21 +437,21 @@ async function run_test_4() {
async function run_test_5() {
// Load the profile and populate it.
do_load_profile();
Services.cookiesvc.runInTransaction(_ => {
Services.cookies.runInTransaction(_ => {
let uri = NetUtil.newURI("http://bar.com/");
const channel = NetUtil.newChannel({
uri,
loadUsingSystemPrincipal: true,
contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
});
Services.cookiesvc.setCookieStringFromHttp(
Services.cookies.setCookieStringFromHttp(
uri,
"oh=hai; path=/; max-age=1000",
channel
);
for (let i = 0; i < 3000; ++i) {
let uri = NetUtil.newURI("http://" + i + ".com/");
Services.cookiesvc.setCookieStringFromHttp(
Services.cookies.setCookieStringFromHttp(
uri,
"oh=hai; max-age=1000",
channel

Просмотреть файл

@ -45,7 +45,7 @@ add_task(async () => {
let uri2 = NetUtil.newURI("http://bar.com/bar.html");
// Set a cookie for host 1.
Services.cookiesvc.setCookieStringFromHttp(
Services.cookies.setCookieStringFromHttp(
uri1,
"oh=hai; max-age=1000",
make_channel(uri1.spec)
@ -61,11 +61,7 @@ add_task(async () => {
chan2.QueryInterface(Ci.nsIPrivateBrowsingChannel);
chan2.setPrivate(true);
Services.cookiesvc.setCookieStringFromHttp(
uri2,
"oh=hai; max-age=1000",
chan2
);
Services.cookies.setCookieStringFromHttp(uri2, "oh=hai; max-age=1000", chan2);
Assert.equal(await getCookieStringFromPrivateDocument(uri1.spec), "");
Assert.equal(await getCookieStringFromPrivateDocument(uri2.spec), "oh=hai");
@ -74,11 +70,7 @@ add_task(async () => {
Assert.equal(await getCookieStringFromPrivateDocument(uri1.spec), "");
Assert.equal(await getCookieStringFromPrivateDocument(uri2.spec), "");
Services.cookiesvc.setCookieStringFromHttp(
uri2,
"oh=hai; max-age=1000",
chan2
);
Services.cookies.setCookieStringFromHttp(uri2, "oh=hai; max-age=1000", chan2);
Assert.equal(await getCookieStringFromPrivateDocument(uri2.spec), "oh=hai");
// Leave private browsing mode and check counts.
@ -97,11 +89,7 @@ add_task(async () => {
// Enter private browsing mode, set a cookie for host 2, and check the counts.
Assert.equal(await getCookieStringFromPrivateDocument(uri1.spec), "");
Assert.equal(await getCookieStringFromPrivateDocument(uri2.spec), "");
Services.cookiesvc.setCookieStringFromHttp(
uri2,
"oh=hai; max-age=1000",
chan2
);
Services.cookies.setCookieStringFromHttp(uri2, "oh=hai; max-age=1000", chan2);
Assert.equal(await getCookieStringFromPrivateDocument(uri2.spec), "oh=hai");
// Fake a profile change.

Просмотреть файл

@ -54,11 +54,11 @@ add_task(async () => {
""
);
Assert.equal(Services.cookiesvc.getCookieStringFromHttp(uri, channel), "");
Assert.equal(Services.cookies.getCookieStringFromHttp(uri, channel), "");
await CookieXPCShellUtils.setCookieToDocument(uri.spec, "oh2=hai");
Services.cookiesvc.setCookieStringFromHttp(uri, "oh3=hai", channel);
Services.cookies.setCookieStringFromHttp(uri, "oh3=hai", channel);
Assert.equal(
await CookieXPCShellUtils.getCookieStringFromDocument("http://foo.com/"),
""

Просмотреть файл

@ -36,7 +36,7 @@ add_task(async () => {
});
for (let i = 0; i < CMAX; ++i) {
let uri = NetUtil.newURI("http://" + i + ".com/");
Services.cookiesvc.setCookieStringFromHttp(
Services.cookies.setCookieStringFromHttp(
uri,
"oh=hai; max-age=1000",
channel

Просмотреть файл

@ -182,7 +182,7 @@ function* run_test_1(generator) {
});
// Load the profile and populate it.
Services.cookiesvc.setCookieStringFromHttp(
Services.cookies.setCookieStringFromHttp(
uri,
"oh=hai; max-age=1000",
channel
@ -217,7 +217,7 @@ function* run_test_2(generator) {
loadUsingSystemPrincipal: true,
contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
});
Services.cookiesvc.setCookieStringFromHttp(
Services.cookies.setCookieStringFromHttp(
uri,
"oh=hai; max-age=1000",
channel

Просмотреть файл

@ -6,10 +6,8 @@
Classes = [
{
'js_name': 'storage',
'cid': '{bbbb1d61-438f-4436-92ed-8308e5830fb0}',
'contract_ids': ['@mozilla.org/storage/service;1'],
'interfaces': ['mozIStorageService'],
'singleton': True,
'type': 'mozilla::storage::Service',
'headers': ['/storage/mozStorageService.h'],

Просмотреть файл

@ -98,10 +98,8 @@ Classes = [
},
{
'name': 'AppStartup',
'js_name': 'startup',
'cid': '{7dd4d320-c84b-4624-8d45-7bb9b2356977}',
'contract_ids': ['@mozilla.org/toolkit/app-startup;1'],
'interfaces': ['nsIAppStartup'],
'type': 'nsAppStartup',
'headers': ['/toolkit/components/startup/nsAppStartup.h'],
'init_method': 'Init',

Просмотреть файл

@ -6,10 +6,8 @@
Classes = [
{
'js_name': 'clearData',
'cid': '{0c06583d-7dd8-4293-b1a5-912205f779aa}',
'contract_ids': ['@mozilla.org/clear-data-service;1'],
'interfaces': ['nsIClearDataService'],
'jsm': 'resource://gre/modules/ClearDataService.jsm',
'constructor': 'ClearDataService',
},

Просмотреть файл

@ -18,7 +18,7 @@ const { TelemetryController } = ChromeUtils.import(
ChromeUtils.import("resource://gre/modules/Timer.jsm", this);
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", this);
var EXPORTED_SYMBOLS = ["CrashManager", "getCrashManager"];
var EXPORTED_SYMBOLS = ["CrashManager"];
/**
* How long to wait after application startup before crash event files are
@ -1545,7 +1545,3 @@ XPCOMUtils.defineLazyGetter(CrashManager, "Singleton", function() {
return gCrashManager;
});
function getCrashManager() {
return CrashManager.Singleton;
}

Просмотреть файл

@ -12,11 +12,4 @@ Classes = [
'constructor': 'CrashService',
'categories': {'profile-after-change': 'CrashService'},
},
{
'js_name': 'crashmanager',
'cid': '{c887b6a9-a5eb-4566-a440-bebaea3e54fd}',
'contract_ids': ['@mozilla.org/crashmanager;1'],
'jsm': 'resource://gre/modules/CrashManager.jsm',
'constructor': 'getCrashManager',
},
]

Просмотреть файл

@ -2,8 +2,6 @@
* 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 EXPORTED_SYMBOLS = ["EnterprisePoliciesManager"];
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
@ -82,11 +80,15 @@ function EnterprisePoliciesManager() {
}
EnterprisePoliciesManager.prototype = {
classID: Components.ID("{ea4e1414-779b-458b-9d1f-d18e8efbc145}"),
QueryInterface: ChromeUtils.generateQI([
Ci.nsIObserver,
Ci.nsISupportsWeakReference,
Ci.nsIEnterprisePolicies,
]),
_xpcom_factory: XPCOMUtils.generateSingletonFactory(
EnterprisePoliciesManager
),
_initialize() {
let provider = this._chooseProvider();
@ -629,3 +631,6 @@ class macOSPoliciesProvider {
return this._failed;
}
}
var components = [EnterprisePoliciesManager];
this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);

Просмотреть файл

@ -1,22 +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 EXPORTED_SYMBOLS = ["EnterprisePolicies"];
function EnterprisePolicies() {
// eslint-disable-next-line mozilla/use-services
const appinfo = Cc["@mozilla.org/xre/app-info;1"].getService(
Ci.nsIXULRuntime
);
if (appinfo.processType == appinfo.PROCESS_TYPE_DEFAULT) {
const { EnterprisePoliciesManager } = ChromeUtils.import(
"resource://gre/modules/EnterprisePoliciesParent.jsm"
);
return new EnterprisePoliciesManager();
}
const { EnterprisePoliciesManagerContent } = ChromeUtils.import(
"resource://gre/modules/EnterprisePoliciesContent.jsm"
);
return new EnterprisePoliciesManagerContent();
}

Просмотреть файл

@ -0,0 +1,5 @@
component {ea4e1414-779b-458b-9d1f-d18e8efbc145} EnterprisePolicies.js process=main
contract @mozilla.org/enterprisepolicies;1 {ea4e1414-779b-458b-9d1f-d18e8efbc145} process=main
component {dc6358f8-d167-4566-bf5b-4350b5e6a7a2} EnterprisePoliciesContent.js process=content
contract @mozilla.org/enterprisepolicies;1 {dc6358f8-d167-4566-bf5b-4350b5e6a7a2} process=content

Просмотреть файл

@ -2,26 +2,35 @@
* 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 EXPORTED_SYMBOLS = ["EnterprisePoliciesManagerContent"];
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
class EnterprisePoliciesManagerContent {
function EnterprisePoliciesManagerContent() {}
EnterprisePoliciesManagerContent.prototype = {
classID: Components.ID("{dc6358f8-d167-4566-bf5b-4350b5e6a7a2}"),
QueryInterface: ChromeUtils.generateQI([Ci.nsIEnterprisePolicies]),
_xpcom_factory: XPCOMUtils.generateSingletonFactory(
EnterprisePoliciesManagerContent
),
get status() {
return (
Services.cpmm.sharedData.get("EnterprisePolicies:Status") ||
Ci.nsIEnterprisePolicies.INACTIVE
);
}
},
isAllowed(feature) {
let disallowedFeatures = Services.cpmm.sharedData.get(
"EnterprisePolicies:DisallowedFeatures"
);
return !(disallowedFeatures && disallowedFeatures.has(feature));
}
}
},
};
EnterprisePoliciesManagerContent.prototype.QueryInterface = ChromeUtils.generateQI(
[Ci.nsIEnterprisePolicies]
);
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([
EnterprisePoliciesManagerContent,
]);

Просмотреть файл

@ -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/.
Classes = [
{
'js_name': 'policies',
'cid': '{49e8d8ef-a713-492a-a3d2-5c9dad4ce2e5}',
'contract_ids': ['@mozilla.org/enterprisepolicies;1'],
'interfaces': ['nsIEnterprisePolicies'],
'jsm': 'resource://gre/modules/EnterprisePolicies.jsm',
'constructor': 'EnterprisePolicies',
},
]

Просмотреть файл

@ -18,14 +18,10 @@ TEST_DIRS += [
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] != "android":
EXTRA_JS_MODULES += [
'EnterprisePolicies.jsm',
'EnterprisePoliciesContent.jsm',
'EnterprisePoliciesParent.jsm',
]
XPCOM_MANIFESTS += [
'components.conf',
EXTRA_COMPONENTS += [
'EnterprisePolicies.js',
'EnterprisePolicies.manifest',
'EnterprisePoliciesContent.js',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':

Просмотреть файл

@ -382,7 +382,7 @@ var ExtensionAddonObserver = {
// If LSNG is not enabled, we need to clear localStorage explicitly using
// the old API.
if (!Services.domStorageManager.nextGenLocalStorageEnabled) {
if (!Services.lsm.nextGenLocalStorageEnabled) {
// Clear localStorage created by the extension
let storage = Services.domStorageManager.getStorage(
null,

Просмотреть файл

@ -13,10 +13,8 @@ Classes = [
},
{
'js_name': 'intl',
'cid': '{35ec195a-e8d0-4300-83af-c8a2cc84b4a3}',
'contract_ids': ['@mozilla.org/mozintl;1'],
'interfaces': ['mozIMozIntl'],
'jsm': 'resource://gre/modules/mozIntl.jsm',
'constructor': 'MozIntl',
},

Просмотреть файл

@ -6,10 +6,8 @@
Classes = [
{
'js_name': 'logins',
'cid': '{cb9e0de8-3598-4ed7-857b-827f011ad5d8}',
'contract_ids': ['@mozilla.org/login-manager;1'],
'interfaces': ['nsILoginManager'],
'jsm': 'resource://gre/modules/LoginManager.jsm',
'constructor': 'LoginManager',
},

Просмотреть файл

@ -22,10 +22,8 @@ if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] != 'android':
'constructor': 'Prompter',
},
{
'js_name': 'prompt',
'cid': '{7ad1b327-6dfa-46ec-9234-f2a620ea7e00}',
'contract_ids': ['@mozilla.org/embedcomp/prompt-service;1'],
'interfaces': ['nsIPromptService'],
'jsm': 'resource://gre/modules/Prompter.jsm',
'constructor': 'EmbedPrompter',
},

Просмотреть файл

@ -8,10 +8,8 @@ HAVE_SIDEBAR = buildconfig.substs['MOZ_BUILD_APP'] in ('browser', 'mobile/androi
Classes = [
{
'js_name': 'search',
'cid': '{7319788a-fe93-4db3-9f39-818cf08f4256}',
'contract_ids': ['@mozilla.org/browser/search-service;1'],
'interfaces': ['nsISearchService'],
'jsm': 'resource://gre/modules/SearchService.jsm',
'constructor': 'SearchService',
'processes': ProcessSelector.MAIN_PROCESS_ONLY,

Просмотреть файл

@ -10,10 +10,8 @@ UnloadFunc = 'mozilla::Telemetry::ShutdownTelemetry'
Classes = [
{
'js_name': 'telemetry',
'cid': '{aea477f2-b3a2-469c-aa29-0a82d132b829}',
'contract_ids': ['@mozilla.org/base/telemetry;1'],
'interfaces': ['nsITelemetry'],
'singleton': True,
'type': 'nsITelemetry',
'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_AND_SOCKET_PROCESS,

Просмотреть файл

@ -37,7 +37,7 @@ add_task(async function() {
do_get_profile(true);
await TelemetryController.testSetup();
Services.io.socketProcessTelemetryPing();
Services.netUtils.socketProcessTelemetryPing();
// Once scalars are set by the socket process, they don't immediately get
// sent to the parent process. Wait for the Telemetry IPC Timer to trigger

Просмотреть файл

@ -174,7 +174,7 @@ var SysInfo = {
return this.overrides[name];
}
return this._genuine.QueryInterface(Ci.nsIPropertyBag).getProperty(name);
return this._genuine.getProperty(name);
},
getPropertyAsUint32(name) {
@ -182,7 +182,7 @@ var SysInfo = {
},
get(name) {
return this._genuine.QueryInterface(Ci.nsIPropertyBag2).get(name);
return this._genuine.get(name);
},
get diskInfo() {

Просмотреть файл

@ -23,6 +23,13 @@ ChromeUtils.defineModuleGetter(
"resource://gre/modules/HealthPing.jsm"
);
XPCOMUtils.defineLazyServiceGetter(
Services,
"cookies",
"@mozilla.org/cookieService;1",
"nsICookieService"
);
const MS_IN_A_MINUTE = 60 * 1000;
function countPingTypes(pings) {
@ -966,7 +973,6 @@ add_task(async function testCookies() {
loadUsingSystemPrincipal: true,
contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
});
Services.cookies.QueryInterface(Ci.nsICookieService);
Services.cookies.setCookieStringFromHttp(uri, "cookie-time=yes", channel);
const id = await TelemetryController.submitExternalPing(TEST_TYPE, {});

Просмотреть файл

@ -6,10 +6,8 @@
Classes = [
{
'js_name': 'urlFormatter',
'cid': '{e6156350-2be8-11db-a98b-0800200c9a66}',
'contract_ids': ['@mozilla.org/toolkit/URLFormatterService;1'],
'interfaces': ['nsIURLFormatter'],
'jsm': 'resource://gre/modules/URLFormatter.jsm',
'constructor': 'nsURLFormatterService',
},

Просмотреть файл

@ -14,21 +14,12 @@ if defined('MOZ_NEW_XULSTORE'):
'singleton': True,
'constructor': 'mozilla::XULStore::GetService',
},
{
'js_name': 'xulStore',
'cid': '{e8e12dba-b942-4c0d-aa21-2843cfc64529}',
'contract_ids': ['@mozilla.org/xul/js-xulstore;1'],
'jsm': 'resource://gre/modules/XULStore.jsm',
'constructor': 'getXULStore',
},
]
else:
Classes = [
{
'js_name': 'xulStore',
'cid': '{6f46b6f4-c8b1-4bd4-a4fa-9ebbed0753ea}',
'contract_ids': ['@mozilla.org/xul/xulstore;1'],
'interfaces': ['nsIXULStore'],
'jsm': 'resource://gre/modules/XULStore.jsm',
'constructor': 'XULStore',
},

Просмотреть файл

@ -10,7 +10,7 @@
// protocol. It also implements the persist() method. JS consumers should use
// this module rather than accessing nsIXULStore directly.
const EXPORTED_SYMBOLS = ["XULStore", "getXULStore"];
const EXPORTED_SYMBOLS = ["XULStore"];
// Services.xulStore loads this module and returns its `XULStore` symbol
// when this implementation of XULStore is enabled, so using it here
@ -99,9 +99,3 @@ class XULStoreEnumerator {
}
}
}
// Only here for the sake of component registration, which requires a
// callable function.
function getXULStore() {
return XULStore;
}

Просмотреть файл

@ -2,6 +2,171 @@
* 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/. */
/* eslint mozilla/use-services:off */
var EXPORTED_SYMBOLS = ["Services"];
var Services = Cu.createServicesCache();
const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
var Services = {};
/**
* WARNING: If you add a getter that isn't in the initTable, please update the
* eslint rule in /tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-services.js
*/
XPCOMUtils.defineLazyGetter(Services, "prefs", function() {
return Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefService)
.QueryInterface(Ci.nsIPrefBranch);
});
XPCOMUtils.defineLazyGetter(Services, "appinfo", function() {
let appinfo = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime);
try {
appinfo.QueryInterface(Ci.nsIXULAppInfo);
} catch (ex) {
// Not all applications implement nsIXULAppInfo (e.g. xpcshell doesn't).
if (
!(ex instanceof Components.Exception) ||
ex.result != Cr.NS_NOINTERFACE
) {
throw ex;
}
}
return appinfo;
});
XPCOMUtils.defineLazyGetter(Services, "dirsvc", function() {
return Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIDirectoryService)
.QueryInterface(Ci.nsIProperties);
});
XPCOMUtils.defineLazyGetter(Services, "sysinfo", function() {
return Cc["@mozilla.org/system-info;1"]
.getService(Ci.nsIPropertyBag2)
.QueryInterface(Ci.nsISystemInfo);
});
if (AppConstants.MOZ_CRASHREPORTER) {
XPCOMUtils.defineLazyGetter(Services, "crashmanager", () => {
let ns = {};
ChromeUtils.import("resource://gre/modules/CrashManager.jsm", ns);
return ns.CrashManager.Singleton;
});
}
XPCOMUtils.defineLazyGetter(Services, "io", () => {
return Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService)
.QueryInterface(Ci.nsISpeculativeConnect);
});
var initTable = {
appShell: ["@mozilla.org/appshell/appShellService;1", "nsIAppShellService"],
cache2: [
"@mozilla.org/netwerk/cache-storage-service;1",
"nsICacheStorageService",
],
catMan: ["@mozilla.org/categorymanager;1", "nsICategoryManager"],
clearData: ["@mozilla.org/clear-data-service;1", "nsIClearDataService"],
cpmm: ["@mozilla.org/childprocessmessagemanager;1", "nsIMessageSender"],
console: ["@mozilla.org/consoleservice;1", "nsIConsoleService"],
cookies: ["@mozilla.org/cookiemanager;1", "nsICookieManager"],
droppedLinkHandler: [
"@mozilla.org/content/dropped-link-handler;1",
"nsIDroppedLinkHandler",
],
els: ["@mozilla.org/eventlistenerservice;1", "nsIEventListenerService"],
eTLD: [
"@mozilla.org/network/effective-tld-service;1",
"nsIEffectiveTLDService",
],
intl: ["@mozilla.org/mozintl;1", "mozIMozIntl"],
locale: ["@mozilla.org/intl/localeservice;1", "mozILocaleService"],
logins: ["@mozilla.org/login-manager;1", "nsILoginManager"],
mm: ["@mozilla.org/globalmessagemanager;1", "nsISupports"],
obs: ["@mozilla.org/observer-service;1", "nsIObserverService"],
perms: ["@mozilla.org/permissionmanager;1", "nsIPermissionManager"],
ppmm: ["@mozilla.org/parentprocessmessagemanager;1", "nsISupports"],
prompt: ["@mozilla.org/embedcomp/prompt-service;1", "nsIPromptService"],
scriptloader: [
"@mozilla.org/moz/jssubscript-loader;1",
"mozIJSSubScriptLoader",
],
scriptSecurityManager: [
"@mozilla.org/scriptsecuritymanager;1",
"nsIScriptSecurityManager",
],
storage: ["@mozilla.org/storage/service;1", "mozIStorageService"],
domStorageManager: [
"@mozilla.org/dom/localStorage-manager;1",
"nsIDOMStorageManager",
],
lsm: ["@mozilla.org/dom/localStorage-manager;1", "nsILocalStorageManager"],
search: ["@mozilla.org/browser/search-service;1", "nsISearchService"],
strings: ["@mozilla.org/intl/stringbundle;1", "nsIStringBundleService"],
telemetry: ["@mozilla.org/base/telemetry;1", "nsITelemetry"],
textToSubURI: ["@mozilla.org/intl/texttosuburi;1", "nsITextToSubURI"],
tm: ["@mozilla.org/thread-manager;1", "nsIThreadManager"],
urlFormatter: [
"@mozilla.org/toolkit/URLFormatterService;1",
"nsIURLFormatter",
],
vc: ["@mozilla.org/xpcom/version-comparator;1", "nsIVersionComparator"],
wm: ["@mozilla.org/appshell/window-mediator;1", "nsIWindowMediator"],
ww: ["@mozilla.org/embedcomp/window-watcher;1", "nsIWindowWatcher"],
startup: ["@mozilla.org/toolkit/app-startup;1", "nsIAppStartup"],
clipboard: ["@mozilla.org/widget/clipboard;1", "nsIClipboard"],
DOMRequest: [
"@mozilla.org/dom/dom-request-service;1",
"nsIDOMRequestService",
],
focus: ["@mozilla.org/focus-manager;1", "nsIFocusManager"],
uriFixup: ["@mozilla.org/docshell/uri-fixup;1", "nsIURIFixup"],
blocklist: ["@mozilla.org/extensions/blocklist;1"],
netUtils: ["@mozilla.org/network/util;1", "nsINetUtil"],
loadContextInfo: [
"@mozilla.org/load-context-info-factory;1",
"nsILoadContextInfoFactory",
],
qms: ["@mozilla.org/dom/quota-manager-service;1", "nsIQuotaManagerService"],
};
if (AppConstants.platform == "android") {
initTable.androidBridge = [
"@mozilla.org/android/bridge;1",
"nsIAndroidBridge",
];
}
if (AppConstants.MOZ_GECKO_PROFILER) {
initTable.profiler = ["@mozilla.org/tools/profiler;1", "nsIProfiler"];
}
if ("@mozilla.org/enterprisepolicies;1" in Cc) {
initTable.policies = [
"@mozilla.org/enterprisepolicies;1",
"nsIEnterprisePolicies",
];
}
if (AppConstants.MOZ_NEW_XULSTORE) {
XPCOMUtils.defineLazyGetter(Services, "xulStore", () => {
const { XULStore } = ChromeUtils.import(
"resource://gre/modules/XULStore.jsm"
);
return XULStore;
});
} else {
initTable.xulStore = ["@mozilla.org/xul/xulstore;1", "nsIXULStore"];
}
XPCOMUtils.defineLazyServiceGetters(Services, initTable);
initTable = undefined;

Просмотреть файл

@ -6,7 +6,6 @@
Classes = [
{
'js_name': 'blocklist',
'cid': '{66354bc9-7ed1-4692-ae1d-8da97d6b205e}',
'contract_ids': ['@mozilla.org/extensions/blocklist;1'],
'jsm': 'resource://gre/modules/addonManager.js',

Просмотреть файл

@ -11,17 +11,14 @@ else:
Classes = [
{
'js_name': 'appinfo',
'cid': '{95d89e3e-a169-41a3-8e56-719978e15b12}',
'contract_ids': [
'@mozilla.org/xre/app-info;1',
'@mozilla.org/xre/runtime;1',
] + crash_reporter,
'interfaces': ['nsIXULRuntime', 'nsIXULAppInfo'],
'legacy_constructor': 'mozilla::AppInfoConstructor',
'headers': ['nsAppRunner.h'],
'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS,
'overridable': True,
},
{
'cid': '{471f4944-1dd2-11b2-87ac-90be0a51d609}',
@ -36,14 +33,11 @@ Classes = [
'headers': ['/dom/webbrowserpersist/nsWebBrowserPersist.h'],
},
{
'js_name': 'ww',
'cid': '{a21bfa01-f349-4394-a84c-8de5cf0737d0}',
'contract_ids': ['@mozilla.org/embedcomp/window-watcher;1'],
'interfaces': ['nsIWindowWatcher'],
'type': 'nsWindowWatcher',
'headers': ['nsWindowWatcher.h'],
'init_method': 'Init',
'overridable': True,
},
{
'cid': '{5573967d-f6cf-4c63-8e0e-9ac06e04d62b}',

Просмотреть файл

@ -0,0 +1,40 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// ------------------------------------------------------------------------------
// Requirements
// ------------------------------------------------------------------------------
var rule = require("../lib/rules/use-services");
var RuleTester = require("eslint").RuleTester;
const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
// ------------------------------------------------------------------------------
// Tests
// ------------------------------------------------------------------------------
function invalidCode(code, name) {
let message = `Use Services.${name} rather than getService().`;
return { code, errors: [{ message, type: "CallExpression" }] };
}
ruleTester.run("use-services", rule, {
valid: [
'Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator)',
'Components.classes["@mozilla.org/uuid-generator;1"].getService(Components.interfaces.nsIUUIDGenerator)',
"Services.wm.addListener()",
],
invalid: [
invalidCode(
'Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);',
"wm"
),
invalidCode(
'Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(Components.interfaces.nsIAppStartup);',
"startup"
),
],
});

Просмотреть файл

@ -6,10 +6,8 @@
Classes = [
{
'js_name': 'profiler',
'cid': '{25db9b8e-8123-4de1-b66d-8bbbedf2cdf4}',
'contract_ids': ['@mozilla.org/tools/profiler;1'],
'interfaces': ['nsIProfiler'],
'type': 'nsProfiler',
'headers': ['/tools/profiler/gecko/nsProfiler.h'],
'init_method': 'Init',

Просмотреть файл

@ -43,14 +43,11 @@ Classes = [
'headers': ['/widget/nsTransferable.h'],
},
{
'js_name': 'clipboard',
'cid': '{8b5314ba-db01-11d2-96ce-0060b0fb9956}',
'contract_ids': ['@mozilla.org/widget/clipboard;1'],
'interfaces': ['nsIClipboard'],
'type': 'nsClipboard',
'headers': ['/widget/android/nsClipboard.h'],
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
'overridable': True,
},
{
'cid': '{77221d5a-1dd2-11b2-8c69-c710f15d2ed5}',
@ -92,10 +89,8 @@ Classes = [
'init_method': 'Init',
},
{
'js_name': 'androidBridge',
'cid': '{0fe2321d-ebd9-467d-a743-03a68d40599e}',
'contract_ids': ['@mozilla.org/android/bridge;1'],
'interfaces': ['nsIAndroidBridge'],
'type': 'nsAndroidBridge',
'headers': ['/widget/android/AndroidBridge.h'],
},

Просмотреть файл

@ -87,13 +87,10 @@ Classes = [
if defined('MOZ_X11'):
Classes += [
{
'js_name': 'clipboard',
'cid': '{8b5314ba-db01-11d2-96ce-0060b0fb9956}',
'contract_ids': ['@mozilla.org/widget/clipboard;1'],
'interfaces': ['nsIClipboard'],
'type': 'nsIClipboard',
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
'overridable': True,
},
{
'cid': '{77221d5a-1dd2-11b2-8c69-c710f15d2ed5}',

Просмотреть файл

@ -148,13 +148,10 @@ Classes = [
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
},
{
'js_name': 'clipboard',
'cid': '{8b5314ba-db01-11d2-96ce-0060b0fb9956}',
'contract_ids': ['@mozilla.org/widget/clipboard;1'],
'interfaces': ['nsIClipboard'],
'type': 'nsIClipboard',
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
'overridable': True,
},
]

Просмотреть файл

@ -32,10 +32,8 @@ Classes = [
'constructor': 'nsChromeRegistry::GetSingleton',
},
{
'js_name': 'console',
'cid': '{7e3ff85c-1dd2-11b2-8d4b-eb452cb0ff40}',
'contract_ids': ['@mozilla.org/consoleservice;1'],
'interfaces': ['nsIConsoleService'],
'type': 'nsConsoleService',
'headers': ['/xpcom/base/nsConsoleService.h'],
'init_method': 'Init',
@ -186,20 +184,15 @@ Classes = [
'headers': ['nsSupportsPrimitives.h'],
},
{
'js_name': 'sysinfo',
'cid': '{d962398a-99e5-49b2-857a-c159049c7f6c}',
'contract_ids': ['@mozilla.org/system-info;1'],
'interfaces': ['nsIPropertyBag2', 'nsISystemInfo'],
'type': 'nsSystemInfo',
'headers': ['nsSystemInfo.h'],
'init_method': 'Init',
'overridable': True,
},
{
'js_name': 'tm',
'cid': '{7a4204c6-e45a-4c37-8ebb-6709a22c917c}',
'contract_ids': ['@mozilla.org/thread-manager;1'],
'interfaces': ['nsIThreadManager'],
'legacy_constructor': 'nsThreadManagerGetSingleton',
'headers': ['/xpcom/build/XPCOMModule.h'],
},
@ -218,10 +211,8 @@ Classes = [
'headers': ['nsVariant.h'],
},
{
'js_name': 'vc',
'cid': '{c6e47036-ca94-4be3-963a-9abd8705f7a8}',
'contract_ids': ['@mozilla.org/xpcom/version-comparator;1'],
'interfaces': ['nsIVersionComparator'],
'type': 'nsVersionComparatorImpl',
'headers': ['/xpcom/base/nsVersionComparatorImpl.h'],
},

Просмотреть файл

@ -6,7 +6,6 @@
#include "StaticComponents.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/PerfectHash.h"
#include "mozilla/ResultExtensions.h"
#include "mozilla/StaticPtr.h"
@ -21,8 +20,6 @@
#include "nsIXPConnect.h"
#include "nsString.h"
#include "nsStringEnumerator.h"
#include "nsTArray.h"
#include "xptinfo.h"
// Cleanup pollution from zipstruct.h
#undef UNSUPPORTED
@ -74,10 +71,6 @@ const StaticCategoryEntry gStaticCategoryEntries[] = {
//# @category_entries@
};
const nsXPTInterface gInterfaces[] = {
//# @interfaces@
};
const StringOffset gComponentJSMs[] = {
//# @component_jsms@
};
@ -138,8 +131,6 @@ static nsresult ConstructJSMComponent(const nsACString& aURI,
//# @module_contract_id_table@
//# @js_services_table@
static inline bool CalledInit(size_t aIdx) {
return GetBit(gInitCalled, aIdx);
}
@ -234,14 +225,6 @@ nsresult StaticModule::CreateInstance(nsISupports* aOuter, const nsIID& aIID,
return CreateInstanceImpl(ID(), aOuter, aIID, aResult);
}
GetServiceHelper StaticModule::GetService() const {
return { ID(), nullptr };
}
GetServiceHelper StaticModule::GetService(nsresult* aRv) const {
return { ID(), aRv };
}
nsISupports* StaticModule::ServiceInstance() const {
return gServiceInstances[Idx()];
@ -267,26 +250,6 @@ nsCString StaticCategory::Name() const {
return GetString(mName);
}
nsCString JSServiceEntry::Name() const {
return GetString(mName);
}
JSServiceEntry::InterfaceList JSServiceEntry::Interfaces() const {
InterfaceList iids;
iids.SetCapacity(mInterfaceCount);
for (size_t i = 0; i < mInterfaceCount; i++) {
nsXPTInterface ifaceID = gInterfaces[mInterfaceOffset.mOffset + i];
iids.AppendElement(&nsXPTInterfaceInfo::Get(ifaceID)->IID());
}
return iids;
}
/* static */
const JSServiceEntry* JSServiceEntry::Lookup(const nsACString& aName) {
return LookupJSService(aName);
}
/* static */ const StaticModule* StaticComponents::LookupByCID(
const nsID& aCID) {
@ -326,10 +289,6 @@ StaticComponents::GetComponentJSMs() {
return result.forget();
}
/* static */ Span<const JSServiceEntry> StaticComponents::GetJSServices() {
return { gJSServices, ArrayLength(gJSServices) };
}
/* static */ void StaticComponents::Shutdown() {
CallUnloadFuncs();
}

Просмотреть файл

@ -9,7 +9,6 @@
#include "mozilla/AlreadyAddRefed.h"
#include "mozilla/Module.h"
#include "mozilla/Span.h"
#include "nsID.h"
#include "nsStringFwd.h"
#include "nscore.h"
@ -20,8 +19,6 @@
class nsIFactory;
class nsIUTF8StringEnumerator;
class nsISupports;
template <typename T, size_t N>
class AutoTArray;
namespace mozilla {
namespace xpcom {
@ -75,13 +72,6 @@ struct StringOffset final {
uint32_t mOffset;
};
/**
* Represents an offset into the interfaces table.
*/
struct InterfaceOffset final {
uint32_t mOffset;
};
/**
* Represents a static component entry defined in a `Classes` list in an XPCOM
* manifest. Handles creating instances of and caching service instances for
@ -128,9 +118,6 @@ struct StaticModule {
nsresult CreateInstance(nsISupports* aOuter, const nsIID& aIID,
void** aResult) const;
GetServiceHelper GetService() const;
GetServiceHelper GetService(nsresult*) const;
nsISupports* ServiceInstance() const;
void SetServiceInstance(already_AddRefed<nsISupports> aInst) const;
};
@ -209,26 +196,6 @@ struct StaticCategory final {
}
};
struct JSServiceEntry final {
using InterfaceList = AutoTArray<const nsIID*, 4>;
static const JSServiceEntry* Lookup(const nsACString& aName);
StringOffset mName;
ModuleID mModuleID;
InterfaceOffset mInterfaceOffset;
uint8_t mInterfaceCount;
nsCString Name() const;
const StaticModule& Module() const {
return gStaticModules[size_t(mModuleID)];
}
InterfaceList Interfaces() const;
};
class StaticComponents final {
public:
static const StaticModule* LookupByCID(const nsID& aCID);
@ -244,8 +211,6 @@ class StaticComponents final {
static already_AddRefed<nsIUTF8StringEnumerator> GetComponentJSMs();
static Span<const JSServiceEntry> GetJSServices();
/**
* Calls any module unload from manifests whose components have been loaded.
*/

Просмотреть файл

@ -6,10 +6,8 @@
Classes = [
{
'js_name': 'catMan',
'cid': '{16d222a6-1dd2-11b2-b693-f38b02c021b2}',
'contract_ids': ['@mozilla.org/categorymanager;1'],
'interfaces': ['nsICategoryManager'],
'legacy_constructor': 'nsCategoryManager::Create',
'headers': ['/xpcom/components/nsCategoryManager.h'],
'processes': ProcessSelector.ALLOW_IN_GPU_RDD_AND_SOCKET_PROCESS,

Просмотреть файл

@ -173,8 +173,6 @@ class StringTable(object):
strings = StringTable()
interfaces = []
# Represents a C++ namespace, containing a set of classes and potentially
# sub-namespaces. This is used to generate pre-declarations for incomplete
@ -225,17 +223,6 @@ class ModuleEntry(object):
self.processes = data.get('processes', 0)
self.headers = data.get('headers', [])
self.js_name = data.get('js_name', None)
self.interfaces = data.get('interfaces', [])
if len(self.interfaces) > 255:
raise Exception('JS service %s may not have more than 255 '
'interfaces' % self.js_name)
self.interfaces_offset = len(interfaces)
for iface in self.interfaces:
interfaces.append(iface)
# If the manifest declares Init or Unload functions, this contains its
# index, as understood by the `CallInitFunc()` function.
#
@ -317,19 +304,6 @@ class ModuleEntry(object):
contract_id=contract_id,
processes=lower_processes(self.processes))
# Generates the C++ code for a JSServiceEntry represengin this module.
def lower_js_service(self):
return """
{{
{js_name},
ModuleID::{name},
{{ {iface_offset} }},
{iface_count}
}}""".format(js_name=strings.entry_to_cxx(self.js_name),
name=self.name,
iface_offset=self.interfaces_offset,
iface_count=len(self.interfaces))
# Generates the C++ code necessary to construct an instance of this
# component.
#
@ -521,13 +495,6 @@ def gen_module_funcs(substs, funcs):
substs['init_count'] = len(funcs)
def gen_interfaces(ifaces):
res = []
for iface in ifaces:
res.append(' nsXPTInterface::%s,\n' % iface)
return ''.join(res)
# Generates class pre-declarations for any types referenced in `Classes` array
# entries which do not have corresponding `headers` entries to fully declare
# their types.
@ -619,7 +586,6 @@ def gen_substs(manifests):
contracts = []
contract_map = {}
categories = defaultdict(list)
js_services = {}
jsms = set()
@ -647,20 +613,12 @@ def gen_substs(manifests):
if mod.jsm:
jsms.add(mod.jsm)
if mod.js_name:
if mod.js_name in js_services:
raise Exception('Duplicate JS service name: %s' % mod.js_name)
js_services[mod.js_name] = mod
cid_phf = PerfectHash(modules, PHF_SIZE,
key=lambda module: module.cid.bytes)
contract_phf = PerfectHash(contracts, PHF_SIZE,
key=lambda entry: entry.contract)
js_services_phf = PerfectHash(list(js_services.values()), PHF_SIZE,
key=lambda entry: entry.js_name)
substs = {}
gen_categories(substs, categories)
@ -678,8 +636,6 @@ def gen_substs(manifests):
substs['component_jsms'] = '\n'.join(' %s,' % strings.entry_to_cxx(jsm)
for jsm in sorted(jsms)) + '\n'
substs['interfaces'] = gen_interfaces(interfaces)
substs['decls'] = gen_decls(types)
substs['constructors'] = gen_constructors(cid_phf.entries)
@ -713,19 +669,6 @@ def gen_substs(manifests):
key_bytes='aKey.BeginReading()',
key_length='aKey.Length()')
substs['js_services_table'] = js_services_phf.cxx_codegen(
name='LookupJSService',
entry_type='JSServiceEntry',
entries_name='gJSServices',
lower_entry=lambda entry: entry.lower_js_service(),
return_type='const JSServiceEntry*',
return_entry='return entry.Name() == aKey ? &entry : nullptr;',
key_type='const nsACString&',
key_bytes='aKey.BeginReading()',
key_length='aKey.Length()')
# Do this only after everything else has been emitted so we're sure the
# string table is complete.
substs['strings'] = strings.to_cxx()

Просмотреть файл

@ -1440,6 +1440,10 @@ nsresult nsComponentManagerImpl::GetService(ModuleID aId, const nsIID& aIID,
MutexLock lock(mLock);
if (!entry.Active()) {
return NS_ERROR_FACTORY_NOT_REGISTERED;
}
Maybe<EntryWrapper> wrapper;
if (entry.Overridable()) {
// If we expect this service to be overridden by test code, we need to look
@ -1448,8 +1452,6 @@ nsresult nsComponentManagerImpl::GetService(ModuleID aId, const nsIID& aIID,
if (!wrapper) {
return NS_ERROR_FACTORY_NOT_REGISTERED;
}
} else if (!entry.Active()) {
return NS_ERROR_FACTORY_NOT_REGISTERED;
} else {
wrapper.emplace(&entry);
}

Просмотреть файл

@ -12,10 +12,8 @@ Classes = [
'headers': ['nsArray.h'],
},
{
'js_name': 'obs',
'cid': '{d07f5195-e3d1-11d2-8acd-00105a1b8860}',
'contract_ids': ['@mozilla.org/observer-service;1'],
'interfaces': ['nsIObserverService'],
'legacy_constructor': 'nsObserverService::Create',
'headers': ['/xpcom/ds/nsObserverService.h'],
'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_AND_SOCKET_PROCESS,

Просмотреть файл

@ -6,10 +6,8 @@
Classes = [
{
'js_name': 'dirsvc',
'cid': '{f00152d0-b40b-11d3-8c9c-000064657374}',
'contract_ids': ['@mozilla.org/file/directory_service;1'],
'interfaces': ['nsIDirectoryService', 'nsIProperties'],
'legacy_constructor': 'nsDirectoryService::Create',
'headers': ['nsDirectoryService.h'],
},

Просмотреть файл

@ -179,7 +179,7 @@ utility_types = [
# Core of the code generator. Takes a list of raw JSON XPT interfaces, and
# writes out a file containing the necessary static declarations into fd.
def link_to_cpp(interfaces, fd, header_fd):
def link_to_cpp(interfaces, fd):
# Perfect Hash from IID to interface.
iid_phf = PerfectHash(interfaces, PHFSIZE,
key=lambda i: iid_bytes(i['uuid']))
@ -449,20 +449,8 @@ def link_to_cpp(interfaces, fd, header_fd):
for iface in iid_phf.entries:
lower_iface(iface)
# Write out the final output files
# Write out the final output file
fd.write("/* THIS FILE WAS GENERATED BY xptcodegen.py - DO NOT EDIT */\n\n")
header_fd.write("/* THIS FILE WAS GENERATED BY xptcodegen.py - DO NOT EDIT */\n\n")
header_fd.write("""
enum class nsXPTInterface : uint16_t {
""")
for entry in iid_phf.entries:
header_fd.write(" %s,\n" % entry['name'])
header_fd.write("""
};
""")
# Include any bindings files which we need to include for webidl types
for include in sorted(includes):
@ -560,7 +548,7 @@ const uint16_t sInterfacesSize = mozilla::ArrayLength(sInterfaces);
""")
def link_and_write(files, outfile, outheader):
def link_and_write(files, outfile):
interfaces = []
for file in files:
with open(file, 'r') as fd:
@ -574,7 +562,7 @@ def link_and_write(files, outfile, outheader):
iids.add(interface['uuid'])
names.add(interface['name'])
link_to_cpp(interfaces, outfile, outheader)
link_to_cpp(interfaces, outfile)
def main():
@ -583,12 +571,11 @@ def main():
parser = ArgumentParser()
parser.add_argument('outfile', help='Output C++ file to generate')
parser.add_argument('outheader', help='Output C++ header file to generate')
parser.add_argument('xpts', nargs='*', help='source xpt files')
args = parser.parse_args(sys.argv[1:])
with open(args.outfile, 'w') as fd, open(args.outheader, 'w') as header_fd:
link_and_write(args.xpts, fd, header_fd)
with open(args.outfile, 'w') as fd:
link_and_write(args.xpts, fd)
if __name__ == '__main__':

Просмотреть файл

@ -21,7 +21,6 @@
#include "js/Value.h"
#include "nsString.h"
#include "nsTArray.h"
#include "xptdata.h"
// Forward Declarations
namespace mozilla {
@ -70,10 +69,6 @@ struct nsXPTInterfaceInfo {
return xpt::detail::InterfaceByName(aName);
}
static const nsXPTInterfaceInfo* Get(nsXPTInterface aID) {
return ByIndex(uint16_t(aID));
}
// These are only needed for Components_interfaces's enumerator.
static const nsXPTInterfaceInfo* ByIndex(uint16_t aIndex) {
// NOTE: We add 1 here, as the internal index 0 is reserved for null.

Просмотреть файл

@ -6,18 +6,14 @@
Classes = [
{
'js_name': 'appShell',
'cid': '{0099907d-123c-4853-a46a-43098b5fb68c}',
'contract_ids': ['@mozilla.org/appshell/appShellService;1'],
'interfaces': ['nsIAppShellService'],
'type': 'nsAppShellService',
'headers': ['/xpfe/appshell/nsAppShellService.h'],
},
{
'js_name': 'wm',
'cid': '{79a2b7cc-f05b-4605-bfa0-fac54f27eec8}',
'contract_ids': ['@mozilla.org/appshell/window-mediator;1'],
'interfaces': ['nsIWindowMediator'],
'type': 'nsWindowMediator',
'headers': ['/xpfe/appshell/nsWindowMediator.h'],
'init_method': 'Init',