Bug 1363208 part 6. Remove the NonOrdinaryGetPrototypeOf annotation. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 21 Jan 2019 03:33:16 +0000
changeset 454648 c825004b9059681860fdfe283698d813217e6f9d
parent 454647 7faa84f9f73a76f37d605a6b07d46c24e516e576
child 454649 140c8b32490c724df4677e93ef98f31c420c7dfe
push id35409
push userrmaries@mozilla.com
push dateMon, 21 Jan 2019 17:48:45 +0000
treeherdermozilla-central@4977d02e1191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1363208
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1363208 part 6. Remove the NonOrdinaryGetPrototypeOf annotation. r=peterv We can just check for a non-global object (so excluding Window) with cross-origin properties. Differential Revision: https://phabricator.services.mozilla.com/D15430
dom/bindings/Codegen.py
dom/bindings/Configuration.py
dom/bindings/parser/WebIDL.py
dom/webidl/Location.webidl
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -3753,17 +3753,17 @@ def InitMemberSlots(descriptor, failureC
         if (!UpdateMemberSlots(aCx, aReflector, aObject)) {
           $*{failureCode}
         }
         """,
         failureCode=failureCode)
 
 
 def SetImmutablePrototype(descriptor, failureCode):
-    if not descriptor.hasNonOrdinaryGetPrototypeOf():
+    if not descriptor.isMaybeCrossOriginObject():
         return ""
 
     return fill(
         """
         bool succeeded;
         if (!JS_SetImmutablePrototype(aCx, aReflector, &succeeded)) {
           ${failureCode}
         }
@@ -12517,17 +12517,17 @@ class CGDOMJSProxyHandler_canNurseryAllo
             return true;
         """)
 
 
 class CGDOMJSProxyHandler(CGClass):
     def __init__(self, descriptor):
         assert (descriptor.supportsIndexedProperties() or
                 descriptor.supportsNamedProperties() or
-                descriptor.hasNonOrdinaryGetPrototypeOf())
+                descriptor.isMaybeCrossOriginObject())
         methods = [CGDOMJSProxyHandler_getOwnPropDescriptor(descriptor),
                    CGDOMJSProxyHandler_defineProperty(descriptor),
                    ClassUsingDeclaration("mozilla::dom::DOMProxyHandler",
                                          "defineProperty"),
                    CGDOMJSProxyHandler_ownPropNames(descriptor),
                    CGDOMJSProxyHandler_hasOwn(descriptor),
                    CGDOMJSProxyHandler_get(descriptor),
                    CGDOMJSProxyHandler_className(descriptor),
@@ -12544,17 +12544,17 @@ class CGDOMJSProxyHandler(CGClass):
         ]
 
         if descriptor.supportsIndexedProperties():
             methods.append(CGDOMJSProxyHandler_getElements(descriptor))
         if (descriptor.operations['IndexedSetter'] is not None or
             (descriptor.operations['NamedSetter'] is not None and
              descriptor.interface.getExtendedAttribute('OverrideBuiltins'))):
             methods.append(CGDOMJSProxyHandler_setCustom(descriptor))
-        if descriptor.hasNonOrdinaryGetPrototypeOf():
+        if descriptor.isMaybeCrossOriginObject():
             methods.append(CGDOMJSProxyHandler_getPrototypeIfOrdinary())
         if descriptor.operations['LegacyCaller']:
             methods.append(CGDOMJSProxyHandler_call())
             methods.append(CGDOMJSProxyHandler_isCallable())
         if descriptor.interface.hasProbablyShortLivingWrapper():
             if not descriptor.wrapperCache:
                 raise TypeError("Need a wrapper cache to support nursery "
                                 "allocation of DOM objects")
--- a/dom/bindings/Configuration.py
+++ b/dom/bindings/Configuration.py
@@ -437,33 +437,42 @@ class Descriptor(DescriptorProvider):
             for m in self.interface.members:
                 if m.isMethod() and m.isStringifier():
                     addOperation('Stringifier', m)
                 if m.isMethod() and m.isDefaultToJSON():
                     self.hasDefaultToJSON = True
 
         if self.concrete:
             self.proxy = False
+            self.hasCrossOriginMembers = False
             iface = self.interface
             for m in iface.members:
                 # Don't worry about inheriting legacycallers either: in
                 # practice these are on most-derived prototypes.
                 if m.isMethod() and m.isLegacycaller():
                     if not m.isIdentifierLess():
                         raise TypeError("We don't support legacycaller with "
                                         "identifier.\n%s" % m.location)
                     if len(m.signatures()) != 1:
                         raise TypeError("We don't support overloaded "
                                         "legacycaller.\n%s" % m.location)
                     addOperation('LegacyCaller', m)
             while iface:
                 for m in iface.members:
+                    if (m.isAttr() and
+                        (m.getExtendedAttribute("CrossOriginReadable") or
+                         m.getExtendedAttribute("CrossOriginWritable"))):
+                        self.hasCrossOriginMembers = True
+
                     if not m.isMethod():
                         continue
 
+                    if m.getExtendedAttribute("CrossOriginCallable"):
+                        self.hasCrossOriginMembers = True
+
                     def addIndexedOrNamedOperation(operation, m):
                         if m.isIndexed():
                             operation = 'Indexed' + operation
                         else:
                             assert m.isNamed()
                             operation = 'Named' + operation
                         addOperation(operation, m)
 
@@ -479,17 +488,17 @@ class Descriptor(DescriptorProvider):
                                         (iface, iface.location))
 
                 iface.setUserData('hasConcreteDescendant', True)
                 iface = iface.parent
 
             self.proxy = (self.supportsIndexedProperties() or
                           (self.supportsNamedProperties() and
                            not self.hasNamedPropertiesObject) or
-                          self.hasNonOrdinaryGetPrototypeOf())
+                          self.isMaybeCrossOriginObject())
 
             if self.proxy:
                 if (not self.operations['IndexedGetter'] and
                     (self.operations['IndexedSetter'] or
                      self.operations['IndexedDeleter'])):
                     raise SyntaxError("%s supports indexed properties but does "
                                       "not have an indexed getter.\n%s" %
                                       (self.interface, self.interface.location))
@@ -703,18 +712,20 @@ class Descriptor(DescriptorProvider):
         Determine whether our GetSupportedNames call needs a caller type.  The
         idea is that if your named getter needs a caller type, then so does
         GetSupportedNames.
         """
         assert self.supportsNamedProperties()
         namedGetter = self.operations['NamedGetter']
         return namedGetter.getExtendedAttribute("NeedsCallerType")
 
-    def hasNonOrdinaryGetPrototypeOf(self):
-        return self.interface.getExtendedAttribute("NonOrdinaryGetPrototypeOf")
+    def isMaybeCrossOriginObject(self):
+        # If we're isGlobal and have cross-origin members, we're a Window, and
+        # that's not a cross-origin object.  The WindowProxy is.
+        return self.hasCrossOriginMembers and not self.isGlobal()
 
     def needsHeaderInclude(self):
         """
         An interface doesn't need a header file if it is not concrete, not
         pref-controlled, has no prototype object, has no static methods or
         attributes and has no parent.  The parent matters because we assert
         things about refcounting that depend on the actual underlying type if we
         have a parent.
--- a/dom/bindings/parser/WebIDL.py
+++ b/dom/bindings/parser/WebIDL.py
@@ -1781,18 +1781,17 @@ class IDLInterface(IDLInterfaceOrNamespa
             elif (identifier == "NeedResolve" or
                   identifier == "OverrideBuiltins" or
                   identifier == "ChromeOnly" or
                   identifier == "Unforgeable" or
                   identifier == "LegacyEventInit" or
                   identifier == "ProbablyShortLivingWrapper" or
                   identifier == "LegacyUnenumerableNamedProperties" or
                   identifier == "RunConstructorInCallerCompartment" or
-                  identifier == "WantsEventListenerHooks" or
-                  identifier == "NonOrdinaryGetPrototypeOf"):
+                  identifier == "WantsEventListenerHooks"):
                 # Known extended attributes that do not take values
                 if not attr.noArguments():
                     raise WebIDLError("[%s] must take no arguments" % identifier,
                                       [attr.location])
             elif identifier == "Exposed":
                 convertExposedAttrToGlobalNameSet(attr,
                                                   self._exposureGlobalNames)
             elif (identifier == "Pref" or
--- a/dom/webidl/Location.webidl
+++ b/dom/webidl/Location.webidl
@@ -6,17 +6,17 @@
  * The origin of this IDL file is
  * http://www.whatwg.org/specs/web-apps/current-work/#the-location-interface
  *
  * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
  * Opera Software ASA. You are granted a license to use, reproduce
  * and create derivative works of this document.
  */
 
-[Unforgeable, NonOrdinaryGetPrototypeOf]
+[Unforgeable]
 interface Location {
   // Bug 824857: no support for stringifier attributes yet.
   //  stringifier attribute USVString href;
 
   // Bug 824857 should remove this.
   [Throws, NeedsSubjectPrincipal]
   stringifier;