How to use IdlInterfaceMember method in wpt

Best JavaScript code snippet using wpt

idlharness.js

Source:idlharness.js Github

copy

Full Screen

...544 }.bind(this));545 }546 parsed_idl.members.forEach(function(member)547 {548 this.members[parsed_idl.name].members.push(new IdlInterfaceMember(member));549 }.bind(this));550 }.bind(this));551 this.partials = [];552 for (var lhs in this["implements"])553 {554 this.recursively_get_implements(lhs).forEach(function(rhs)555 {556 var errStr = lhs + " implements " + rhs + ", but ";557 if (!(lhs in this.members)) throw errStr + lhs + " is undefined.";558 if (!(this.members[lhs] instanceof IdlInterface)) throw errStr + lhs + " is not an interface.";559 if (!(rhs in this.members)) throw errStr + rhs + " is undefined.";560 if (!(this.members[rhs] instanceof IdlInterface)) throw errStr + rhs + " is not an interface.";561 this.members[rhs].members.forEach(function(member)562 {563 this.members[lhs].members.push(new IdlInterfaceMember(member));564 }.bind(this));565 }.bind(this));566 }567 this["implements"] = {};568 for (var lhs in this["includes"])569 {570 this.recursively_get_includes(lhs).forEach(function(rhs)571 {572 var errStr = lhs + " includes " + rhs + ", but ";573 if (!(lhs in this.members)) throw errStr + lhs + " is undefined.";574 if (!(this.members[lhs] instanceof IdlInterface)) throw errStr + lhs + " is not an interface.";575 if (!(rhs in this.members)) throw errStr + rhs + " is undefined.";576 if (!(this.members[rhs] instanceof IdlInterface)) throw errStr + rhs + " is not an interface.";577 this.members[rhs].members.forEach(function(member)578 {579 this.members[lhs].members.push(new IdlInterfaceMember(member));580 }.bind(this));581 }.bind(this));582 }583 this["includes"] = {};584 Object.getOwnPropertyNames(this.members).forEach(function(memberName) {585 var member = this.members[memberName];586 if (!(member instanceof IdlInterface)) {587 return;588 }589 var globals = exposure_set(member, ["Window"]);590 member.exposed = exposed_in(globals);591 member.exposureSet = globals;592 }.bind(this));593 // Now run test() on every member, and test_object() for every object.594 for (var name in this.members)595 {596 this.members[name].test();597 if (name in this.objects)598 {599 this.objects[name].forEach(function(str)600 {601 this.members[name].test_object(str);602 }.bind(this));603 }604 }605};606//@}607IdlArray.prototype.assert_type_is = function(value, type)608//@{609{610 if (type.idlType in this.members611 && this.members[type.idlType] instanceof IdlTypedef) {612 this.assert_type_is(value, this.members[type.idlType].idlType);613 return;614 }615 if (type.union) {616 for (var i = 0; i < type.idlType.length; i++) {617 try {618 this.assert_type_is(value, type.idlType[i]);619 // No AssertionError, so we match one type in the union620 return;621 } catch(e) {622 if (e instanceof AssertionError) {623 // We didn't match this type, let's try some others624 continue;625 }626 throw e;627 }628 }629 // TODO: Is there a nice way to list the union's types in the message?630 assert_true(false, "Attribute has value " + format_value(value)631 + " which doesn't match any of the types in the union");632 }633 /**634 * Helper function that tests that value is an instance of type according635 * to the rules of WebIDL. value is any JavaScript value, and type is an636 * object produced by WebIDLParser.js' "type" production. That production637 * is fairly elaborate due to the complexity of WebIDL's types, so it's638 * best to look at the grammar to figure out what properties it might have.639 */640 if (type.idlType == "any")641 {642 // No assertions to make643 return;644 }645 if (type.nullable && value === null)646 {647 // This is fine648 return;649 }650 if (type.array)651 {652 // TODO: not supported yet653 return;654 }655 if (type.sequence)656 {657 assert_true(Array.isArray(value), "should be an Array");658 if (!value.length)659 {660 // Nothing we can do.661 return;662 }663 this.assert_type_is(value[0], type.idlType);664 return;665 }666 if (type.generic === "Promise") {667 assert_true("then" in value, "Attribute with a Promise type should have a then property");668 // TODO: Ideally, we would check on project fulfillment669 // that we get the right type670 // but that would require making the type check async671 return;672 }673 if (type.generic === "FrozenArray") {674 assert_true(Array.isArray(value), "Value should be array");675 assert_true(Object.isFrozen(value), "Value should be frozen");676 if (!value.length)677 {678 // Nothing we can do.679 return;680 }681 this.assert_type_is(value[0], type.idlType);682 return;683 }684 type = type.idlType;685 switch(type)686 {687 case "void":688 assert_equals(value, undefined);689 return;690 case "boolean":691 assert_equals(typeof value, "boolean");692 return;693 case "byte":694 assert_equals(typeof value, "number");695 assert_equals(value, Math.floor(value), "should be an integer");696 assert_true(-128 <= value && value <= 127, "byte " + value + " should be in range [-128, 127]");697 return;698 case "octet":699 assert_equals(typeof value, "number");700 assert_equals(value, Math.floor(value), "should be an integer");701 assert_true(0 <= value && value <= 255, "octet " + value + " should be in range [0, 255]");702 return;703 case "short":704 assert_equals(typeof value, "number");705 assert_equals(value, Math.floor(value), "should be an integer");706 assert_true(-32768 <= value && value <= 32767, "short " + value + " should be in range [-32768, 32767]");707 return;708 case "unsigned short":709 assert_equals(typeof value, "number");710 assert_equals(value, Math.floor(value), "should be an integer");711 assert_true(0 <= value && value <= 65535, "unsigned short " + value + " should be in range [0, 65535]");712 return;713 case "long":714 assert_equals(typeof value, "number");715 assert_equals(value, Math.floor(value), "should be an integer");716 assert_true(-2147483648 <= value && value <= 2147483647, "long " + value + " should be in range [-2147483648, 2147483647]");717 return;718 case "unsigned long":719 assert_equals(typeof value, "number");720 assert_equals(value, Math.floor(value), "should be an integer");721 assert_true(0 <= value && value <= 4294967295, "unsigned long " + value + " should be in range [0, 4294967295]");722 return;723 case "long long":724 assert_equals(typeof value, "number");725 return;726 case "unsigned long long":727 case "DOMTimeStamp":728 assert_equals(typeof value, "number");729 assert_true(0 <= value, "unsigned long long should be positive");730 return;731 case "float":732 assert_equals(typeof value, "number");733 assert_equals(value, fround(value), "float rounded to 32-bit float should be itself");734 assert_not_equals(value, Infinity);735 assert_not_equals(value, -Infinity);736 assert_not_equals(value, NaN);737 return;738 case "DOMHighResTimeStamp":739 case "double":740 assert_equals(typeof value, "number");741 assert_not_equals(value, Infinity);742 assert_not_equals(value, -Infinity);743 assert_not_equals(value, NaN);744 return;745 case "unrestricted float":746 assert_equals(typeof value, "number");747 assert_equals(value, fround(value), "unrestricted float rounded to 32-bit float should be itself");748 return;749 case "unrestricted double":750 assert_equals(typeof value, "number");751 return;752 case "DOMString":753 assert_equals(typeof value, "string");754 return;755 case "ByteString":756 assert_equals(typeof value, "string");757 assert_regexp_match(value, /^[\x00-\x7F]*$/);758 return;759 case "USVString":760 assert_equals(typeof value, "string");761 assert_regexp_match(value, /^([\x00-\ud7ff\ue000-\uffff]|[\ud800-\udbff][\udc00-\udfff])*$/);762 return;763 case "object":764 assert_in_array(typeof value, ["object", "function"], "wrong type: not object or function");765 return;766 }767 if (!(type in this.members))768 {769 throw "Unrecognized type " + type;770 }771 if (this.members[type] instanceof IdlInterface)772 {773 // We don't want to run the full774 // IdlInterface.prototype.test_instance_of, because that could result775 // in an infinite loop. TODO: This means we don't have tests for776 // NoInterfaceObject interfaces, and we also can't test objects that777 // come from another self.778 assert_in_array(typeof value, ["object", "function"], "wrong type: not object or function");779 if (value instanceof Object780 && !this.members[type].has_extended_attribute("NoInterfaceObject")781 && type in self)782 {783 assert_true(value instanceof self[type], "instanceof " + type);784 }785 }786 else if (this.members[type] instanceof IdlEnum)787 {788 assert_equals(typeof value, "string");789 }790 else if (this.members[type] instanceof IdlDictionary)791 {792 // TODO: Test when we actually have something to test this on793 }794 else795 {796 throw "Type " + type + " isn't an interface or dictionary";797 }798};799//@}800/// IdlObject ///801function IdlObject() {}802IdlObject.prototype.test = function()803//@{804{805 /**806 * By default, this does nothing, so no actual tests are run for IdlObjects807 * that don't define any (e.g., IdlDictionary at the time of this writing).808 */809};810//@}811IdlObject.prototype.has_extended_attribute = function(name)812//@{813{814 /**815 * This is only meaningful for things that support extended attributes,816 * such as interfaces, exceptions, and members.817 */818 return this.extAttrs.some(function(o)819 {820 return o.name == name;821 });822};823//@}824/// IdlDictionary ///825// Used for IdlArray.prototype.assert_type_is826function IdlDictionary(obj)827//@{828{829 /**830 * obj is an object produced by the WebIDLParser.js "dictionary"831 * production.832 */833 /** Self-explanatory. */834 this.name = obj.name;835 /** A back-reference to our IdlArray. */836 this.array = obj.array;837 /** An array of objects produced by the "dictionaryMember" production. */838 this.members = obj.members;839 /**840 * The name (as a string) of the dictionary type we inherit from, or null841 * if there is none.842 */843 this.base = obj.inheritance;844}845//@}846IdlDictionary.prototype = Object.create(IdlObject.prototype);847IdlDictionary.prototype.get_inheritance_stack = function() {848 return IdlInterface.prototype.get_inheritance_stack.call(this);849};850/// IdlInterface ///851function IdlInterface(obj, is_callback, is_mixin)852//@{853{854 /**855 * obj is an object produced by the WebIDLParser.js "interface" production.856 */857 /** Self-explanatory. */858 this.name = obj.name;859 /** A back-reference to our IdlArray. */860 this.array = obj.array;861 /**862 * An indicator of whether we should run tests on the interface object and863 * interface prototype object. Tests on members are controlled by .untested864 * on each member, not this.865 */866 this.untested = obj.untested;867 /** An array of objects produced by the "ExtAttr" production. */868 this.extAttrs = obj.extAttrs;869 /** An array of IdlInterfaceMembers. */870 this.members = obj.members.map(function(m){return new IdlInterfaceMember(m); });871 if (this.has_extended_attribute("Unforgeable")) {872 this.members873 .filter(function(m) { return !m["static"] && (m.type == "attribute" || m.type == "operation"); })874 .forEach(function(m) { return m.isUnforgeable = true; });875 }876 /**877 * The name (as a string) of the type we inherit from, or null if there is878 * none.879 */880 this.base = obj.inheritance;881 this._is_callback = is_callback;882 this._is_mixin = is_mixin;883}884//@}885IdlInterface.prototype = Object.create(IdlObject.prototype);886IdlInterface.prototype.is_callback = function()887//@{888{889 return this._is_callback;890};891//@}892IdlInterface.prototype.is_mixin = function()893//@{894{895 return this._is_mixin;896};897//@}898IdlInterface.prototype.has_constants = function()899//@{900{901 return this.members.some(function(member) {902 return member.type === "const";903 });904};905//@}906IdlInterface.prototype.is_global = function()907//@{908{909 return this.extAttrs.some(function(attribute) {910 return attribute.name === "Global";911 });912};913//@}914IdlInterface.prototype.has_to_json_regular_operation = function() {915 return this.members.some(function(m) {916 return m.is_to_json_regular_operation();917 });918};919IdlInterface.prototype.has_default_to_json_regular_operation = function() {920 return this.members.some(function(m) {921 return m.is_to_json_regular_operation() && m.has_extended_attribute("Default");922 });923};924IdlInterface.prototype.get_inheritance_stack = function() {925 /**926 * See https://heycam.github.io/webidl/#create-an-inheritance-stack927 *928 * Returns an array of IdlInterface objects which contains itself929 * and all of its inherited interfaces.930 *931 * So given:932 *933 * A : B {};934 * B : C {};935 * C {};936 *937 * then A.get_inheritance_stack() should return [A, B, C],938 * and B.get_inheritance_stack() should return [B, C].939 *940 * Note: as dictionary inheritance is expressed identically by the AST,941 * this works just as well for getting a stack of inherited dictionaries.942 */943 var stack = [this];944 var idl_interface = this;945 while (idl_interface.base) {946 var base = this.array.members[idl_interface.base];947 if (!base) {948 throw new Error(idl_interface.type + " " + idl_interface.base + " not found (inherited by " + idl_interface.name + ")");949 }950 idl_interface = base;951 stack.push(idl_interface);952 }953 return stack;954};955/**956 * Implementation of957 * https://heycam.github.io/webidl/#default-tojson-operation958 * for testing purposes.959 *960 * Collects the IDL types of the attributes that meet the criteria961 * for inclusion in the default toJSON operation for easy962 * comparison with actual value963 */964IdlInterface.prototype.default_to_json_operation = function(callback) {965 var map = new Map(), isDefault = false;966 this.traverse_inherited_and_consequential_interfaces(function(I) {967 if (I.has_default_to_json_regular_operation()) {968 isDefault = true;969 I.members.forEach(function(m) {970 if (!m.static && m.type == "attribute" && I.array.is_json_type(m.idlType)) {971 map.set(m.name, m.idlType);972 }973 });974 } else if (I.has_to_json_regular_operation()) {975 isDefault = false;976 }977 });978 return isDefault ? map : null;979};980/**981 * Traverses inherited interfaces from the top down982 * and imeplemented interfaces inside out.983 * Invokes |callback| on each interface.984 *985 * This is an abstract implementation of the traversal986 * algorithm specified in:987 * https://heycam.github.io/webidl/#collect-attribute-values988 * Given the following inheritance tree:989 *990 * F991 * |992 * C E - I993 * | |994 * B - D995 * |996 * G - A - H - J997 *998 * Invoking traverse_inherited_and_consequential_interfaces() on A999 * would traverse the tree in the following order:1000 * C -> B -> F -> E -> I -> D -> A -> G -> H -> J1001 */1002IdlInterface.prototype.traverse_inherited_and_consequential_interfaces = function(callback) {1003 if (typeof callback != "function") {1004 throw new TypeError();1005 }1006 var stack = this.get_inheritance_stack();1007 _traverse_inherited_and_consequential_interfaces(stack, callback);1008};1009function _traverse_inherited_and_consequential_interfaces(stack, callback) {1010 var I = stack.pop();1011 callback(I);1012 var mixins = I.array["implements"][I.name] || I.array["includes"][I.name];1013 if (mixins) {1014 mixins.forEach(function(id) {1015 var mixin = I.array.members[id];1016 if (!mixin) {1017 throw new Error("Interface " + id + " not found (implemented by " + I.name + ")");1018 }1019 var interfaces = mixin.get_inheritance_stack();1020 _traverse_inherited_and_consequential_interfaces(interfaces, callback);1021 });1022 }1023 if (stack.length > 0) {1024 _traverse_inherited_and_consequential_interfaces(stack, callback);1025 }1026}1027IdlInterface.prototype.test = function()1028//@{1029{1030 if (this.has_extended_attribute("NoInterfaceObject") || this.is_mixin())1031 {1032 // No tests to do without an instance. TODO: We should still be able1033 // to run tests on the prototype object, if we obtain one through some1034 // other means.1035 return;1036 }1037 if (!this.exposed) {1038 test(function() {1039 assert_false(this.name in self);1040 }.bind(this), this.name + " interface: existence and properties of interface object");1041 return;1042 }1043 if (!this.untested)1044 {1045 // First test things to do with the exception/interface object and1046 // exception/interface prototype object.1047 this.test_self();1048 }1049 // Then test things to do with its members (constants, fields, attributes,1050 // operations, . . .). These are run even if .untested is true, because1051 // members might themselves be marked as .untested. This might happen to1052 // interfaces if the interface itself is untested but a partial interface1053 // that extends it is tested -- then the interface itself and its initial1054 // members will be marked as untested, but the members added by the partial1055 // interface are still tested.1056 this.test_members();1057};1058//@}1059IdlInterface.prototype.test_self = function()1060//@{1061{1062 test(function()1063 {1064 // This function tests WebIDL as of 2015-01-13.1065 // "For every interface that is exposed in a given ECMAScript global1066 // environment and:1067 // * is a callback interface that has constants declared on it, or1068 // * is a non-callback interface that is not declared with the1069 // [NoInterfaceObject] extended attribute,1070 // a corresponding property MUST exist on the ECMAScript global object.1071 // The name of the property is the identifier of the interface, and its1072 // value is an object called the interface object.1073 // The property has the attributes { [[Writable]]: true,1074 // [[Enumerable]]: false, [[Configurable]]: true }."1075 if (this.is_callback() && !this.has_constants()) {1076 return;1077 }1078 // TODO: Should we test here that the property is actually writable1079 // etc., or trust getOwnPropertyDescriptor?1080 assert_own_property(self, this.name,1081 "self does not have own property " + format_value(this.name));1082 var desc = Object.getOwnPropertyDescriptor(self, this.name);1083 assert_false("get" in desc, "self's property " + format_value(this.name) + " should not have a getter");1084 assert_false("set" in desc, "self's property " + format_value(this.name) + " should not have a setter");1085 assert_true(desc.writable, "self's property " + format_value(this.name) + " should be writable");1086 assert_false(desc.enumerable, "self's property " + format_value(this.name) + " should not be enumerable");1087 assert_true(desc.configurable, "self's property " + format_value(this.name) + " should be configurable");1088 if (this.is_callback()) {1089 // "The internal [[Prototype]] property of an interface object for1090 // a callback interface must be the Function.prototype object."1091 assert_equals(Object.getPrototypeOf(self[this.name]), Function.prototype,1092 "prototype of self's property " + format_value(this.name) + " is not Object.prototype");1093 return;1094 }1095 // "The interface object for a given non-callback interface is a1096 // function object."1097 // "If an object is defined to be a function object, then it has1098 // characteristics as follows:"1099 // Its [[Prototype]] internal property is otherwise specified (see1100 // below).1101 // "* Its [[Get]] internal property is set as described in ECMA-2621102 // section 9.1.8."1103 // Not much to test for this.1104 // "* Its [[Construct]] internal property is set as described in1105 // ECMA-262 section 19.2.2.3."1106 // Tested below if no constructor is defined. TODO: test constructors1107 // if defined.1108 // "* Its @@hasInstance property is set as described in ECMA-2621109 // section 19.2.3.8, unless otherwise specified."1110 // TODO1111 // ES6 (rev 30) 19.1.3.6:1112 // "Else, if O has a [[Call]] internal method, then let builtinTag be1113 // "Function"."1114 assert_class_string(self[this.name], "Function", "class string of " + this.name);1115 // "The [[Prototype]] internal property of an interface object for a1116 // non-callback interface is determined as follows:"1117 var prototype = Object.getPrototypeOf(self[this.name]);1118 if (this.base) {1119 // "* If the interface inherits from some other interface, the1120 // value of [[Prototype]] is the interface object for that other1121 // interface."1122 var has_interface_object =1123 !this.array1124 .members[this.base]1125 .has_extended_attribute("NoInterfaceObject");1126 if (has_interface_object) {1127 assert_own_property(self, this.base,1128 'should inherit from ' + this.base +1129 ', but self has no such property');1130 assert_equals(prototype, self[this.base],1131 'prototype of ' + this.name + ' is not ' +1132 this.base);1133 }1134 } else {1135 // "If the interface doesn't inherit from any other interface, the1136 // value of [[Prototype]] is %FunctionPrototype% ([ECMA-262],1137 // section 6.1.7.4)."1138 assert_equals(prototype, Function.prototype,1139 "prototype of self's property " + format_value(this.name) + " is not Function.prototype");1140 }1141 if (!this.has_extended_attribute("Constructor")) {1142 // "The internal [[Call]] method of the interface object behaves as1143 // follows . . .1144 //1145 // "If I was not declared with a [Constructor] extended attribute,1146 // then throw a TypeError."1147 assert_throws(new TypeError(), function() {1148 self[this.name]();1149 }.bind(this), "interface object didn't throw TypeError when called as a function");1150 assert_throws(new TypeError(), function() {1151 new self[this.name]();1152 }.bind(this), "interface object didn't throw TypeError when called as a constructor");1153 }1154 }.bind(this), this.name + " interface: existence and properties of interface object");1155 if (!this.is_callback()) {1156 test(function() {1157 // This function tests WebIDL as of 2014-10-25.1158 // https://heycam.github.io/webidl/#es-interface-call1159 assert_own_property(self, this.name,1160 "self does not have own property " + format_value(this.name));1161 // "Interface objects for non-callback interfaces MUST have a1162 // property named “length” with attributes { [[Writable]]: false,1163 // [[Enumerable]]: false, [[Configurable]]: true } whose value is1164 // a Number."1165 assert_own_property(self[this.name], "length");1166 var desc = Object.getOwnPropertyDescriptor(self[this.name], "length");1167 assert_false("get" in desc, this.name + ".length should not have a getter");1168 assert_false("set" in desc, this.name + ".length should not have a setter");1169 assert_false(desc.writable, this.name + ".length should not be writable");1170 assert_false(desc.enumerable, this.name + ".length should not be enumerable");1171 assert_true(desc.configurable, this.name + ".length should be configurable");1172 var constructors = this.extAttrs1173 .filter(function(attr) { return attr.name == "Constructor"; });1174 var expected_length = minOverloadLength(constructors);1175 assert_equals(self[this.name].length, expected_length, "wrong value for " + this.name + ".length");1176 }.bind(this), this.name + " interface object length");1177 }1178 if (!this.is_callback() || this.has_constants()) {1179 test(function() {1180 // This function tests WebIDL as of 2015-11-17.1181 // https://heycam.github.io/webidl/#interface-object1182 assert_own_property(self, this.name,1183 "self does not have own property " + format_value(this.name));1184 // "All interface objects must have a property named “name” with1185 // attributes { [[Writable]]: false, [[Enumerable]]: false,1186 // [[Configurable]]: true } whose value is the identifier of the1187 // corresponding interface."1188 assert_own_property(self[this.name], "name");1189 var desc = Object.getOwnPropertyDescriptor(self[this.name], "name");1190 assert_false("get" in desc, this.name + ".name should not have a getter");1191 assert_false("set" in desc, this.name + ".name should not have a setter");1192 assert_false(desc.writable, this.name + ".name should not be writable");1193 assert_false(desc.enumerable, this.name + ".name should not be enumerable");1194 assert_true(desc.configurable, this.name + ".name should be configurable");1195 assert_equals(self[this.name].name, this.name, "wrong value for " + this.name + ".name");1196 }.bind(this), this.name + " interface object name");1197 }1198 if (this.has_extended_attribute("LegacyWindowAlias")) {1199 test(function()1200 {1201 var aliasAttrs = this.extAttrs.filter(function(o) { return o.name === "LegacyWindowAlias"; });1202 if (aliasAttrs.length > 1) {1203 throw "Invalid IDL: multiple LegacyWindowAlias extended attributes on " + this.name;1204 }1205 if (this.is_callback()) {1206 throw "Invalid IDL: LegacyWindowAlias extended attribute on non-interface " + this.name;1207 }1208 if (this.exposureSet.indexOf("Window") === -1) {1209 throw "Invalid IDL: LegacyWindowAlias extended attribute on " + this.name + " which is not exposed in Window";1210 }1211 // TODO: when testing of [NoInterfaceObject] interfaces is supported,1212 // check that it's not specified together with LegacyWindowAlias.1213 // TODO: maybe check that [LegacyWindowAlias] is not specified on a partial interface.1214 var rhs = aliasAttrs[0].rhs;1215 if (!rhs) {1216 throw "Invalid IDL: LegacyWindowAlias extended attribute on " + this.name + " without identifier";1217 }1218 var aliases;1219 if (rhs.type === "identifier-list") {1220 aliases = rhs.value;1221 } else { // rhs.type === identifier1222 aliases = [ rhs.value ];1223 }1224 // OK now actually check the aliases...1225 var alias;1226 if (exposed_in(exposure_set(this, this.exposureSet)) && 'document' in self) {1227 for (alias of aliases) {1228 assert_true(alias in self, alias + " should exist");1229 assert_equals(self[alias], self[this.name], "self." + alias + " should be the same value as self." + this.name);1230 var desc = Object.getOwnPropertyDescriptor(self, alias);1231 assert_equals(desc.value, self[this.name], "wrong value in " + alias + " property descriptor");1232 assert_true(desc.writable, alias + " should be writable");1233 assert_false(desc.enumerable, alias + " should not be enumerable");1234 assert_true(desc.configurable, alias + " should be configurable");1235 assert_false('get' in desc, alias + " should not have a getter");1236 assert_false('set' in desc, alias + " should not have a setter");1237 }1238 } else {1239 for (alias of aliases) {1240 assert_false(alias in self, alias + " should not exist");1241 }1242 }1243 }.bind(this), this.name + " interface: legacy window alias");1244 }1245 // TODO: Test named constructors if I find any interfaces that have them.1246 test(function()1247 {1248 // This function tests WebIDL as of 2015-01-21.1249 // https://heycam.github.io/webidl/#interface-object1250 if (this.is_callback() && !this.has_constants()) {1251 return;1252 }1253 assert_own_property(self, this.name,1254 "self does not have own property " + format_value(this.name));1255 if (this.is_callback()) {1256 assert_false("prototype" in self[this.name],1257 this.name + ' should not have a "prototype" property');1258 return;1259 }1260 // "An interface object for a non-callback interface must have a1261 // property named “prototype” with attributes { [[Writable]]: false,1262 // [[Enumerable]]: false, [[Configurable]]: false } whose value is an1263 // object called the interface prototype object. This object has1264 // properties that correspond to the regular attributes and regular1265 // operations defined on the interface, and is described in more detail1266 // in section 4.5.4 below."1267 assert_own_property(self[this.name], "prototype",1268 'interface "' + this.name + '" does not have own property "prototype"');1269 var desc = Object.getOwnPropertyDescriptor(self[this.name], "prototype");1270 assert_false("get" in desc, this.name + ".prototype should not have a getter");1271 assert_false("set" in desc, this.name + ".prototype should not have a setter");1272 assert_false(desc.writable, this.name + ".prototype should not be writable");1273 assert_false(desc.enumerable, this.name + ".prototype should not be enumerable");1274 assert_false(desc.configurable, this.name + ".prototype should not be configurable");1275 // Next, test that the [[Prototype]] of the interface prototype object1276 // is correct. (This is made somewhat difficult by the existence of1277 // [NoInterfaceObject].)1278 // TODO: Aryeh thinks there's at least other place in this file where1279 // we try to figure out if an interface prototype object is1280 // correct. Consolidate that code.1281 // "The interface prototype object for a given interface A must have an1282 // internal [[Prototype]] property whose value is returned from the1283 // following steps:1284 // "If A is declared with the [Global] extended1285 // attribute, and A supports named properties, then return the named1286 // properties object for A, as defined in §3.6.4 Named properties1287 // object.1288 // "Otherwise, if A is declared to inherit from another interface, then1289 // return the interface prototype object for the inherited interface.1290 // "Otherwise, if A is declared with the [LegacyArrayClass] extended1291 // attribute, then return %ArrayPrototype%.1292 // "Otherwise, return %ObjectPrototype%.1293 //1294 // "In the ECMAScript binding, the DOMException type has some additional1295 // requirements:1296 //1297 // "Unlike normal interface types, the interface prototype object1298 // for DOMException must have as its [[Prototype]] the intrinsic1299 // object %ErrorPrototype%."1300 //1301 if (this.name === "Window") {1302 assert_class_string(Object.getPrototypeOf(self[this.name].prototype),1303 'WindowProperties',1304 'Class name for prototype of Window' +1305 '.prototype is not "WindowProperties"');1306 } else {1307 var inherit_interface, inherit_interface_has_interface_object;1308 if (this.base) {1309 inherit_interface = this.base;1310 inherit_interface_has_interface_object =1311 !this.array1312 .members[inherit_interface]1313 .has_extended_attribute("NoInterfaceObject");1314 } else if (this.has_extended_attribute('LegacyArrayClass')) {1315 inherit_interface = 'Array';1316 inherit_interface_has_interface_object = true;1317 } else if (this.name === "DOMException") {1318 inherit_interface = 'Error';1319 inherit_interface_has_interface_object = true;1320 } else {1321 inherit_interface = 'Object';1322 inherit_interface_has_interface_object = true;1323 }1324 if (inherit_interface_has_interface_object) {1325 assert_own_property(self, inherit_interface,1326 'should inherit from ' + inherit_interface + ', but self has no such property');1327 assert_own_property(self[inherit_interface], 'prototype',1328 'should inherit from ' + inherit_interface + ', but that object has no "prototype" property');1329 assert_equals(Object.getPrototypeOf(self[this.name].prototype),1330 self[inherit_interface].prototype,1331 'prototype of ' + this.name + '.prototype is not ' + inherit_interface + '.prototype');1332 } else {1333 // We can't test that we get the correct object, because this is the1334 // only way to get our hands on it. We only test that its class1335 // string, at least, is correct.1336 assert_class_string(Object.getPrototypeOf(self[this.name].prototype),1337 inherit_interface + 'Prototype',1338 'Class name for prototype of ' + this.name +1339 '.prototype is not "' + inherit_interface + 'Prototype"');1340 }1341 }1342 // "The class string of an interface prototype object is the1343 // concatenation of the interface’s identifier and the string1344 // “Prototype”."1345 // Skip these tests for now due to a specification issue about1346 // prototype name.1347 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=282441348 // assert_class_string(self[this.name].prototype, this.name + "Prototype",1349 // "class string of " + this.name + ".prototype");1350 // String() should end up calling {}.toString if nothing defines a1351 // stringifier.1352 if (!this.has_stringifier()) {1353 // assert_equals(String(self[this.name].prototype), "[object " + this.name + "Prototype]",1354 // "String(" + this.name + ".prototype)");1355 }1356 }.bind(this), this.name + " interface: existence and properties of interface prototype object");1357 // "If the interface is declared with the [Global]1358 // extended attribute, or the interface is in the set of inherited1359 // interfaces for any other interface that is declared with one of these1360 // attributes, then the interface prototype object must be an immutable1361 // prototype exotic object."1362 // https://heycam.github.io/webidl/#interface-prototype-object1363 if (this.is_global()) {1364 this.test_immutable_prototype("interface prototype object", self[this.name].prototype);1365 }1366 test(function()1367 {1368 if (this.is_callback() && !this.has_constants()) {1369 return;1370 }1371 assert_own_property(self, this.name,1372 "self does not have own property " + format_value(this.name));1373 if (this.is_callback()) {1374 assert_false("prototype" in self[this.name],1375 this.name + ' should not have a "prototype" property');1376 return;1377 }1378 assert_own_property(self[this.name], "prototype",1379 'interface "' + this.name + '" does not have own property "prototype"');1380 // "If the [NoInterfaceObject] extended attribute was not specified on1381 // the interface, then the interface prototype object must also have a1382 // property named “constructor” with attributes { [[Writable]]: true,1383 // [[Enumerable]]: false, [[Configurable]]: true } whose value is a1384 // reference to the interface object for the interface."1385 assert_own_property(self[this.name].prototype, "constructor",1386 this.name + '.prototype does not have own property "constructor"');1387 var desc = Object.getOwnPropertyDescriptor(self[this.name].prototype, "constructor");1388 assert_false("get" in desc, this.name + ".prototype.constructor should not have a getter");1389 assert_false("set" in desc, this.name + ".prototype.constructor should not have a setter");1390 assert_true(desc.writable, this.name + ".prototype.constructor should be writable");1391 assert_false(desc.enumerable, this.name + ".prototype.constructor should not be enumerable");1392 assert_true(desc.configurable, this.name + ".prototype.constructor should be configurable");1393 assert_equals(self[this.name].prototype.constructor, self[this.name],1394 this.name + '.prototype.constructor is not the same object as ' + this.name);1395 }.bind(this), this.name + ' interface: existence and properties of interface prototype object\'s "constructor" property');1396};1397//@}1398IdlInterface.prototype.test_immutable_prototype = function(type, obj)1399//@{1400{1401 if (typeof Object.setPrototypeOf !== "function") {1402 return;1403 }1404 test(function(t) {1405 var originalValue = Object.getPrototypeOf(obj);1406 var newValue = Object.create(null);1407 t.add_cleanup(function() {1408 try {1409 Object.setPrototypeOf(obj, originalValue);1410 } catch (err) {}1411 });1412 assert_throws(new TypeError(), function() {1413 Object.setPrototypeOf(obj, newValue);1414 });1415 assert_equals(1416 Object.getPrototypeOf(obj),1417 originalValue,1418 "original value not modified"1419 );1420 }.bind(this), this.name + " interface: internal [[SetPrototypeOf]] method " +1421 "of " + type + " - setting to a new value via Object.setPrototypeOf " +1422 "should throw a TypeError");1423 test(function(t) {1424 var originalValue = Object.getPrototypeOf(obj);1425 var newValue = Object.create(null);1426 t.add_cleanup(function() {1427 var setter = Object.getOwnPropertyDescriptor(1428 Object.prototype, '__proto__'1429 ).set;1430 try {1431 setter.call(obj, originalValue);1432 } catch (err) {}1433 });1434 assert_throws(new TypeError(), function() {1435 obj.__proto__ = newValue;1436 });1437 assert_equals(1438 Object.getPrototypeOf(obj),1439 originalValue,1440 "original value not modified"1441 );1442 }.bind(this), this.name + " interface: internal [[SetPrototypeOf]] method " +1443 "of " + type + " - setting to a new value via __proto__ " +1444 "should throw a TypeError");1445 test(function(t) {1446 var originalValue = Object.getPrototypeOf(obj);1447 var newValue = Object.create(null);1448 t.add_cleanup(function() {1449 try {1450 Reflect.setPrototypeOf(obj, originalValue);1451 } catch (err) {}1452 });1453 assert_false(Reflect.setPrototypeOf(obj, newValue));1454 assert_equals(1455 Object.getPrototypeOf(obj),1456 originalValue,1457 "original value not modified"1458 );1459 }.bind(this), this.name + " interface: internal [[SetPrototypeOf]] method " +1460 "of " + type + " - setting to a new value via Reflect.setPrototypeOf " +1461 "should return false");1462 test(function() {1463 var originalValue = Object.getPrototypeOf(obj);1464 Object.setPrototypeOf(obj, originalValue);1465 }.bind(this), this.name + " interface: internal [[SetPrototypeOf]] method " +1466 "of " + type + " - setting to its original value via Object.setPrototypeOf " +1467 "should not throw");1468 test(function() {1469 var originalValue = Object.getPrototypeOf(obj);1470 obj.__proto__ = originalValue;1471 }.bind(this), this.name + " interface: internal [[SetPrototypeOf]] method " +1472 "of " + type + " - setting to its original value via __proto__ " +1473 "should not throw");1474 test(function() {1475 var originalValue = Object.getPrototypeOf(obj);1476 assert_true(Reflect.setPrototypeOf(obj, originalValue));1477 }.bind(this), this.name + " interface: internal [[SetPrototypeOf]] method " +1478 "of " + type + " - setting to its original value via Reflect.setPrototypeOf " +1479 "should return true");1480};1481//@}1482IdlInterface.prototype.test_member_const = function(member)1483//@{1484{1485 if (!this.has_constants()) {1486 throw "Internal error: test_member_const called without any constants";1487 }1488 test(function()1489 {1490 assert_own_property(self, this.name,1491 "self does not have own property " + format_value(this.name));1492 // "For each constant defined on an interface A, there must be1493 // a corresponding property on the interface object, if it1494 // exists."1495 assert_own_property(self[this.name], member.name);1496 // "The value of the property is that which is obtained by1497 // converting the constant’s IDL value to an ECMAScript1498 // value."1499 assert_equals(self[this.name][member.name], constValue(member.value),1500 "property has wrong value");1501 // "The property has attributes { [[Writable]]: false,1502 // [[Enumerable]]: true, [[Configurable]]: false }."1503 var desc = Object.getOwnPropertyDescriptor(self[this.name], member.name);1504 assert_false("get" in desc, "property should not have a getter");1505 assert_false("set" in desc, "property should not have a setter");1506 assert_false(desc.writable, "property should not be writable");1507 assert_true(desc.enumerable, "property should be enumerable");1508 assert_false(desc.configurable, "property should not be configurable");1509 }.bind(this), this.name + " interface: constant " + member.name + " on interface object");1510 // "In addition, a property with the same characteristics must1511 // exist on the interface prototype object."1512 test(function()1513 {1514 assert_own_property(self, this.name,1515 "self does not have own property " + format_value(this.name));1516 if (this.is_callback()) {1517 assert_false("prototype" in self[this.name],1518 this.name + ' should not have a "prototype" property');1519 return;1520 }1521 assert_own_property(self[this.name], "prototype",1522 'interface "' + this.name + '" does not have own property "prototype"');1523 assert_own_property(self[this.name].prototype, member.name);1524 assert_equals(self[this.name].prototype[member.name], constValue(member.value),1525 "property has wrong value");1526 var desc = Object.getOwnPropertyDescriptor(self[this.name], member.name);1527 assert_false("get" in desc, "property should not have a getter");1528 assert_false("set" in desc, "property should not have a setter");1529 assert_false(desc.writable, "property should not be writable");1530 assert_true(desc.enumerable, "property should be enumerable");1531 assert_false(desc.configurable, "property should not be configurable");1532 }.bind(this), this.name + " interface: constant " + member.name + " on interface prototype object");1533};1534//@}1535IdlInterface.prototype.test_member_attribute = function(member)1536//@{1537 {1538 var a_test = async_test(this.name + " interface: attribute " + member.name);1539 a_test.step(function()1540 {1541 if (this.is_callback() && !this.has_constants()) {1542 a_test.done()1543 return;1544 }1545 assert_own_property(self, this.name,1546 "self does not have own property " + format_value(this.name));1547 assert_own_property(self[this.name], "prototype",1548 'interface "' + this.name + '" does not have own property "prototype"');1549 if (member["static"]) {1550 assert_own_property(self[this.name], member.name,1551 "The interface object must have a property " +1552 format_value(member.name));1553 a_test.done();1554 } else if (this.is_global()) {1555 assert_own_property(self, member.name,1556 "The global object must have a property " +1557 format_value(member.name));1558 assert_false(member.name in self[this.name].prototype,1559 "The prototype object should not have a property " +1560 format_value(member.name));1561 var getter = Object.getOwnPropertyDescriptor(self, member.name).get;1562 assert_equals(typeof(getter), "function",1563 format_value(member.name) + " must have a getter");1564 // Try/catch around the get here, since it can legitimately throw.1565 // If it does, we obviously can't check for equality with direct1566 // invocation of the getter.1567 var gotValue;1568 var propVal;1569 try {1570 propVal = self[member.name];1571 gotValue = true;1572 } catch (e) {1573 gotValue = false;1574 }1575 if (gotValue) {1576 assert_equals(propVal, getter.call(undefined),1577 "Gets on a global should not require an explicit this");1578 }1579 // do_interface_attribute_asserts must be the last thing we do,1580 // since it will call done() on a_test.1581 this.do_interface_attribute_asserts(self, member, a_test);1582 } else {1583 assert_true(member.name in self[this.name].prototype,1584 "The prototype object must have a property " +1585 format_value(member.name));1586 if (!member.has_extended_attribute("LenientThis")) {1587 if (member.idlType.generic !== "Promise") {1588 assert_throws(new TypeError(), function() {1589 self[this.name].prototype[member.name];1590 }.bind(this), "getting property on prototype object must throw TypeError");1591 // do_interface_attribute_asserts must be the last thing we1592 // do, since it will call done() on a_test.1593 this.do_interface_attribute_asserts(self[this.name].prototype, member, a_test);1594 } else {1595 promise_rejects(a_test, new TypeError(),1596 self[this.name].prototype[member.name])1597 .then(function() {1598 // do_interface_attribute_asserts must be the last1599 // thing we do, since it will call done() on a_test.1600 this.do_interface_attribute_asserts(self[this.name].prototype,1601 member, a_test);1602 }.bind(this));1603 }1604 } else {1605 assert_equals(self[this.name].prototype[member.name], undefined,1606 "getting property on prototype object must return undefined");1607 // do_interface_attribute_asserts must be the last thing we do,1608 // since it will call done() on a_test.1609 this.do_interface_attribute_asserts(self[this.name].prototype, member, a_test);1610 }1611 }1612 }.bind(this));1613};1614//@}1615IdlInterface.prototype.test_member_operation = function(member)1616//@{1617{1618 var a_test = async_test(this.name + " interface: operation " + member.name +1619 "(" + member.arguments.map(1620 function(m) {return m.idlType.idlType; } ).join(", ")1621 +")");1622 a_test.step(function()1623 {1624 // This function tests WebIDL as of 2015-12-29.1625 // https://heycam.github.io/webidl/#es-operations1626 if (this.is_callback() && !this.has_constants()) {1627 a_test.done();1628 return;1629 }1630 assert_own_property(self, this.name,1631 "self does not have own property " + format_value(this.name));1632 if (this.is_callback()) {1633 assert_false("prototype" in self[this.name],1634 this.name + ' should not have a "prototype" property');1635 a_test.done();1636 return;1637 }1638 assert_own_property(self[this.name], "prototype",1639 'interface "' + this.name + '" does not have own property "prototype"');1640 // "For each unique identifier of an exposed operation defined on the1641 // interface, there must exist a corresponding property, unless the1642 // effective overload set for that identifier and operation and with an1643 // argument count of 0 has no entries."1644 // TODO: Consider [Exposed].1645 // "The location of the property is determined as follows:"1646 var memberHolderObject;1647 // "* If the operation is static, then the property exists on the1648 // interface object."1649 if (member["static"]) {1650 assert_own_property(self[this.name], member.name,1651 "interface object missing static operation");1652 memberHolderObject = self[this.name];1653 // "* Otherwise, [...] if the interface was declared with the [Global]1654 // extended attribute, then the property exists1655 // on every object that implements the interface."1656 } else if (this.is_global()) {1657 assert_own_property(self, member.name,1658 "global object missing non-static operation");1659 memberHolderObject = self;1660 // "* Otherwise, the property exists solely on the interface’s1661 // interface prototype object."1662 } else {1663 assert_own_property(self[this.name].prototype, member.name,1664 "interface prototype object missing non-static operation");1665 memberHolderObject = self[this.name].prototype;1666 }1667 this.do_member_operation_asserts(memberHolderObject, member, a_test);1668 }.bind(this));1669};1670//@}1671IdlInterface.prototype.do_member_operation_asserts = function(memberHolderObject, member, a_test)1672//@{1673{1674 var done = a_test.done.bind(a_test);1675 var operationUnforgeable = member.isUnforgeable;1676 var desc = Object.getOwnPropertyDescriptor(memberHolderObject, member.name);1677 // "The property has attributes { [[Writable]]: B,1678 // [[Enumerable]]: true, [[Configurable]]: B }, where B is false if the1679 // operation is unforgeable on the interface, and true otherwise".1680 assert_false("get" in desc, "property should not have a getter");1681 assert_false("set" in desc, "property should not have a setter");1682 assert_equals(desc.writable, !operationUnforgeable,1683 "property should be writable if and only if not unforgeable");1684 assert_true(desc.enumerable, "property should be enumerable");1685 assert_equals(desc.configurable, !operationUnforgeable,1686 "property should be configurable if and only if not unforgeable");1687 // "The value of the property is a Function object whose1688 // behavior is as follows . . ."1689 assert_equals(typeof memberHolderObject[member.name], "function",1690 "property must be a function");1691 // "The value of the Function object’s “length” property is1692 // a Number determined as follows:1693 // ". . .1694 // "Return the length of the shortest argument list of the1695 // entries in S."1696 assert_equals(memberHolderObject[member.name].length,1697 minOverloadLength(this.members.filter(function(m) {1698 return m.type == "operation" && m.name == member.name;1699 })),1700 "property has wrong .length");1701 // Make some suitable arguments1702 var args = member.arguments.map(function(arg) {1703 return create_suitable_object(arg.idlType);1704 });1705 // "Let O be a value determined as follows:1706 // ". . .1707 // "Otherwise, throw a TypeError."1708 // This should be hit if the operation is not static, there is1709 // no [ImplicitThis] attribute, and the this value is null.1710 //1711 // TODO: We currently ignore the [ImplicitThis] case. Except we manually1712 // check for globals, since otherwise we'll invoke window.close(). And we1713 // have to skip this test for anything that on the proto chain of "self",1714 // since that does in fact have implicit-this behavior.1715 if (!member["static"]) {1716 var cb;1717 if (!this.is_global() &&1718 memberHolderObject[member.name] != self[member.name])1719 {1720 cb = awaitNCallbacks(2, done);1721 throwOrReject(a_test, member, memberHolderObject[member.name], null, args,1722 "calling operation with this = null didn't throw TypeError", cb);1723 } else {1724 cb = awaitNCallbacks(1, done);1725 }1726 // ". . . If O is not null and is also not a platform object1727 // that implements interface I, throw a TypeError."1728 //1729 // TODO: Test a platform object that implements some other1730 // interface. (Have to be sure to get inheritance right.)1731 throwOrReject(a_test, member, memberHolderObject[member.name], {}, args,1732 "calling operation with this = {} didn't throw TypeError", cb);1733 } else {1734 done();1735 }1736}1737//@}1738IdlInterface.prototype.add_iterable_members = function(member)1739//@{1740{1741 this.members.push(new IdlInterfaceMember(1742 { type: "operation", name: "entries", idlType: "iterator", arguments: []}));1743 this.members.push(new IdlInterfaceMember(1744 { type: "operation", name: "keys", idlType: "iterator", arguments: []}));1745 this.members.push(new IdlInterfaceMember(1746 { type: "operation", name: "values", idlType: "iterator", arguments: []}));1747 this.members.push(new IdlInterfaceMember(1748 { type: "operation", name: "forEach", idlType: "void",1749 arguments:1750 [{ name: "callback", idlType: {idlType: "function"}},1751 { name: "thisValue", idlType: {idlType: "any"}, optional: true}]}));1752};1753IdlInterface.prototype.test_to_json_operation = function(memberHolderObject, member) {1754 if (member.has_extended_attribute("Default")) {1755 var map = this.default_to_json_operation();1756 test(function() {1757 var json = memberHolderObject.toJSON();1758 map.forEach(function(type, k) {1759 assert_true(k in json, "property " + JSON.stringify(k) + " should be present in the output of " + this.name + ".prototype.toJSON()");1760 var descriptor = Object.getOwnPropertyDescriptor(json, k);1761 assert_true(descriptor.writable, "property " + k + " should be writable");1762 assert_true(descriptor.configurable, "property " + k + " should be configurable");1763 assert_true(descriptor.enumerable, "property " + k + " should be enumerable");1764 this.array.assert_type_is(json[k], type);1765 delete json[k];1766 }, this);1767 }.bind(this), "Test default toJSON operation of " + this.name);1768 } else {1769 test(function() {1770 assert_true(this.array.is_json_type(member.idlType), JSON.stringify(member.idlType) + " is not an appropriate return value for the toJSON operation of " + this.name);1771 this.array.assert_type_is(memberHolderObject.toJSON(), member.idlType);1772 }.bind(this), "Test toJSON operation of " + this.name);1773 }1774};1775//@}1776IdlInterface.prototype.test_member_iterable = function(member)1777//@{1778{1779 var interfaceName = this.name;1780 var isPairIterator = member.idlType instanceof Array;1781 test(function()1782 {1783 var descriptor = Object.getOwnPropertyDescriptor(self[interfaceName].prototype, Symbol.iterator);1784 assert_true(descriptor.writable, "property should be writable");1785 assert_true(descriptor.configurable, "property should be configurable");1786 assert_false(descriptor.enumerable, "property should not be enumerable");1787 assert_equals(self[interfaceName].prototype[Symbol.iterator].name, isPairIterator ? "entries" : "values", "@@iterator function does not have the right name");1788 }, "Testing Symbol.iterator property of iterable interface " + interfaceName);1789 if (isPairIterator) {1790 test(function() {1791 assert_equals(self[interfaceName].prototype[Symbol.iterator], self[interfaceName].prototype["entries"], "entries method is not the same as @@iterator");1792 }, "Testing pair iterable interface " + interfaceName);1793 } else {1794 test(function() {1795 ["entries", "keys", "values", "forEach", Symbol.Iterator].forEach(function(property) {1796 assert_equals(self[interfaceName].prototype[property], Array.prototype[property], property + " function is not the same as Array one");1797 });1798 }, "Testing value iterable interface " + interfaceName);1799 }1800};1801//@}1802IdlInterface.prototype.test_member_stringifier = function(member)1803//@{1804{1805 test(function()1806 {1807 if (this.is_callback() && !this.has_constants()) {1808 return;1809 }1810 assert_own_property(self, this.name,1811 "self does not have own property " + format_value(this.name));1812 if (this.is_callback()) {1813 assert_false("prototype" in self[this.name],1814 this.name + ' should not have a "prototype" property');1815 return;1816 }1817 assert_own_property(self[this.name], "prototype",1818 'interface "' + this.name + '" does not have own property "prototype"');1819 // ". . . the property exists on the interface prototype object."1820 var interfacePrototypeObject = self[this.name].prototype;1821 assert_own_property(self[this.name].prototype, "toString",1822 "interface prototype object missing non-static operation");1823 var stringifierUnforgeable = member.isUnforgeable;1824 var desc = Object.getOwnPropertyDescriptor(interfacePrototypeObject, "toString");1825 // "The property has attributes { [[Writable]]: B,1826 // [[Enumerable]]: true, [[Configurable]]: B }, where B is false if the1827 // stringifier is unforgeable on the interface, and true otherwise."1828 assert_false("get" in desc, "property should not have a getter");1829 assert_false("set" in desc, "property should not have a setter");1830 assert_equals(desc.writable, !stringifierUnforgeable,1831 "property should be writable if and only if not unforgeable");1832 assert_true(desc.enumerable, "property should be enumerable");1833 assert_equals(desc.configurable, !stringifierUnforgeable,1834 "property should be configurable if and only if not unforgeable");1835 // "The value of the property is a Function object, which behaves as1836 // follows . . ."1837 assert_equals(typeof interfacePrototypeObject.toString, "function",1838 "property must be a function");1839 // "The value of the Function object’s “length” property is the Number1840 // value 0."1841 assert_equals(interfacePrototypeObject.toString.length, 0,1842 "property has wrong .length");1843 // "Let O be the result of calling ToObject on the this value."1844 assert_throws(new TypeError(), function() {1845 self[this.name].prototype.toString.apply(null, []);1846 }, "calling stringifier with this = null didn't throw TypeError");1847 // "If O is not an object that implements the interface on which the1848 // stringifier was declared, then throw a TypeError."1849 //1850 // TODO: Test a platform object that implements some other1851 // interface. (Have to be sure to get inheritance right.)1852 assert_throws(new TypeError(), function() {1853 self[this.name].prototype.toString.apply({}, []);1854 }, "calling stringifier with this = {} didn't throw TypeError");1855 }.bind(this), this.name + " interface: stringifier");1856};1857//@}1858IdlInterface.prototype.test_members = function()1859//@{1860{1861 for (var i = 0; i < this.members.length; i++)1862 {1863 var member = this.members[i];1864 switch (member.type) {1865 case "iterable":1866 this.add_iterable_members(member);1867 break;1868 // TODO: add setlike and maplike handling.1869 default:1870 break;1871 }1872 }1873 for (var i = 0; i < this.members.length; i++)1874 {1875 var member = this.members[i];1876 if (member.untested) {1877 continue;1878 }1879 if (!exposed_in(exposure_set(member, this.exposureSet))) {1880 test(function() {1881 // It's not exposed, so we shouldn't find it anywhere.1882 assert_false(member.name in self[this.name],1883 "The interface object must not have a property " +1884 format_value(member.name));1885 assert_false(member.name in self[this.name].prototype,1886 "The prototype object must not have a property " +1887 format_value(member.name));1888 }.bind(this), this.name + " interface: member " + member.name);1889 continue;1890 }1891 switch (member.type) {1892 case "const":1893 this.test_member_const(member);1894 break;1895 case "attribute":1896 // For unforgeable attributes, we do the checks in1897 // test_interface_of instead.1898 if (!member.isUnforgeable)1899 {1900 this.test_member_attribute(member);1901 }1902 if (member.stringifier) {1903 this.test_member_stringifier(member);1904 }1905 break;1906 case "operation":1907 // TODO: Need to correctly handle multiple operations with the same1908 // identifier.1909 // For unforgeable operations, we do the checks in1910 // test_interface_of instead.1911 if (member.name) {1912 if (!member.isUnforgeable)1913 {1914 this.test_member_operation(member);1915 }1916 } else if (member.stringifier) {1917 this.test_member_stringifier(member);1918 }1919 break;1920 case "iterable":1921 this.test_member_iterable(member);1922 break;1923 default:1924 // TODO: check more member types.1925 break;1926 }1927 }1928};1929//@}1930IdlInterface.prototype.test_object = function(desc)1931//@{1932{1933 var obj, exception = null;1934 try1935 {1936 obj = eval(desc);1937 }1938 catch(e)1939 {1940 exception = e;1941 }1942 var expected_typeof =1943 this.members.some(function(member) { return member.legacycaller; })1944 ? "function"1945 : "object";1946 this.test_primary_interface_of(desc, obj, exception, expected_typeof);1947 var current_interface = this;1948 while (current_interface)1949 {1950 if (!(current_interface.name in this.array.members))1951 {1952 throw "Interface " + current_interface.name + " not found (inherited by " + this.name + ")";1953 }1954 if (current_interface.prevent_multiple_testing && current_interface.already_tested)1955 {1956 return;1957 }1958 current_interface.test_interface_of(desc, obj, exception, expected_typeof);1959 current_interface = this.array.members[current_interface.base];1960 }1961};1962//@}1963IdlInterface.prototype.test_primary_interface_of = function(desc, obj, exception, expected_typeof)1964//@{1965{1966 // Only the object itself, not its members, are tested here, so if the1967 // interface is untested, there is nothing to do.1968 if (this.untested)1969 {1970 return;1971 }1972 // "The internal [[SetPrototypeOf]] method of every platform object that1973 // implements an interface with the [Global] extended1974 // attribute must execute the same algorithm as is defined for the1975 // [[SetPrototypeOf]] internal method of an immutable prototype exotic1976 // object."1977 // https://heycam.github.io/webidl/#platform-object-setprototypeof1978 if (this.is_global())1979 {1980 this.test_immutable_prototype("global platform object", obj);1981 }1982 // We can't easily test that its prototype is correct if there's no1983 // interface object, or the object is from a different global environment1984 // (not instanceof Object). TODO: test in this case that its prototype at1985 // least looks correct, even if we can't test that it's actually correct.1986 if (!this.has_extended_attribute("NoInterfaceObject")1987 && (typeof obj != expected_typeof || obj instanceof Object))1988 {1989 test(function()1990 {1991 assert_equals(exception, null, "Unexpected exception when evaluating object");1992 assert_equals(typeof obj, expected_typeof, "wrong typeof object");1993 assert_own_property(self, this.name,1994 "self does not have own property " + format_value(this.name));1995 assert_own_property(self[this.name], "prototype",1996 'interface "' + this.name + '" does not have own property "prototype"');1997 // "The value of the internal [[Prototype]] property of the1998 // platform object is the interface prototype object of the primary1999 // interface from the platform object’s associated global2000 // environment."2001 assert_equals(Object.getPrototypeOf(obj),2002 self[this.name].prototype,2003 desc + "'s prototype is not " + this.name + ".prototype");2004 }.bind(this), this.name + " must be primary interface of " + desc);2005 }2006 // "The class string of a platform object that implements one or more2007 // interfaces must be the identifier of the primary interface of the2008 // platform object."2009 test(function()2010 {2011 assert_equals(exception, null, "Unexpected exception when evaluating object");2012 assert_equals(typeof obj, expected_typeof, "wrong typeof object");2013 assert_class_string(obj, this.name, "class string of " + desc);2014 if (!this.has_stringifier())2015 {2016 assert_equals(String(obj), "[object " + this.name + "]", "String(" + desc + ")");2017 }2018 }.bind(this), "Stringification of " + desc);2019};2020//@}2021IdlInterface.prototype.test_interface_of = function(desc, obj, exception, expected_typeof)2022//@{2023{2024 // TODO: Indexed and named properties, more checks on interface members2025 this.already_tested = true;2026 for (var i = 0; i < this.members.length; i++)2027 {2028 var member = this.members[i];2029 if (member.untested) {2030 continue;2031 }2032 if (!exposed_in(exposure_set(member, this.exposureSet))) {2033 test(function() {2034 assert_false(member.name in obj);2035 }.bind(this), this.name + "interface: " + desc + 'must not have property "' + member.name + '"');2036 continue;2037 }2038 if (member.type == "attribute" && member.isUnforgeable)2039 {2040 var a_test = async_test(this.name + " interface: " + desc + ' must have own property "' + member.name + '"');2041 a_test.step(function() {2042 assert_equals(exception, null, "Unexpected exception when evaluating object");2043 assert_equals(typeof obj, expected_typeof, "wrong typeof object");2044 // Call do_interface_attribute_asserts last, since it will call a_test.done()2045 this.do_interface_attribute_asserts(obj, member, a_test);2046 }.bind(this));2047 }2048 else if (member.type == "operation" &&2049 member.name &&2050 member.isUnforgeable)2051 {2052 var a_test = async_test(this.name + " interface: " + desc + ' must have own property "' + member.name + '"');2053 a_test.step(function()2054 {2055 assert_equals(exception, null, "Unexpected exception when evaluating object");2056 assert_equals(typeof obj, expected_typeof, "wrong typeof object");2057 assert_own_property(obj, member.name,2058 "Doesn't have the unforgeable operation property");2059 this.do_member_operation_asserts(obj, member, a_test);2060 }.bind(this));2061 }2062 else if ((member.type == "const"2063 || member.type == "attribute"2064 || member.type == "operation")2065 && member.name)2066 {2067 var described_name = member.name;2068 if (member.type == "operation")2069 {2070 described_name += "(" + member.arguments.map(arg => arg.idlType.idlType).join(", ") + ")";2071 }2072 test(function()2073 {2074 assert_equals(exception, null, "Unexpected exception when evaluating object");2075 assert_equals(typeof obj, expected_typeof, "wrong typeof object");2076 if (!member["static"]) {2077 if (!this.is_global()) {2078 assert_inherits(obj, member.name);2079 } else {2080 assert_own_property(obj, member.name);2081 }2082 if (member.type == "const")2083 {2084 assert_equals(obj[member.name], constValue(member.value));2085 }2086 if (member.type == "attribute")2087 {2088 // Attributes are accessor properties, so they might2089 // legitimately throw an exception rather than returning2090 // anything.2091 var property, thrown = false;2092 try2093 {2094 property = obj[member.name];2095 }2096 catch (e)2097 {2098 thrown = true;2099 }2100 if (!thrown)2101 {2102 this.array.assert_type_is(property, member.idlType);2103 }2104 }2105 if (member.type == "operation")2106 {2107 assert_equals(typeof obj[member.name], "function");2108 }2109 }2110 }.bind(this), this.name + " interface: " + desc + ' must inherit property "' + described_name + '" with the proper type');2111 }2112 // TODO: This is wrong if there are multiple operations with the same2113 // identifier.2114 // TODO: Test passing arguments of the wrong type.2115 if (member.type == "operation" && member.name && member.arguments.length)2116 {2117 var a_test = async_test( this.name + " interface: calling " + member.name +2118 "(" + member.arguments.map(function(m) { return m.idlType.idlType; }).join(", ") +2119 ") on " + desc + " with too few arguments must throw TypeError");2120 a_test.step(function()2121 {2122 assert_equals(exception, null, "Unexpected exception when evaluating object");2123 assert_equals(typeof obj, expected_typeof, "wrong typeof object");2124 var fn;2125 if (!member["static"]) {2126 if (!this.is_global() && !member.isUnforgeable) {2127 assert_inherits(obj, member.name);2128 } else {2129 assert_own_property(obj, member.name);2130 }2131 fn = obj[member.name];2132 }2133 else2134 {2135 assert_own_property(obj.constructor, member.name, "interface object must have static operation as own property");2136 fn = obj.constructor[member.name];2137 }2138 var minLength = minOverloadLength(this.members.filter(function(m) {2139 return m.type == "operation" && m.name == member.name;2140 }));2141 var args = [];2142 var cb = awaitNCallbacks(minLength, a_test.done.bind(a_test));2143 for (var i = 0; i < minLength; i++) {2144 throwOrReject(a_test, member, fn, obj, args, "Called with " + i + " arguments", cb);2145 args.push(create_suitable_object(member.arguments[i].idlType));2146 }2147 if (minLength === 0) {2148 cb();2149 }2150 }.bind(this));2151 }2152 if (member.is_to_json_regular_operation()) {2153 this.test_to_json_operation(obj, member);2154 }2155 }2156};2157//@}2158IdlInterface.prototype.has_stringifier = function()2159//@{2160{2161 if (this.name === "DOMException") {2162 // toString is inherited from Error, so don't assume we have the2163 // default stringifer2164 return true;2165 }2166 if (this.members.some(function(member) { return member.stringifier; })) {2167 return true;2168 }2169 if (this.base &&2170 this.array.members[this.base].has_stringifier()) {2171 return true;2172 }2173 return false;2174};2175//@}2176IdlInterface.prototype.do_interface_attribute_asserts = function(obj, member, a_test)2177//@{2178{2179 // This function tests WebIDL as of 2015-01-27.2180 // TODO: Consider [Exposed].2181 // This is called by test_member_attribute() with the prototype as obj if2182 // it is not a global, and the global otherwise, and by test_interface_of()2183 // with the object as obj.2184 var pendingPromises = [];2185 // "For each exposed attribute of the interface, whether it was declared on2186 // the interface itself or one of its consequential interfaces, there MUST2187 // exist a corresponding property. The characteristics of this property are2188 // as follows:"2189 // "The name of the property is the identifier of the attribute."2190 assert_own_property(obj, member.name);2191 // "The property has attributes { [[Get]]: G, [[Set]]: S, [[Enumerable]]:2192 // true, [[Configurable]]: configurable }, where:2193 // "configurable is false if the attribute was declared with the2194 // [Unforgeable] extended attribute and true otherwise;2195 // "G is the attribute getter, defined below; and2196 // "S is the attribute setter, also defined below."2197 var desc = Object.getOwnPropertyDescriptor(obj, member.name);2198 assert_false("value" in desc, 'property descriptor should not have a "value" field');2199 assert_false("writable" in desc, 'property descriptor should not have a "writable" field');2200 assert_true(desc.enumerable, "property should be enumerable");2201 if (member.isUnforgeable)2202 {2203 assert_false(desc.configurable, "[Unforgeable] property must not be configurable");2204 }2205 else2206 {2207 assert_true(desc.configurable, "property must be configurable");2208 }2209 // "The attribute getter is a Function object whose behavior when invoked2210 // is as follows:"2211 assert_equals(typeof desc.get, "function", "getter must be Function");2212 // "If the attribute is a regular attribute, then:"2213 if (!member["static"]) {2214 // "If O is not a platform object that implements I, then:2215 // "If the attribute was specified with the [LenientThis] extended2216 // attribute, then return undefined.2217 // "Otherwise, throw a TypeError."2218 if (!member.has_extended_attribute("LenientThis")) {2219 if (member.idlType.generic !== "Promise") {2220 assert_throws(new TypeError(), function() {2221 desc.get.call({});2222 }.bind(this), "calling getter on wrong object type must throw TypeError");2223 } else {2224 pendingPromises.push(2225 promise_rejects(a_test, new TypeError(), desc.get.call({}),2226 "calling getter on wrong object type must reject the return promise with TypeError"));2227 }2228 } else {2229 assert_equals(desc.get.call({}), undefined,2230 "calling getter on wrong object type must return undefined");2231 }2232 }2233 // "The value of the Function object’s “length” property is the Number2234 // value 0."2235 assert_equals(desc.get.length, 0, "getter length must be 0");2236 // TODO: Test calling setter on the interface prototype (should throw2237 // TypeError in most cases).2238 if (member.readonly2239 && !member.has_extended_attribute("LenientSetter")2240 && !member.has_extended_attribute("PutForwards")2241 && !member.has_extended_attribute("Replaceable"))2242 {2243 // "The attribute setter is undefined if the attribute is declared2244 // readonly and has neither a [PutForwards] nor a [Replaceable]2245 // extended attribute declared on it."2246 assert_equals(desc.set, undefined, "setter must be undefined for readonly attributes");2247 }2248 else2249 {2250 // "Otherwise, it is a Function object whose behavior when2251 // invoked is as follows:"2252 assert_equals(typeof desc.set, "function", "setter must be function for PutForwards, Replaceable, or non-readonly attributes");2253 // "If the attribute is a regular attribute, then:"2254 if (!member["static"]) {2255 // "If /validThis/ is false and the attribute was not specified2256 // with the [LenientThis] extended attribute, then throw a2257 // TypeError."2258 // "If the attribute is declared with a [Replaceable] extended2259 // attribute, then: ..."2260 // "If validThis is false, then return."2261 if (!member.has_extended_attribute("LenientThis")) {2262 assert_throws(new TypeError(), function() {2263 desc.set.call({});2264 }.bind(this), "calling setter on wrong object type must throw TypeError");2265 } else {2266 assert_equals(desc.set.call({}), undefined,2267 "calling setter on wrong object type must return undefined");2268 }2269 }2270 // "The value of the Function object’s “length” property is the Number2271 // value 1."2272 assert_equals(desc.set.length, 1, "setter length must be 1");2273 }2274 Promise.all(pendingPromises).then(a_test.done.bind(a_test));2275}2276//@}2277/// IdlInterfaceMember ///2278function IdlInterfaceMember(obj)2279//@{2280{2281 /**2282 * obj is an object produced by the WebIDLParser.js "ifMember" production.2283 * We just forward all properties to this object without modification,2284 * except for special extAttrs handling.2285 */2286 for (var k in obj)2287 {2288 this[k] = obj[k];2289 }2290 if (!("extAttrs" in this))2291 {2292 this.extAttrs = [];...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2var wptidl = require('./wptidl.js');3var idl = fs.readFileSync('test.idl', 'utf8');4var idlInterface = wptidl.parse(idl);5console.log(idlInterface.members);6interface Test {7 const unsigned long MAX = 100;8 const unsigned long MIN = 0;9 attribute DOMString name;10 void init();11 void init(DOMString name);12 void init(DOMString name, unsigned long value);13 void init(DOMString name, unsigned long value, boolean flag);14 unsigned long getValue();15 unsigned long getValue(DOMString name);16 unsigned long getValue(DOMString name, boolean flag);17 unsigned long getValue(DOMString name, unsigned long value);18 unsigned long getValue(DOMString name, unsigned long value, boolean flag);19 void setValue(unsigned long value);20 void setValue(DOMString name, unsigned long value);21 void setValue(DOMString name, unsigned long value, boolean flag);22 void setValue(DOMString name, unsigned long value, boolean flag, DOMString name2);23 void setValue(DOMString name, unsigned long value, boolean flag, DOMString name2, unsigned long value2);24 void setValue(DOMString name, unsigned long value, boolean flag, DOMString name2, unsigned long value2, boolean flag2);25 void setValue(DOMString name, unsigned long value, boolean flag, DOMString name2, unsigned long value2, boolean flag2, DOMString name3);26 void setValue(DOMString name, unsigned long value, boolean flag, DOMString name2, unsigned long value2, boolean flag2, DOMString name3, unsigned long value3);27 void setValue(DOMString name, unsigned long value, boolean flag, DOMString name2, unsigned long value2, boolean flag2, DOMString name3, unsigned long value3, boolean flag3);28 void setValue(DOMString name, unsigned long value, boolean flag, DOMString name2, unsigned long value2, boolean flag2, DOMString name3, unsigned long value3, boolean flag3, DOMString name4);29 void setValue(DOMString name, unsigned long value, boolean flag, DOMString name2, unsigned long value2, boolean flag2, DOMString name3, unsigned long value3, boolean flag

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2var wptidl = require('./wptidl.js');3var idl = fs.readFileSync('./test.idl', 'utf8');4var obj = wptidl.parse(idl);5console.log(obj);6console.log(obj.members[0].idlType);7console.log(obj.members[0].idlType.idlType);8console.log(obj.members[0].idlType.idlType.idlType);9console.log(obj.members[0].idlType.idlType.idlType.idlType);10console.log(obj.members[0].idlType.idlType.idlType.idlType.idlType);11console.log(obj.members[0].idlType.idlType.idlType.idlType.idlType.idlType);12console.log(obj.members[0].idlType.idlType.idlType.idlType.idlType.idlType.idlType);13console.log(obj.members[0].idlType.idlType.idlType.idlType.idlType.idlType.idlType.idlType);14console.log(obj.members[0].idlType.idlType.idlType.idlType.idlType.idlType.idlType.idlType.idlType);15console.log(obj.members[0].idlType.idlType.idlType.idlType.idlType.idlType.idlType.idlType.idlType.idlType);16console.log(obj.members[0].idlType.idlType.idlType.idlType.idlType.idlType.idlType.idlType.idlType.idlType.idlType);

