Bug 1119490 - Expose the URL constructor to WorkerDebuggerGlobalScope;r=khuey

This commit is contained in:
Eddy Bruel 2016-02-22 10:41:09 +01:00
Родитель b7e9c528d8
Коммит dae2755a45
9 изменённых файлов: 106 добавлений и 5 удалений

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

@ -12826,6 +12826,46 @@ class CGRegisterWorkerBindings(CGAbstractMethod):
lines.append(CGGeneric("return true;\n"))
return CGList(lines, "\n").define()
class CGRegisterWorkerDebuggerBindings(CGAbstractMethod):
def __init__(self, config):
CGAbstractMethod.__init__(self, None, 'RegisterWorkerDebuggerBindings', 'bool',
[Argument('JSContext*', 'aCx'),
Argument('JS::Handle<JSObject*>', 'aObj')])
self.config = config
def definition_body(self):
# We have to be a bit careful: Some of the interfaces we want to expose
# in workers only have one descriptor, while others have both a worker
# and a non-worker descriptor. When both are present we want the worker
# descriptor, but otherwise we want whatever descriptor we've got.
descriptors = self.config.getDescriptors(hasInterfaceObject=True,
isExposedInWorkerDebugger=True,
register=True,
skipGen=False,
workers=True)
workerDescriptorIfaceNames = set(d.interface.identifier.name for
d in descriptors)
descriptors.extend(
filter(
lambda d: d.interface.identifier.name not in workerDescriptorIfaceNames,
self.config.getDescriptors(hasInterfaceObject=True,
isExposedInWorkerDebugger=True,
register=True,
skipGen=False,
workers=False)))
conditions = []
for desc in descriptors:
bindingNS = toBindingNamespace(desc.name)
condition = "!%s::GetConstructorObject(aCx, aObj)" % bindingNS
if desc.isExposedConditionally():
condition = (
"%s::ConstructorEnabled(aCx, aObj) && " % bindingNS
+ condition)
conditions.append(condition)
lines = [CGIfWrapper(CGGeneric("return false;\n"), condition) for
condition in conditions]
lines.append(CGGeneric("return true;\n"))
return CGList(lines, "\n").define()
class CGResolveSystemBinding(CGAbstractMethod):
def __init__(self, config):
@ -16081,6 +16121,32 @@ class GlobalGenRoots():
# Done.
return curr
@staticmethod
def RegisterWorkerDebuggerBindings(config):
curr = CGRegisterWorkerDebuggerBindings(config)
# Wrap all of that in our namespaces.
curr = CGNamespace.build(['mozilla', 'dom'],
CGWrapper(curr, post='\n'))
curr = CGWrapper(curr, post='\n')
# Add the includes
defineIncludes = [CGHeaders.getDeclarationFilename(desc.interface)
for desc in config.getDescriptors(hasInterfaceObject=True,
register=True,
isExposedInWorkerDebugger=True,
skipGen=False)]
curr = CGHeaders([], [], [], [], [], defineIncludes,
'RegisterWorkerDebuggerBindings', curr)
# Add include guards.
curr = CGIncludeGuard('RegisterWorkerDebuggerBindings', curr)
# Done.
return curr
@staticmethod
def ResolveSystemBinding(config):

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

@ -228,6 +228,8 @@ class Configuration:
getter = lambda x: x.interface.getNavigatorProperty() is not None
elif key == 'isExposedInAnyWorker':
getter = lambda x: x.interface.isExposedInAnyWorker()
elif key == 'isExposedInWorkerDebugger':
getter = lambda x: x.interface.isExposedInWorkerDebugger()
elif key == 'isExposedInSystemGlobals':
getter = lambda x: x.interface.isExposedInSystemGlobals()
elif key == 'isExposedInWindow':

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

