diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 8c350b4fc17..a43af48895a 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -2200,6 +2200,23 @@ class MethodDefiner(PropertyDefiner): condition, specData, doIdArrays) +def IsCrossOriginWritable(attr, descriptor): + """ + Return whether the IDLAttribute in question is cross-origin writable on the + interface represented by descriptor. This is needed to handle the fact that + some, but not all, interfaces implementing URLUtils want a cross-origin + writable .href. + """ + crossOriginWritable = attr.getExtendedAttribute("CrossOriginWritable") + if not crossOriginWritable: + return False + if crossOriginWritable == True: + return True + assert (isinstance(crossOriginWritable, list) and + len(crossOriginWritable) == 1) + return crossOriginWritable[0] == descriptor.interface.identifier.name + + class AttrDefiner(PropertyDefiner): def __init__(self, descriptor, name, static, unforgeable=False): assert not (static and unforgeable) @@ -2263,7 +2280,7 @@ class AttrDefiner(PropertyDefiner): else: if attr.hasLenientThis(): accessor = "genericLenientSetter" - elif attr.getExtendedAttribute("CrossOriginWritable"): + elif IsCrossOriginWritable(attr, self.descriptor): accessor = "genericCrossOriginSetter" elif self.descriptor.needsSpecialGenericOps(): accessor = "genericSetter" @@ -10396,13 +10413,13 @@ class CGDescriptor(CGThing): cgThings.append(CGSpecializedSetter(descriptor, m)) if m.hasLenientThis(): hasLenientSetter = True - elif m.getExtendedAttribute("CrossOriginWritable"): + elif IsCrossOriginWritable(m, descriptor): crossOriginSetters.add(m.identifier.name) elif descriptor.needsSpecialGenericOps(): hasSetter = True elif m.getExtendedAttribute("PutForwards"): cgThings.append(CGSpecializedForwardingSetter(descriptor, m)) - if m.getExtendedAttribute("CrossOriginWritable"): + if IsCrossOriginWritable(m, descriptor): crossOriginSetters.add(m.identifier.name) elif descriptor.needsSpecialGenericOps(): hasSetter = True diff --git a/dom/bindings/parser/WebIDL.py b/dom/bindings/parser/WebIDL.py index 993d47f82e4..4c239e36eb7 100644 --- a/dom/bindings/parser/WebIDL.py +++ b/dom/bindings/parser/WebIDL.py @@ -2997,7 +2997,7 @@ class IDLAttribute(IDLInterfaceMember): [attr.location, self.location]) elif (identifier == "CrossOriginReadable" or identifier == "CrossOriginWritable"): - if not attr.noArguments(): + if not attr.noArguments() and identifier == "CrossOriginReadable": raise WebIDLError("[%s] must take no arguments" % identifier, [attr.location]) if self.isStatic(): @@ -3591,15 +3591,19 @@ class IDLMethod(IDLInterfaceMember, IDLScope): raise WebIDLError("[LenientFloat] used on an operation with no " "restricted float type arguments", [attr.location, self.location]) + elif (identifier == "Pure" or + identifier == "CrossOriginCallable" or + identifier == "WebGLHandlesContextLoss"): + # Known no-argument attributes. + if not attr.noArguments(): + raise WebIDLError("[%s] must take no arguments" % identifier, + [attr.location]) elif (identifier == "Throws" or identifier == "NewObject" or identifier == "ChromeOnly" or identifier == "Pref" or identifier == "Func" or identifier == "AvailableIn" or - identifier == "Pure" or - identifier == "CrossOriginCallable" or - identifier == "WebGLHandlesContextLoss" or identifier == "CheckPermissions"): # Known attributes that we don't need to do anything with here pass diff --git a/dom/webidl/Location.webidl b/dom/webidl/Location.webidl index 8e59473aef1..7cc105890d0 100644 --- a/dom/webidl/Location.webidl +++ b/dom/webidl/Location.webidl @@ -15,7 +15,7 @@ interface Location { [Throws] void assign(DOMString url); - [Throws] + [Throws, CrossOriginCallable] void replace(DOMString url); // XXXbz there is no forceget argument in the spec! See bug 1037721. [Throws] diff --git a/dom/webidl/URLUtils.webidl b/dom/webidl/URLUtils.webidl index 8cb4bfa5ee1..2e56c20429c 100644 --- a/dom/webidl/URLUtils.webidl +++ b/dom/webidl/URLUtils.webidl @@ -17,7 +17,7 @@ interface URLUtilsNoSearchParams { // Bug 824857: no support for stringifier attributes yet. // stringifier attribute DOMString href; - [Throws] + [Throws, CrossOriginWritable=Location] attribute DOMString href; [Throws] readonly attribute DOMString origin;