From bb157707dd89750d0f2c13378626e32f4c9381bc Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Tue, 15 Jul 2014 16:15:28 -0300 Subject: [PATCH] Bug 1009645 - Address additional comments. r=bz --HG-- extra : rebase_source : c6befdd143ad15751182af10f80b03c2f23eea4d --- dom/base/Navigator.cpp | 2 +- dom/bindings/parser/WebIDL.py | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 24e997da8341..0916b441f99c 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -1538,7 +1538,7 @@ Navigator::GetFeature(const nsAString& aName) NS_NAMED_LITERAL_STRING(apiWindowPrefix, "api.window."); if (StringBeginsWith(aName, apiWindowPrefix)) { - const nsAString& featureName = Substring(aName, apiWindowPrefix.Length(), aName.Length()-apiWindowPrefix.Length()); + const nsAString& featureName = Substring(aName, apiWindowPrefix.Length()); if (IsFeatureDetectible(featureName)) { p->MaybeResolve(true); } else { diff --git a/dom/bindings/parser/WebIDL.py b/dom/bindings/parser/WebIDL.py index 67335182c5e2..e5c8e5c614eb 100644 --- a/dom/bindings/parser/WebIDL.py +++ b/dom/bindings/parser/WebIDL.py @@ -569,14 +569,20 @@ class IDLInterface(IDLObjectWithScope): assert not parent or isinstance(parent, IDLInterface) if self.getExtendedAttribute("FeatureDetectible"): - if self.getExtendedAttribute("NoInterfaceObject"): - raise WebIDLError("[FeatureDetectible] not allowed on interface " - " with [NoInterfaceObject]", + if not (self.getExtendedAttribute("Func") or + self.getExtendedAttribute("AvailableIn") or + self.getExtendedAttribute("CheckPermissions")): + raise WebIDLError("[FeatureDetectible] is only allowed in combination " + "with [Func], [AvailableIn] or [CheckPermissions]", [self.location]) if self.getExtendedAttribute("Pref"): raise WebIDLError("[FeatureDetectible] must not be specified " "in combination with [Pref]", [self.location]) + if not self.hasInterfaceObject(): + raise WebIDLError("[FeatureDetectible] not allowed on interface " + "with [NoInterfaceObject]", + [self.location]) self.parent = parent @@ -2905,9 +2911,9 @@ class IDLAttribute(IDLInterfaceMember): if not (self.getExtendedAttribute("Func") or self.getExtendedAttribute("AvailableIn") or self.getExtendedAttribute("CheckPermissions")): - raise WebIDLError("[%s] is only allowed in combination with [Func], " - "[AvailableIn] or [CheckPermissions]" % identifier, - [attr.location, self.location]) + raise WebIDLError("[FeatureDetectible] is only allowed in combination " + "with [Func], [AvailableIn] or [CheckPermissions]", + [self.location]) if self.getExtendedAttribute("Pref"): raise WebIDLError("[FeatureDetectible] must not be specified " "in combination with [Pref]", @@ -3031,13 +3037,6 @@ class IDLAttribute(IDLInterfaceMember): raise WebIDLError("[LenientThis] is not allowed in combination " "with [%s]" % identifier, [attr.location, self.location]) - elif identifier == "FeatureDetectible": - if not (self.getExtendedAttribute("Func") or - self.getExtendedAttribute("AvailableIn") or - self.getExtendedAttribute("CheckPermissions")): - raise WebIDLError("[%s] is only allowed in combination with [Func], " - "[AvailableIn] or [CheckPermissions]" % identifier, - [attr.location, self.location]) elif (identifier == "Pref" or identifier == "SetterThrows" or identifier == "Pure" or @@ -3050,7 +3049,8 @@ class IDLAttribute(IDLInterfaceMember): identifier == "Frozen" or identifier == "AvailableIn" or identifier == "NewObject" or - identifier == "CheckPermissions"): + identifier == "CheckPermissions" or + identifier == "FeatureDetectible"): # Known attributes that we don't need to do anything with here pass else: @@ -3462,8 +3462,8 @@ class IDLMethod(IDLInterfaceMember, IDLScope): [self.location]) if self.getExtendedAttribute("Pref"): raise WebIDLError("[FeatureDetectible] must not be specified " - "in combination with [Pref]", - [self.location]) + "in combination with [Pref]", + [self.location]) overloadWithPromiseReturnType = None overloadWithoutPromiseReturnType = None