@ -133,6 +133,7 @@ class WebIDLCodegenManager(LoggingMixin):
'PrototypeList.h',
'RegisterBindings.h',
'RegisterWorkerBindings.h',
'RegisterWorkerDebuggerBindings.h',
'ResolveSystemBinding.h',
'UnionConversions.h',
'UnionTypes.h',
@ -142,6 +143,7 @@ class WebIDLCodegenManager(LoggingMixin):
GLOBAL_DEFINE_FILES = {
'RegisterBindings.cpp',
'RegisterWorkerBindings.cpp',
'RegisterWorkerDebuggerBindings.cpp',
'ResolveSystemBinding.cpp',
'UnionTypes.cpp',
'PrototypeList.cpp',

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

@ -508,6 +508,9 @@ class IDLExposureMixins():
def isExposedInAnyWorker(self):
return len(self.getWorkerExposureSet()) > 0
def isExposedInWorkerDebugger(self):
return len(self.getWorkerDebuggerExposureSet()) > 0
def isExposedInSystemGlobals(self):
return 'BackstagePass' in self.exposureSet
@ -527,6 +530,10 @@ class IDLExposureMixins():
workerScopes = self._globalScope.globalNameMapping["Worker"]
return workerScopes.intersection(self.exposureSet)
def getWorkerDebuggerExposureSet(self):
workerDebuggerScopes = self._globalScope.globalNameMapping["WorkerDebugger"]
return workerDebuggerScopes.intersection(self.exposureSet)
class IDLExternalInterface(IDLObjectWithIdentifier, IDLExposureMixins):
def __init__(self, location, parentScope, identifier):

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

@ -15,7 +15,7 @@
// [Constructor(DOMString url, optional (URL or DOMString) base = "about:blank")]
[Constructor(DOMString url, URL base),
Constructor(DOMString url, optional DOMString base),
Exposed=(Window,Worker)]
Exposed=(Window,Worker,WorkerDebugger)]
interface URL {
// Bug 824857: no support for stringifier attributes yet.
// stringifier attribute USVString href;

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

@ -15,7 +15,7 @@
[Constructor(optional USVString init = ""),
Constructor(URLSearchParams init),
Exposed=(Window,Worker,System)]
Exposed=(Window,Worker,WorkerDebugger,System)]
interface URLSearchParams {
void append(USVString name, USVString value);
void delete(USVString name);

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

@ -10,6 +10,7 @@
#include "jsapi.h"
#include "mozilla/dom/RegisterWorkerBindings.h"
#include "mozilla/dom/RegisterWorkerDebuggerBindings.h"
#include "mozilla/OSFileConstants.h"
USING_WORKERS_NAMESPACE
@ -36,3 +37,19 @@ WorkerPrivate::RegisterBindings(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
return true;
}
bool
WorkerPrivate::RegisterDebuggerBindings(JSContext* aCx,
JS::Handle<JSObject*> aGlobal)
{
// Init Web IDL bindings
if (!RegisterWorkerDebuggerBindings(aCx, aGlobal)) {
return false;
}
if (!JS_DefineDebuggerObject(aCx, aGlobal)) {
return false;
}
return true;
}

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

@ -6440,14 +6440,18 @@ WorkerPrivate::CreateDebuggerGlobalScope(JSContext* aCx)
JSAutoCompartment ac(aCx, global);
if (!JS_DefineDebuggerObject(aCx, global)) {
// RegisterDebuggerBindings() can spin a nested event loop so we have to set
// mDebuggerScope before calling it, and we have to make sure to unset
// mDebuggerScope if it fails.
mDebuggerScope = Move(globalScope);
if (!RegisterDebuggerBindings(aCx, global)) {
mDebuggerScope = nullptr;
return nullptr;
}
JS_FireOnNewGlobalObject(aCx, global);
mDebuggerScope = globalScope.forget();
return mDebuggerScope;
}

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

@ -1264,6 +1264,9 @@ public:
bool
RegisterBindings(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
bool
RegisterDebuggerBindings(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
#define WORKER_SIMPLE_PREF(name, getter, NAME) \
bool \
getter() const \