diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 53bb341ade73..68de0f2c31d9 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -1301,6 +1301,17 @@ class CGClassHasInstanceHook(CGAbstractStaticMethod): def isChromeOnly(m): return m.getExtendedAttribute("ChromeOnly") +def getAvailableInTestFunc(obj): + availableIn = obj.getExtendedAttribute("AvailableIn") + if availableIn is None: + return None + assert isinstance(availableIn, list) and len(availableIn) == 1 + if availableIn[0] == "PrivilegedApps": + return "IsInPrivilegedApp" + if availableIn[0] == "CertifiedApps": + return "IsInCertifiedApp" + raise TypeError("Unknown AvailableIn value '%s'" % availableIn[0]) + class MemberCondition: """ An object representing the condition for a member to actually be @@ -2118,6 +2129,9 @@ class CGConstructorEnabled(CGAbstractMethod): conditions.append("%s(aCx, aObj)" % func[0]) if iface.getExtendedAttribute("PrefControlled"): conditions.append("%s::PrefEnabled()" % self.descriptor.nativeType) + availableIn = getAvailableInTestFunc(iface) + if availableIn: + conditions.append("%s(aCx, aObj)" % availableIn) # We should really have some conditions assert len(conditions) body = CGWrapper(CGList((CGGeneric(cond) for cond in conditions), diff --git a/dom/bindings/Configuration.py b/dom/bindings/Configuration.py index 2926be233e88..1360ac029843 100644 --- a/dom/bindings/Configuration.py +++ b/dom/bindings/Configuration.py @@ -492,7 +492,8 @@ class Descriptor(DescriptorProvider): return (self.interface.getExtendedAttribute("Pref") or self.interface.getExtendedAttribute("ChromeOnly") or self.interface.getExtendedAttribute("Func") or - self.interface.getExtendedAttribute("PrefControlled")) + self.interface.getExtendedAttribute("PrefControlled") or + self.interface.getExtendedAttribute("AvailableIn")) # Some utility methods def getTypesFromDescriptor(descriptor): diff --git a/dom/bindings/parser/WebIDL.py b/dom/bindings/parser/WebIDL.py index f0369d92ac05..90da33ea6445 100644 --- a/dom/bindings/parser/WebIDL.py +++ b/dom/bindings/parser/WebIDL.py @@ -977,6 +977,7 @@ class IDLInterface(IDLObjectWithScope): identifier == "JSImplementation" or identifier == "HeaderFile" or identifier == "NavigatorProperty" or + identifier == "AvailableIn" or identifier == "Func"): # Known extended attributes that take a string value if not attr.hasValue(): @@ -2813,6 +2814,7 @@ class IDLAttribute(IDLInterfaceMember): identifier == "Constant" or identifier == "Func" or identifier == "Frozen" or + identifier == "AvailableIn" or identifier == "NewObject"): # Known attributes that we don't need to do anything with here pass @@ -3363,6 +3365,7 @@ class IDLMethod(IDLInterfaceMember, IDLScope): identifier == "ChromeOnly" or identifier == "Pref" or identifier == "Func" or + identifier == "AvailableIn" or identifier == "Pure" or identifier == "CrossOriginCallable" or identifier == "WebGLHandlesContextLoss"): diff --git a/dom/bindings/test/TestCodeGen.webidl b/dom/bindings/test/TestCodeGen.webidl index cf5ca157672a..1eabe0cc767c 100644 --- a/dom/bindings/test/TestCodeGen.webidl +++ b/dom/bindings/test/TestCodeGen.webidl @@ -10,6 +10,7 @@ typedef TestInterface? NullableTestInterface; interface TestExternalInterface; +[AvailableIn=PrivilegedApps, Pref="xyz"] interface TestRenamedInterface { }; @@ -105,6 +106,7 @@ interface OnlyForUseInConstructor { Constructor(long arg1, IndirectlyImplementedInterface iface), Constructor(Date arg1), // Constructor(long arg1, long arg2, (TestInterface or OnlyForUseInConstructor) arg3), + AvailableIn=CertifiedApps, NamedConstructor=Test, NamedConstructor=Test(DOMString str), NamedConstructor=Test2(DictForConstructor dict, any any1, object obj1,