зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1473492 part 2. Disallow [Cached] on JS-implemented interfaces. r=mccr8
This commit is contained in:
Родитель
ba8705c5c6
Коммит
56cf508c19
|
@ -1045,6 +1045,12 @@ class IDLInterfaceOrNamespace(IDLObjectWithScope, IDLExposureMixins):
|
|||
(member.getExtendedAttribute("StoreInSlot") or
|
||||
member.getExtendedAttribute("Cached"))) or
|
||||
member.isMaplikeOrSetlike()):
|
||||
if self.isJSImplemented() and not member.isMaplikeOrSetlike():
|
||||
raise WebIDLError("Interface %s is JS-implemented and we "
|
||||
"don't support [Cached] or [StoreInSlot] "
|
||||
"on JS-implemented interfaces" %
|
||||
self.identifier.name,
|
||||
[self.location, member.location])
|
||||
if member.slotIndices is None:
|
||||
member.slotIndices = dict()
|
||||
member.slotIndices[self.identifier.name] = self.totalMembersInSlots
|
||||
|
|
|
@ -27,13 +27,13 @@ TestInterfaceJS.prototype = {
|
|||
|
||||
get anyArg() { return this._anyArg; },
|
||||
get objectArg() { return this._objectArg; },
|
||||
get dictionaryArg() { return this._dictionaryArg; },
|
||||
getDictionaryArg: function() { return this._dictionaryArg; },
|
||||
get anyAttr() { return this._anyAttr; },
|
||||
set anyAttr(val) { this._anyAttr = val; },
|
||||
get objectAttr() { return this._objectAttr; },
|
||||
set objectAttr(val) { this._objectAttr = val; },
|
||||
get dictionaryAttr() { return this._dictionaryAttr; },
|
||||
set dictionaryAttr(val) { this._dictionaryAttr = val; },
|
||||
getDictionaryAttr: function() { return this._dictionaryAttr; },
|
||||
setDictionaryAttr: function(val) { this._dictionaryAttr = val; },
|
||||
pingPongAny: function(any) { return any; },
|
||||
pingPongObject: function(obj) { return obj; },
|
||||
pingPongObjectOrString: function(objectOrString) { return objectOrString; },
|
||||
|
|
|
@ -41,12 +41,13 @@ interface TestJSImplInterface {
|
|||
void passNullableByte(byte? arg);
|
||||
void passOptionalNullableByte(optional byte? arg);
|
||||
void passVariadicByte(byte... arg);
|
||||
[Cached, Pure]
|
||||
readonly attribute byte cachedByte;
|
||||
[Cached, Constant]
|
||||
readonly attribute byte cachedConstantByte;
|
||||
[Cached, Pure]
|
||||
attribute byte cachedWritableByte;
|
||||
// [Cached] is not supported in JS-implemented WebIDL.
|
||||
//[Cached, Pure]
|
||||
//readonly attribute byte cachedByte;
|
||||
//[Cached, Constant]
|
||||
//readonly attribute byte cachedConstantByte;
|
||||
//[Cached, Pure]
|
||||
//attribute byte cachedWritableByte;
|
||||
[Affects=Nothing]
|
||||
attribute byte sideEffectFreeByte;
|
||||
[Affects=Nothing, DependsOn=DOMState]
|
||||
|
@ -160,8 +161,9 @@ interface TestJSImplInterface {
|
|||
void passNullableSelf(TestJSImplInterface? arg);
|
||||
attribute TestJSImplInterface nonNullSelf;
|
||||
attribute TestJSImplInterface? nullableSelf;
|
||||
[Cached, Pure]
|
||||
readonly attribute TestJSImplInterface cachedSelf;
|
||||
// [Cached] is not supported in JS-implemented WebIDL.
|
||||
//[Cached, Pure]
|
||||
//readonly attribute TestJSImplInterface cachedSelf;
|
||||
// Optional arguments
|
||||
void passOptionalSelf(optional TestJSImplInterface? arg);
|
||||
void passOptionalNonNullSelf(optional TestJSImplInterface arg);
|
||||
|
@ -230,16 +232,17 @@ interface TestJSImplInterface {
|
|||
void passConsequentialInterface(IndirectlyImplementedInterface arg);
|
||||
|
||||
// Sequence types
|
||||
[Cached, Pure]
|
||||
readonly attribute sequence<long> readonlySequence;
|
||||
[Cached, Pure]
|
||||
readonly attribute sequence<Dict> readonlySequenceOfDictionaries;
|
||||
[Cached, Pure]
|
||||
readonly attribute sequence<Dict>? readonlyNullableSequenceOfDictionaries;
|
||||
[Cached, Pure, Frozen]
|
||||
readonly attribute sequence<long> readonlyFrozenSequence;
|
||||
[Cached, Pure, Frozen]
|
||||
readonly attribute sequence<long>? readonlyFrozenNullableSequence;
|
||||
// [Cached] is not supported in JS-implemented WebIDL.
|
||||
//[Cached, Pure]
|
||||
//readonly attribute sequence<long> readonlySequence;
|
||||
//[Cached, Pure]
|
||||
//readonly attribute sequence<Dict> readonlySequenceOfDictionaries;
|
||||
//[Cached, Pure]
|
||||
//readonly attribute sequence<Dict>? readonlyNullableSequenceOfDictionaries;
|
||||
//[Cached, Pure, Frozen]
|
||||
//readonly attribute sequence<long> readonlyFrozenSequence;
|
||||
//[Cached, Pure, Frozen]
|
||||
//readonly attribute sequence<long>? readonlyFrozenNullableSequence;
|
||||
sequence<long> receiveSequence();
|
||||
sequence<long>? receiveNullableSequence();
|
||||
sequence<long?> receiveSequenceOfNullableInts();
|
||||
|
@ -602,18 +605,19 @@ interface TestJSImplInterface {
|
|||
|
||||
void passDictionary(optional Dict x);
|
||||
void passDictionary2(Dict x);
|
||||
[Cached, Pure]
|
||||
readonly attribute Dict readonlyDictionary;
|
||||
[Cached, Pure]
|
||||
readonly attribute Dict? readonlyNullableDictionary;
|
||||
[Cached, Pure]
|
||||
attribute Dict writableDictionary;
|
||||
[Cached, Pure, Frozen]
|
||||
readonly attribute Dict readonlyFrozenDictionary;
|
||||
[Cached, Pure, Frozen]
|
||||
readonly attribute Dict? readonlyFrozenNullableDictionary;
|
||||
[Cached, Pure, Frozen]
|
||||
attribute Dict writableFrozenDictionary;
|
||||
// [Cached] is not supported in JS-implemented WebIDL.
|
||||
//[Cached, Pure]
|
||||
//readonly attribute Dict readonlyDictionary;
|
||||
//[Cached, Pure]
|
||||
//readonly attribute Dict? readonlyNullableDictionary;
|
||||
//[Cached, Pure]
|
||||
//attribute Dict writableDictionary;
|
||||
//[Cached, Pure, Frozen]
|
||||
//readonly attribute Dict readonlyFrozenDictionary;
|
||||
//[Cached, Pure, Frozen]
|
||||
//readonly attribute Dict? readonlyFrozenNullableDictionary;
|
||||
//[Cached, Pure, Frozen]
|
||||
//attribute Dict writableFrozenDictionary;
|
||||
Dict receiveDictionary();
|
||||
Dict? receiveNullableDictionary();
|
||||
void passOtherDictionary(optional GrandparentDict x);
|
||||
|
@ -854,6 +858,7 @@ interface TestCImplementedInterface2 {
|
|||
[NoInterfaceObject,
|
||||
JSImplementation="@mozilla.org/test-js-impl-interface;2"]
|
||||
interface TestJSImplNoInterfaceObject {
|
||||
[Cached, Pure]
|
||||
readonly attribute byte cachedByte;
|
||||
// [Cached] is not supported in JS-implemented WebIDL.
|
||||
//[Cached, Pure]
|
||||
//readonly attribute byte cachedByte;
|
||||
};
|
||||
|
|
|
@ -48,15 +48,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1036214
|
|||
is(Object.getPrototypeOf(t), TestInterfaceJS.prototype, "Prototype setup works correctly");
|
||||
is(t.anyArg, any, "anyArg is correct");
|
||||
is(t.objectArg, obj, "objectArg is correct");
|
||||
is(t.dictionaryArg.anyMember, 42, "dictionaryArg looks correct");
|
||||
is(t.dictionaryArg.objectMember.answer, 42, "dictionaryArg looks correct");
|
||||
is(t.getDictionaryArg().anyMember, 42, "dictionaryArg looks correct");
|
||||
is(t.getDictionaryArg().objectMember.answer, 42, "dictionaryArg looks correct");
|
||||
t.anyAttr = 2;
|
||||
is(t.anyAttr, 2, "ping-pong any attribute works");
|
||||
t.objAttr = obj2;
|
||||
is(t.objAttr, obj2, "ping-pong object attribute works");
|
||||
t.dictionaryAttr = myDict;
|
||||
is(t.dictionaryAttr.anyMember, 42, "ping-pong dictionary attribute works");
|
||||
is(t.dictionaryAttr.objectMember.answer, 42, "ping-pong dictionary attribute works");
|
||||
t.setDictionaryAttr(myDict);
|
||||
is(t.getDictionaryAttr().anyMember, 42, "ping-pong dictionary works");
|
||||
is(t.getDictionaryAttr().objectMember.answer, 42, "ping-pong dictionary works");
|
||||
|
||||
is(any, t.pingPongAny(any), "ping-pong works with any");
|
||||
is(obj, t.pingPongObject(obj), "ping-pong works with obj");
|
||||
|
@ -88,8 +88,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1036214
|
|||
checkThrows(() => new TestInterfaceJS(undefined, undefined, { innerDictionary: { innerObject: xoObj } }), "inner dict param for constructor");
|
||||
checkThrows(() => t.anyAttr = xoObj, "anyAttr");
|
||||
checkThrows(() => t.objectAttr = xoObj, "objAttr");
|
||||
checkThrows(() => t.dictionaryAttr = { anyMember: xoObj }, "dictionaryAttr any");
|
||||
checkThrows(() => t.dictionaryAttr = { objectMember: xoObj }, "dictionaryAttr object");
|
||||
checkThrows(() => t.setDictionaryAttr({ anyMember: xoObj }), "dictionaryAttr any");
|
||||
checkThrows(() => t.setDictionaryAttr({ objectMember: xoObj }), "dictionaryAttr object");
|
||||
checkThrows(() => t.pingPongAny(xoObj), "pingpong any");
|
||||
checkThrows(() => t.pingPongObject(xoObj), "pingpong obj");
|
||||
checkThrows(() => t.pingPongObjectOrString(xoObj), "pingpong union");
|
||||
|
|
|
@ -15,10 +15,11 @@ dictionary TestInterfaceJSUnionableDictionary {
|
|||
interface TestInterfaceJS : EventTarget {
|
||||
readonly attribute any anyArg;
|
||||
readonly attribute object objectArg;
|
||||
[Cached, Pure] readonly attribute TestInterfaceJSDictionary dictionaryArg;
|
||||
TestInterfaceJSDictionary getDictionaryArg();
|
||||
attribute any anyAttr;
|
||||
attribute object objectAttr;
|
||||
[Cached, Pure] attribute TestInterfaceJSDictionary dictionaryAttr;
|
||||
TestInterfaceJSDictionary getDictionaryAttr();
|
||||
void setDictionaryAttr(optional TestInterfaceJSDictionary dict);
|
||||
any pingPongAny(any arg);
|
||||
object pingPongObject(object obj);
|
||||
any pingPongObjectOrString((object or DOMString) objOrString);
|
||||
|
|
Загрузка…
Ссылка в новой задаче