Full Screen

Using AI Code Generation

copy

Full Screen

1idl_test(2 idl_array => {3 idl_array.add_objects({4 });5 }6);7The idl_test() method of the wpt idl_test is used to test the idl interface member. The wpt idl_test is imported using the script tag. The wpt idl_test accepts three arguments:8idl_test([dependencies], [options], callback)9The wpt idl_test is imported using the script tag. The wpt idl_test accepts three arguments:

Full Screen

Using AI Code Generation

copy

Full Screen

1wptext.IdlInterfaceMember("IdlInterfaceMember");2wptext.IdlInterfaceProperty = "IdlInterfaceProperty";3wptext.IdlInterfaceMethod("IdlInterfaceMethod");4wptext.addEventListener("IdlInterfaceEvent", IdlInterfaceEvent_Handler, false);5wptext.IdlInterfaceEvent();6wptext.addEventListener("IdlInterfaceEvent2", IdlInterfaceEvent2_Handler, false);7wptext.IdlInterfaceEvent2();8wptext.addEventListener("IdlInterfaceEvent3", IdlInterfaceEvent3_Handler, false);9wptext.IdlInterfaceEvent3();10wptext.addEventListener("IdlInterfaceEvent4", IdlInterfaceEvent4_Handler, false);11wptext.IdlInterfaceEvent4();12wptext.addEventListener("IdlInterfaceEvent5", IdlInterfaceEvent5_Handler, false);13wptext.IdlInterfaceEvent5();14wptext.addEventListener("IdlInterfaceEvent6", IdlInterfaceEvent6_Handler, false);15wptext.IdlInterfaceEvent6();16wptext.addEventListener("IdlInterfaceEvent7", IdlInterfaceEvent7_Handler, false);17wptext.IdlInterfaceEvent7();18wptext.addEventListener("IdlInterfaceEvent8", IdlInterfaceEvent8_Handler, false);19wptext.IdlInterfaceEvent8();20wptext.addEventListener("IdlInterfaceEvent9", IdlInterfaceEvent9_Handler, false);21wptext.IdlInterfaceEvent9();22wptext.addEventListener("IdlInterfaceEvent

Full Screen

Using AI Code Generation

copy

Full Screen

1var idl = require('./wptidl.js');2var fs = require('fs');3var assert = require('assert');4var idlFile = fs.readFileSync('test.idl', 'utf8');5var idlInterface = idl.parse(idlFile);6var idlInterfaceMember = idlInterface.members[0];7assert.equal(idlInterfaceMember.type, 'attribute');8assert.equal(idlInterfaceMember.idlType.idlType, 'DOMString');9assert.equal(idlInterfaceMember.idlType.nullable, false);10assert.equal(idlInterfaceMember.idlType.union, false);11assert.equal(idlInterfaceMember.idlType.generic, null);12assert.equal(idlInterfaceMember.idlType.array, false);13assert.equal(idlInterfaceMember.idlType.sequence, false);14assert.equal(idlInterfaceMember.idlType.idlType, 'DOMString');15assert.equal(idlInterfaceMember.idlType.nullable, false);16assert.equal(idlInterfaceMember.idlType.union, false);17assert.equal(idlInterfaceMember.idlType.generic, null);18assert.equal(idlInterfaceMember.idlType.array, false);19assert.equal(idlInterfaceMember.idlType.sequence, false);20assert.equal(idlInterfaceMember.extAttrs.length, 1);21assert.equal(idlInterfaceMember.extAttrs[0].name, 'TreatNullAs');22assert.equal(idlInterfaceMember.extAttrs[0].rhs.value, 'EmptyString');23assert.equal(idlInterfaceMember.extAttrs[0].rhs.type, 'string');24assert.equal(idlInterfaceMember.extAttrs[0].rhs.tokens.length, 1);25assert.equal(idlInterfaceMember.extAttrs[0].rhs.tokens[0].type, 'string');26assert.equal(idlInterfaceMember.extAttrs[0].rhs.tokens[0].value, 'EmptyString');27assert.equal(idlInterfaceMember.extAttrs[0].rhs.tokens[0].raw, '"EmptyString"');28assert.equal(idlInterfaceMember.extAttrs[0].rhs.tokens[0].escaped, 'EmptyString');29assert.equal(idlInterfaceMember.extAttrs[0].rhs.tokens[0].rawEscaped, '"EmptyString"');30assert.equal(idlInterfaceMember.extAttrs[0].rhs.tokens[0].line, 1);31assert.equal(idlInterfaceMember.extAttrs[0].rhs.tokens[0].column, 15);32assert.equal(idlInterfaceMember.extAttrs[0].rhs.tokens

Full Screen

Using AI Code Generation

copy

Full Screen

1var idlMember = new IdlInterfaceMember('long', 'testMember');2idlMember.type = 'long';3idlMember.name = 'testMember';4idlMember.extAttrs = [];5idlMember.extAttrs.push(new IdlExtAttr('Constructor'));6idlMember.extAttrs.push(new IdlExtAttr('TreatNonObjectAsNull'));7idlMember.extAttrs.push(new IdlExtAttr('TreatNonCallableAsNull'));8idlMember.extAttrs.push(new IdlExtAttr('PutForwards', 'test'));9idlMember.extAttrs.push(new IdlExtAttr('Replaceable'));10idlMember.extAttrs.push(new IdlExtAttr('LenientSetter'));11idlMember.extAttrs.push(new IdlExtAttr('LenientThis'));12idlMember.extAttrs.push(new IdlExtAttr('LenientThis', 'test'));13idlMember.extAttrs.push(new IdlExtAttr('Unforgeable'));14idlMember.extAttrs.push(new IdlExtAttr('Unforgeable', 'test'));15idlMember.extAttrs.push(new IdlExtAttr('NamedConstructor', 'test'));16idlMember.extAttrs.push(new IdlExtAttr('NamedConstructor', 'test', ['test', 'test1']));17idlMember.extAttrs.push(new IdlExtAttr('NamedConstructor', 'test', ['test', 'test1'], ['test', 'test1']));18idlMember.extAttrs.push(new IdlExtAttr('NamedConstructor', 'test', ['test', 'test1'], ['test', 'test1'], 'test'));19idlMember.extAttrs.push(new IdlExtAttr('NamedConstructor', 'test', ['test', 'test1'], ['test', 'test1'], 'test', 'test'));20idlMember.extAttrs.push(new IdlExtAttr('NamedConstructor', 'test', ['test', 'test1'], ['test', 'test1'], 'test', 'test', ['test', 'test1']));21idlMember.extAttrs.push(new IdlExtAttr('NamedConstructor', 'test', ['test', 'test1'], ['test', 'test1'], 'test', 'test', ['test', 'test1'], ['test', 'test1']));22idlMember.extAttrs.push(new IdlExtAttr('NamedConstructor', 'test', ['test', 'test1'], ['test', 'test1'], 'test', 'test', ['test', 'test1'], ['test', 'test1'], 'test'));23idlMember.extAttrs.push(new

Full Screen

Using AI Code Generation

copy

Full Screen

1function test() {2 var object = new Object();3 assert_throws(new TypeError(), function() {4 object.IdlInterfaceMember();5 });6}

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful