From be8f33b2af2ffc45d3e1a572d92f8e86c9cba37c Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 4 Dec 2013 08:02:18 -0500 Subject: [PATCH] Bug 942631 part 4. Allow WebIDL attributes to return a sequence if it's cached. r=peterv --- dom/bindings/parser/WebIDL.py | 6 +++--- dom/bindings/test/TestBindingHeader.h | 1 + dom/bindings/test/TestCodeGen.webidl | 2 ++ dom/bindings/test/TestExampleGen.webidl | 2 ++ dom/bindings/test/TestJSImplGen.webidl | 2 ++ 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/dom/bindings/parser/WebIDL.py b/dom/bindings/parser/WebIDL.py index 30b234f621ff..944faed6ffa0 100644 --- a/dom/bindings/parser/WebIDL.py +++ b/dom/bindings/parser/WebIDL.py @@ -2652,9 +2652,9 @@ class IDLAttribute(IDLInterfaceMember): if self.type.isDictionary(): raise WebIDLError("An attribute cannot be of a dictionary type", [self.location]) - if self.type.isSequence(): - raise WebIDLError("An attribute cannot be of a sequence type", - [self.location]) + if self.type.isSequence() and not self.getExtendedAttribute("Cached"): + raise WebIDLError("A non-cached attribute cannot be of a sequence " + "type", [self.location]) if self.type.isUnion(): for f in self.type.unroll().flatMemberTypes: if f.isDictionary(): diff --git a/dom/bindings/test/TestBindingHeader.h b/dom/bindings/test/TestBindingHeader.h index e303bb3b4e38..034dc30b497b 100644 --- a/dom/bindings/test/TestBindingHeader.h +++ b/dom/bindings/test/TestBindingHeader.h @@ -340,6 +340,7 @@ public: void PassConsequentialInterface(IndirectlyImplementedInterface&); // Sequence types + void GetReadonlySequence(nsTArray&); void ReceiveSequence(nsTArray&); void ReceiveNullableSequence(Nullable< nsTArray >&); void ReceiveSequenceOfNullableInts(nsTArray< Nullable >&); diff --git a/dom/bindings/test/TestCodeGen.webidl b/dom/bindings/test/TestCodeGen.webidl index e06c14fab276..09dc2565fdc0 100644 --- a/dom/bindings/test/TestCodeGen.webidl +++ b/dom/bindings/test/TestCodeGen.webidl @@ -295,6 +295,8 @@ interface TestInterface { void passConsequentialInterface(IndirectlyImplementedInterface arg); // Sequence types + [Cached, Pure] + readonly attribute sequence readonlySequence; sequence receiveSequence(); sequence? receiveNullableSequence(); sequence receiveSequenceOfNullableInts(); diff --git a/dom/bindings/test/TestExampleGen.webidl b/dom/bindings/test/TestExampleGen.webidl index edfdaf8fc52a..6910b7124d72 100644 --- a/dom/bindings/test/TestExampleGen.webidl +++ b/dom/bindings/test/TestExampleGen.webidl @@ -191,6 +191,8 @@ interface TestExampleInterface { void passConsequentialInterface(IndirectlyImplementedInterface arg); // Sequence types + [Cached, Pure] + readonly attribute sequence readonlySequence; sequence receiveSequence(); sequence? receiveNullableSequence(); sequence receiveSequenceOfNullableInts(); diff --git a/dom/bindings/test/TestJSImplGen.webidl b/dom/bindings/test/TestJSImplGen.webidl index 4b7d18ef59de..208cf1ac41df 100644 --- a/dom/bindings/test/TestJSImplGen.webidl +++ b/dom/bindings/test/TestJSImplGen.webidl @@ -212,6 +212,8 @@ interface TestJSImplInterface { void passConsequentialInterface(IndirectlyImplementedInterface arg); // Sequence types + [Cached, Pure] + readonly attribute sequence readonlySequence; sequence receiveSequence(); sequence? receiveNullableSequence(); sequence receiveSequenceOfNullableInts();