Skip to content

Instantly share code, notes, and snippets.

@ehsan
Created January 14, 2016 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ehsan/f763d1981af2239eb431 to your computer and use it in GitHub Desktop.
Save ehsan/f763d1981af2239eb431 to your computer and use it in GitHub Desktop.
diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py
index d33973d9..a1a229e 100644
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -3240,7 +3240,7 @@ class CGConstructorEnabled(CGAbstractMethod):
conditions = []
iface = self.descriptor.interface
- if not iface.isExposedInWindow():
+ if not iface.isExposedOnMainThread():
exposedInWindowCheck = dedent(
"""
MOZ_ASSERT(!NS_IsMainThread(), "Why did we even get called?");
@@ -3259,7 +3259,7 @@ class CGConstructorEnabled(CGAbstractMethod):
}
""", workerCondition=workerCondition.define())
exposedInWorkerCheck = CGGeneric(exposedInWorkerCheck)
- if iface.isExposedInWindow():
+ if iface.isExposedOnMainThread():
exposedInWorkerCheck = CGIfWrapper(exposedInWorkerCheck,
"!NS_IsMainThread()")
body.append(exposedInWorkerCheck)
diff --git a/dom/bindings/parser/WebIDL.py b/dom/bindings/parser/WebIDL.py
index e664988..a2a83ce 100644
--- a/dom/bindings/parser/WebIDL.py
+++ b/dom/bindings/parser/WebIDL.py
@@ -501,6 +501,10 @@ class IDLExposureMixins():
def isExposedInWindow(self):
return 'Window' in self.exposureSet
+ def isExposedOnMainThread(self):
+ return 'Window' in self.exposureSet or
+ 'System' in self.exposureSet
+
def isExposedInAnyWorker(self):
return len(self.getWorkerExposureSet()) > 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment