How to use minOverloadLength method in wpt

Best JavaScript code snippet using wpt

idlharness.js

Source:idlharness.js Github

copy

Full Screen

...5 if (cnt.type === "NaN") return NaN;6 if (cnt.type === "Infinity") return cnt.negative ? -Infinity : Infinity;7 return cnt.value;8}9function minOverloadLength(overloads) {10 if (!overloads.length) {11 return 0;12 }13 return overloads.map(function(attr) {14 return attr.arguments ? attr.arguments.filter(function(arg) {15 return !arg.optional && !arg.variadic;16 }).length : 0;17 })18 .reduce(function(m, n) { return Math.min(m, n); });19}20self.IdlArray = function()21{22 23 this.members = {};24 25 this.objects = {};26 27 this.partials = [];28 this["implements"] = {};29};30IdlArray.prototype.add_idls = function(raw_idls)31{32 33 this.internal_add_idls(WebIDL2.parse(raw_idls));34};35IdlArray.prototype.add_untested_idls = function(raw_idls)36{37 38 var parsed_idls = WebIDL2.parse(raw_idls);39 for (var i = 0; i < parsed_idls.length; i++)40 {41 parsed_idls[i].untested = true;42 if ("members" in parsed_idls[i])43 {44 for (var j = 0; j < parsed_idls[i].members.length; j++)45 {46 parsed_idls[i].members[j].untested = true;47 }48 }49 }50 this.internal_add_idls(parsed_idls);51};52IdlArray.prototype.internal_add_idls = function(parsed_idls)53{54 55 parsed_idls.forEach(function(parsed_idl)56 {57 if (parsed_idl.type == "interface" && parsed_idl.partial)58 {59 this.partials.push(parsed_idl);60 return;61 }62 if (parsed_idl.type == "implements")63 {64 if (!(parsed_idl.target in this["implements"]))65 {66 this["implements"][parsed_idl.target] = [];67 }68 this["implements"][parsed_idl.target].push(parsed_idl["implements"]);69 return;70 }71 parsed_idl.array = this;72 if (parsed_idl.name in this.members)73 {74 throw "Duplicate identifier " + parsed_idl.name;75 }76 switch(parsed_idl.type)77 {78 case "interface":79 this.members[parsed_idl.name] =80 new IdlInterface(parsed_idl, false);81 break;82 case "dictionary":83 84 85 this.members[parsed_idl.name] = new IdlDictionary(parsed_idl);86 break;87 case "typedef":88 this.members[parsed_idl.name] = new IdlTypedef(parsed_idl);89 break;90 case "callback":91 92 console.log("callback not yet supported");93 break;94 case "enum":95 this.members[parsed_idl.name] = new IdlEnum(parsed_idl);96 break;97 case "callback interface":98 this.members[parsed_idl.name] =99 new IdlInterface(parsed_idl, true);100 break;101 default:102 throw parsed_idl.name + ": " + parsed_idl.type + " not yet supported";103 }104 }.bind(this));105};106IdlArray.prototype.add_objects = function(dict)107{108 109 for (var k in dict)110 {111 if (k in this.objects)112 {113 this.objects[k] = this.objects[k].concat(dict[k]);114 }115 else116 {117 this.objects[k] = dict[k];118 }119 }120};121IdlArray.prototype.prevent_multiple_testing = function(name)122{123 124 this.members[name].prevent_multiple_testing = true;125};126IdlArray.prototype.recursively_get_implements = function(interface_name)127{128 129 var ret = this["implements"][interface_name];130 if (ret === undefined)131 {132 return [];133 }134 for (var i = 0; i < this["implements"][interface_name].length; i++)135 {136 ret = ret.concat(this.recursively_get_implements(ret[i]));137 if (ret.indexOf(ret[i]) != ret.lastIndexOf(ret[i]))138 {139 throw "Circular implements statements involving " + ret[i];140 }141 }142 return ret;143};144IdlArray.prototype.test = function()145{146 147 148 149 this.partials.forEach(function(parsed_idl)150 {151 if (!(parsed_idl.name in this.members)152 || !(this.members[parsed_idl.name] instanceof IdlInterface))153 {154 throw "Partial interface " + parsed_idl.name + " with no original interface";155 }156 if (parsed_idl.extAttrs)157 {158 parsed_idl.extAttrs.forEach(function(extAttr)159 {160 this.members[parsed_idl.name].extAttrs.push(extAttr);161 }.bind(this));162 }163 parsed_idl.members.forEach(function(member)164 {165 this.members[parsed_idl.name].members.push(new IdlInterfaceMember(member));166 }.bind(this));167 }.bind(this));168 this.partials = [];169 for (var lhs in this["implements"])170 {171 this.recursively_get_implements(lhs).forEach(function(rhs)172 {173 var errStr = lhs + " implements " + rhs + ", but ";174 if (!(lhs in this.members)) throw errStr + lhs + " is undefined.";175 if (!(this.members[lhs] instanceof IdlInterface)) throw errStr + lhs + " is not an interface.";176 if (!(rhs in this.members)) throw errStr + rhs + " is undefined.";177 if (!(this.members[rhs] instanceof IdlInterface)) throw errStr + rhs + " is not an interface.";178 this.members[rhs].members.forEach(function(member)179 {180 this.members[lhs].members.push(new IdlInterfaceMember(member));181 }.bind(this));182 }.bind(this));183 }184 this["implements"] = {};185 186 for (var name in this.members)187 {188 this.members[name].test();189 if (name in this.objects)190 {191 this.objects[name].forEach(function(str)192 {193 this.members[name].test_object(str);194 }.bind(this));195 }196 }197};198IdlArray.prototype.assert_type_is = function(value, type)199{200 201 if (type.idlType == "any")202 {203 204 return;205 }206 if (type.nullable && value === null)207 {208 209 return;210 }211 if (type.array)212 {213 214 return;215 }216 if (type.sequence)217 {218 assert_true(Array.isArray(value), "is not array");219 if (!value.length)220 {221 222 return;223 }224 this.assert_type_is(value[0], type.idlType.idlType);225 return;226 }227 type = type.idlType;228 switch(type)229 {230 case "void":231 assert_equals(value, undefined);232 return;233 case "boolean":234 assert_equals(typeof value, "boolean");235 return;236 case "byte":237 assert_equals(typeof value, "number");238 assert_equals(value, Math.floor(value), "not an integer");239 assert_true(-128 <= value && value <= 127, "byte " + value + " not in range [-128, 127]");240 return;241 case "octet":242 assert_equals(typeof value, "number");243 assert_equals(value, Math.floor(value), "not an integer");244 assert_true(0 <= value && value <= 255, "octet " + value + " not in range [0, 255]");245 return;246 case "short":247 assert_equals(typeof value, "number");248 assert_equals(value, Math.floor(value), "not an integer");249 assert_true(-32768 <= value && value <= 32767, "short " + value + " not in range [-32768, 32767]");250 return;251 case "unsigned short":252 assert_equals(typeof value, "number");253 assert_equals(value, Math.floor(value), "not an integer");254 assert_true(0 <= value && value <= 65535, "unsigned short " + value + " not in range [0, 65535]");255 return;256 case "long":257 assert_equals(typeof value, "number");258 assert_equals(value, Math.floor(value), "not an integer");259 assert_true(-2147483648 <= value && value <= 2147483647, "long " + value + " not in range [-2147483648, 2147483647]");260 return;261 case "unsigned long":262 assert_equals(typeof value, "number");263 assert_equals(value, Math.floor(value), "not an integer");264 assert_true(0 <= value && value <= 4294967295, "unsigned long " + value + " not in range [0, 4294967295]");265 return;266 case "long long":267 assert_equals(typeof value, "number");268 return;269 case "unsigned long long":270 case "DOMTimeStamp":271 assert_equals(typeof value, "number");272 assert_true(0 <= value, "unsigned long long is negative");273 return;274 case "float":275 case "double":276 case "DOMHighResTimeStamp":277 case "unrestricted float":278 case "unrestricted double":279 280 assert_equals(typeof value, "number");281 return;282 case "DOMString":283 case "ByteString":284 case "USVString":285 286 assert_equals(typeof value, "string");287 return;288 case "object":289 assert_true(typeof value == "object" || typeof value == "function", "wrong type: not object or function");290 return;291 }292 if (!(type in this.members))293 {294 throw "Unrecognized type " + type;295 }296 if (this.members[type] instanceof IdlInterface)297 {298 299 300 301 302 303 assert_true(typeof value == "object" || typeof value == "function", "wrong type: not object or function");304 if (value instanceof Object305 && !this.members[type].has_extended_attribute("NoInterfaceObject")306 && type in self)307 {308 assert_true(value instanceof self[type], "not instanceof " + type);309 }310 }311 else if (this.members[type] instanceof IdlEnum)312 {313 assert_equals(typeof value, "string");314 }315 else if (this.members[type] instanceof IdlDictionary)316 {317 318 }319 else if (this.members[type] instanceof IdlTypedef)320 {321 322 }323 else324 {325 throw "Type " + type + " isn't an interface or dictionary";326 }327};328function IdlObject() {}329IdlObject.prototype.test = function()330{331 332};333IdlObject.prototype.has_extended_attribute = function(name)334{335 336 return this.extAttrs.some(function(o)337 {338 return o.name == name;339 });340};341function IdlDictionary(obj)342{343 344 345 this.name = obj.name;346 347 this.members = obj.members;348 349 this.base = obj.inheritance;350}351IdlDictionary.prototype = Object.create(IdlObject.prototype);352function IdlInterface(obj, is_callback) {353 354 355 this.name = obj.name;356 357 this.array = obj.array;358 359 this.untested = obj.untested;360 361 this.extAttrs = obj.extAttrs;362 363 this.members = obj.members.map(function(m){return new IdlInterfaceMember(m); });364 if (this.has_extended_attribute("Unforgeable")) {365 this.members366 .filter(function(m) { return !m["static"] && (m.type == "attribute" || m.type == "operation"); })367 .forEach(function(m) { return m.isUnforgeable = true; });368 }369 370 this.base = obj.inheritance;371 this._is_callback = is_callback;372}373IdlInterface.prototype = Object.create(IdlObject.prototype);374IdlInterface.prototype.is_callback = function()375{376 return this._is_callback;377};378IdlInterface.prototype.has_constants = function()379{380 return this.members.some(function(member) {381 return member.type === "const";382 });383};384IdlInterface.prototype.is_global = function()385{386 return this.extAttrs.some(function(attribute) {387 return attribute.name === "Global" ||388 attribute.name === "PrimaryGlobal";389 });390};391IdlInterface.prototype.test = function()392{393 if (this.has_extended_attribute("NoInterfaceObject"))394 {395 396 397 398 return;399 }400 if (!this.untested)401 {402 403 404 this.test_self();405 }406 407 408 409 410 411 412 413 this.test_members();414};415IdlInterface.prototype.test_self = function()416{417 test(function()418 {419 420 421 422 423 424 425 426 427 428 429 430 431 if (this.is_callback() && !this.has_constants()) {432 return;433 }434 435 436 assert_own_property(self, this.name,437 "self does not have own property " + format_value(this.name));438 var desc = Object.getOwnPropertyDescriptor(self, this.name);439 assert_false("get" in desc, "self's property " + format_value(this.name) + " has getter");440 assert_false("set" in desc, "self's property " + format_value(this.name) + " has setter");441 assert_true(desc.writable, "self's property " + format_value(this.name) + " is not writable");442 assert_false(desc.enumerable, "self's property " + format_value(this.name) + " is enumerable");443 assert_true(desc.configurable, "self's property " + format_value(this.name) + " is not configurable");444 if (this.is_callback()) {445 446 447 assert_equals(Object.getPrototypeOf(self[this.name]), Object.prototype,448 "prototype of self's property " + format_value(this.name) + " is not Object.prototype");449 return;450 }451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 assert_class_string(self[this.name], "Function", "class string of " + this.name);471 472 473 var prototype = Object.getPrototypeOf(self[this.name]);474 if (this.base) {475 476 477 478 var has_interface_object =479 !this.array480 .members[this.base]481 .has_extended_attribute("NoInterfaceObject");482 if (has_interface_object) {483 assert_own_property(self, this.base,484 'should inherit from ' + this.base +485 ', but self has no such property');486 assert_equals(prototype, self[this.base],487 'prototype of ' + this.name + ' is not ' +488 this.base);489 }490 } else {491 492 493 494 assert_equals(prototype, Function.prototype,495 "prototype of self's property " + format_value(this.name) + " is not Function.prototype");496 }497 if (!this.has_extended_attribute("Constructor")) {498 499 500 501 502 503 assert_throws(new TypeError(), function() {504 self[this.name]();505 }.bind(this), "interface object didn't throw TypeError when called as a function");506 assert_throws(new TypeError(), function() {507 new self[this.name]();508 }.bind(this), "interface object didn't throw TypeError when called as a constructor");509 }510 }.bind(this), this.name + " interface: existence and properties of interface object");511 if (!this.is_callback()) {512 test(function() {513 514 515 assert_own_property(self, this.name,516 "self does not have own property " + format_value(this.name));517 518 519 520 521 assert_own_property(self[this.name], "length");522 var desc = Object.getOwnPropertyDescriptor(self[this.name], "length");523 assert_false("get" in desc, this.name + ".length has getter");524 assert_false("set" in desc, this.name + ".length has setter");525 assert_false(desc.writable, this.name + ".length is writable");526 assert_false(desc.enumerable, this.name + ".length is enumerable");527 assert_true(desc.configurable, this.name + ".length is not configurable");528 var constructors = this.extAttrs529 .filter(function(attr) { return attr.name == "Constructor"; });530 var expected_length = minOverloadLength(constructors);531 assert_equals(self[this.name].length, expected_length, "wrong value for " + this.name + ".length");532 }.bind(this), this.name + " interface object length");533 }534 535 test(function()536 {537 538 539 if (this.is_callback() && !this.has_constants()) {540 return;541 }542 assert_own_property(self, this.name,543 "self does not have own property " + format_value(this.name));544 if (this.is_callback()) {545 assert_false("prototype" in self[this.name],546 this.name + ' should not have a "prototype" property');547 return;548 }549 550 551 552 553 554 555 556 assert_own_property(self[this.name], "prototype",557 'interface "' + this.name + '" does not have own property "prototype"');558 var desc = Object.getOwnPropertyDescriptor(self[this.name], "prototype");559 assert_false("get" in desc, this.name + ".prototype has getter");560 assert_false("set" in desc, this.name + ".prototype has setter");561 assert_false(desc.writable, this.name + ".prototype is writable");562 assert_false(desc.enumerable, this.name + ".prototype is enumerable");563 assert_false(desc.configurable, this.name + ".prototype is configurable");564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 if (this.name === "Window") {584 assert_class_string(Object.getPrototypeOf(self[this.name].prototype),585 'WindowProperties',586 'Class name for prototype of Window' +587 '.prototype is not "WindowProperties"');588 } else {589 var inherit_interface, inherit_interface_has_interface_object;590 if (this.base) {591 inherit_interface = this.base;592 inherit_interface_has_interface_object =593 !this.array594 .members[inherit_interface]595 .has_extended_attribute("NoInterfaceObject");596 } else if (this.has_extended_attribute('ArrayClass')) {597 inherit_interface = 'Array';598 inherit_interface_has_interface_object = true;599 } else {600 inherit_interface = 'Object';601 inherit_interface_has_interface_object = true;602 }603 if (inherit_interface_has_interface_object) {604 assert_own_property(self, inherit_interface,605 'should inherit from ' + inherit_interface + ', but self has no such property');606 assert_own_property(self[inherit_interface], 'prototype',607 'should inherit from ' + inherit_interface + ', but that object has no "prototype" property');608 assert_equals(Object.getPrototypeOf(self[this.name].prototype),609 self[inherit_interface].prototype,610 'prototype of ' + this.name + '.prototype is not ' + inherit_interface + '.prototype');611 } else {612 613 614 615 assert_class_string(Object.getPrototypeOf(self[this.name].prototype),616 inherit_interface + 'Prototype',617 'Class name for prototype of ' + this.name +618 '.prototype is not "' + inherit_interface + 'Prototype"');619 }620 }621 622 623 624 assert_class_string(self[this.name].prototype, this.name + "Prototype",625 "class string of " + this.name + ".prototype");626 627 628 if (!this.has_stringifier()) {629 assert_equals(String(self[this.name].prototype), "[object " + this.name + "Prototype]",630 "String(" + this.name + ".prototype)");631 }632 }.bind(this), this.name + " interface: existence and properties of interface prototype object");633 test(function()634 {635 if (this.is_callback() && !this.has_constants()) {636 return;637 }638 assert_own_property(self, this.name,639 "self does not have own property " + format_value(this.name));640 if (this.is_callback()) {641 assert_false("prototype" in self[this.name],642 this.name + ' should not have a "prototype" property');643 return;644 }645 assert_own_property(self[this.name], "prototype",646 'interface "' + this.name + '" does not have own property "prototype"');647 648 649 650 651 652 assert_own_property(self[this.name].prototype, "constructor",653 this.name + '.prototype does not have own property "constructor"');654 var desc = Object.getOwnPropertyDescriptor(self[this.name].prototype, "constructor");655 assert_false("get" in desc, this.name + ".prototype.constructor has getter");656 assert_false("set" in desc, this.name + ".prototype.constructor has setter");657 assert_true(desc.writable, this.name + ".prototype.constructor is not writable");658 assert_false(desc.enumerable, this.name + ".prototype.constructor is enumerable");659 assert_true(desc.configurable, this.name + ".prototype.constructor in not configurable");660 assert_equals(self[this.name].prototype.constructor, self[this.name],661 this.name + '.prototype.constructor is not the same object as ' + this.name);662 }.bind(this), this.name + ' interface: existence and properties of interface prototype object\'s "constructor" property');663};664IdlInterface.prototype.test_member_const = function(member)665{666 test(function()667 {668 if (this.is_callback() && !this.has_constants()) {669 return;670 }671 assert_own_property(self, this.name,672 "self does not have own property " + format_value(this.name));673 674 675 676 assert_own_property(self[this.name], member.name);677 678 679 680 assert_equals(self[this.name][member.name], constValue(member.value),681 "property has wrong value");682 683 684 var desc = Object.getOwnPropertyDescriptor(self[this.name], member.name);685 assert_false("get" in desc, "property has getter");686 assert_false("set" in desc, "property has setter");687 assert_false(desc.writable, "property is writable");688 assert_true(desc.enumerable, "property is not enumerable");689 assert_false(desc.configurable, "property is configurable");690 }.bind(this), this.name + " interface: constant " + member.name + " on interface object");691 692 693 test(function()694 {695 if (this.is_callback() && !this.has_constants()) {696 return;697 }698 assert_own_property(self, this.name,699 "self does not have own property " + format_value(this.name));700 if (this.is_callback()) {701 assert_false("prototype" in self[this.name],702 this.name + ' should not have a "prototype" property');703 return;704 }705 assert_own_property(self[this.name], "prototype",706 'interface "' + this.name + '" does not have own property "prototype"');707 assert_own_property(self[this.name].prototype, member.name);708 assert_equals(self[this.name].prototype[member.name], constValue(member.value),709 "property has wrong value");710 var desc = Object.getOwnPropertyDescriptor(self[this.name], member.name);711 assert_false("get" in desc, "property has getter");712 assert_false("set" in desc, "property has setter");713 assert_false(desc.writable, "property is writable");714 assert_true(desc.enumerable, "property is not enumerable");715 assert_false(desc.configurable, "property is configurable");716 }.bind(this), this.name + " interface: constant " + member.name + " on interface prototype object");717};718IdlInterface.prototype.test_member_attribute = function(member)719{720 test(function()721 {722 if (this.is_callback() && !this.has_constants()) {723 return;724 }725 assert_own_property(self, this.name,726 "self does not have own property " + format_value(this.name));727 assert_own_property(self[this.name], "prototype",728 'interface "' + this.name + '" does not have own property "prototype"');729 if (member["static"]) {730 assert_own_property(self[this.name], member.name,731 "The interface object must have a property " +732 format_value(member.name));733 } else if (this.is_global()) {734 assert_own_property(self, member.name,735 "The global object must have a property " +736 format_value(member.name));737 assert_false(member.name in self[this.name].prototype,738 "The prototype object must not have a property " +739 format_value(member.name));740 741 742 743 var gotValue;744 var propVal;745 try {746 propVal = self[member.name];747 gotValue = true;748 } catch (e) {749 gotValue = false;750 }751 if (gotValue) {752 var getter = Object.getOwnPropertyDescriptor(self, member.name).get;753 assert_equals(typeof(getter), "function",754 format_value(member.name) + " must have a getter");755 assert_equals(propVal, getter.call(undefined),756 "Gets on a global should not require an explicit this");757 }758 this.do_interface_attribute_asserts(self, member);759 } else {760 assert_true(member.name in self[this.name].prototype,761 "The prototype object must have a property " +762 format_value(member.name));763 if (!member.has_extended_attribute("LenientThis")) {764 assert_throws(new TypeError(), function() {765 self[this.name].prototype[member.name];766 }.bind(this), "getting property on prototype object must throw TypeError");767 } else {768 assert_equals(self[this.name].prototype[member.name], undefined,769 "getting property on prototype object must return undefined");770 }771 this.do_interface_attribute_asserts(self[this.name].prototype, member);772 }773 }.bind(this), this.name + " interface: attribute " + member.name);774};775IdlInterface.prototype.test_member_operation = function(member)776{777 test(function()778 {779 if (this.is_callback() && !this.has_constants()) {780 return;781 }782 assert_own_property(self, this.name,783 "self does not have own property " + format_value(this.name));784 if (this.is_callback()) {785 assert_false("prototype" in self[this.name],786 this.name + ' should not have a "prototype" property');787 return;788 }789 assert_own_property(self[this.name], "prototype",790 'interface "' + this.name + '" does not have own property "prototype"');791 792 793 794 795 796 797 798 799 var memberHolderObject;800 if (member["static"]) {801 assert_own_property(self[this.name], member.name,802 "interface object missing static operation");803 memberHolderObject = self[this.name];804 } else if (this.is_global()) {805 assert_own_property(self, member.name,806 "global object missing non-static operation");807 memberHolderObject = self;808 } else {809 assert_own_property(self[this.name].prototype, member.name,810 "interface prototype object missing non-static operation");811 memberHolderObject = self[this.name].prototype;812 }813 this.do_member_operation_asserts(memberHolderObject, member);814 }.bind(this), this.name + " interface: operation " + member.name +815 "(" + member.arguments.map(function(m) { return m.idlType.idlType; }) +816 ")");817};818IdlInterface.prototype.do_member_operation_asserts = function(memberHolderObject, member)819{820 var operationUnforgeable = member.isUnforgeable;821 var desc = Object.getOwnPropertyDescriptor(memberHolderObject, member.name);822 823 824 825 assert_false("get" in desc, "property has getter");826 assert_false("set" in desc, "property has setter");827 assert_equals(desc.writable, !operationUnforgeable,828 "property should be writable if and only if not unforgeable");829 assert_true(desc.enumerable, "property is not enumerable");830 assert_equals(desc.configurable, !operationUnforgeable,831 "property should be configurable if and only if not unforgeable");832 833 834 assert_equals(typeof memberHolderObject[member.name], "function",835 "property must be a function");836 837 838 839 840 841 assert_equals(memberHolderObject[member.name].length,842 minOverloadLength(this.members.filter(function(m) {843 return m.type == "operation" && m.name == member.name;844 })),845 "property has wrong .length");846 847 var args = member.arguments.map(function(arg) {848 return create_suitable_object(arg.idlType);849 });850 851 852 853 854 855 856 857 858 859 860 if (!member["static"]) {861 if (!this.is_global() &&862 memberHolderObject[member.name] != self[member.name])863 {864 assert_throws(new TypeError(), function() {865 memberHolderObject[member.name].apply(null, args);866 }, "calling operation with this = null didn't throw TypeError");867 }868 869 870 871 872 873 assert_throws(new TypeError(), function() {874 memberHolderObject[member.name].apply({}, args);875 }, "calling operation with this = {} didn't throw TypeError");876 }877}878IdlInterface.prototype.test_member_stringifier = function(member)879{880 test(function()881 {882 if (this.is_callback() && !this.has_constants()) {883 return;884 }885 assert_own_property(self, this.name,886 "self does not have own property " + format_value(this.name));887 if (this.is_callback()) {888 assert_false("prototype" in self[this.name],889 this.name + ' should not have a "prototype" property');890 return;891 }892 assert_own_property(self[this.name], "prototype",893 'interface "' + this.name + '" does not have own property "prototype"');894 895 var interfacePrototypeObject = self[this.name].prototype;896 assert_own_property(self[this.name].prototype, "toString",897 "interface prototype object missing non-static operation");898 var stringifierUnforgeable = member.isUnforgeable;899 var desc = Object.getOwnPropertyDescriptor(interfacePrototypeObject, "toString");900 901 902 903 assert_false("get" in desc, "property has getter");904 assert_false("set" in desc, "property has setter");905 assert_equals(desc.writable, !stringifierUnforgeable,906 "property should be writable if and only if not unforgeable");907 assert_true(desc.enumerable, "property is not enumerable");908 assert_equals(desc.configurable, !stringifierUnforgeable,909 "property should be configurable if and only if not unforgeable");910 911 912 assert_equals(typeof interfacePrototypeObject.toString, "function",913 "property must be a function");914 915 916 assert_equals(interfacePrototypeObject.toString.length, 0,917 "property has wrong .length");918 919 assert_throws(new TypeError(), function() {920 self[this.name].prototype.toString.apply(null, []);921 }, "calling stringifier with this = null didn't throw TypeError");922 923 924 925 926 927 assert_throws(new TypeError(), function() {928 self[this.name].prototype.toString.apply({}, []);929 }, "calling stringifier with this = {} didn't throw TypeError");930 }.bind(this), this.name + " interface: stringifier");931};932IdlInterface.prototype.test_members = function()933{934 for (var i = 0; i < this.members.length; i++)935 {936 var member = this.members[i];937 if (member.untested) {938 continue;939 }940 switch (member.type) {941 case "const":942 this.test_member_const(member);943 break;944 case "attribute":945 946 947 if (!member.isUnforgeable)948 {949 this.test_member_attribute(member);950 }951 break;952 case "operation":953 954 955 956 957 if (member.name) {958 if (!member.isUnforgeable)959 {960 this.test_member_operation(member);961 }962 } else if (member.stringifier) {963 this.test_member_stringifier(member);964 }965 break;966 default:967 968 break;969 }970 }971};972IdlInterface.prototype.test_object = function(desc)973{974 var obj, exception = null;975 try976 {977 obj = eval(desc);978 }979 catch(e)980 {981 exception = e;982 }983 984 985 var expected_typeof = this.members.some(function(member)986 {987 return member.legacycaller988 || ("idlType" in member && member.idlType.legacycaller)989 || ("idlType" in member && typeof member.idlType == "object"990 && "idlType" in member.idlType && member.idlType.idlType == "legacycaller");991 }) ? "function" : "object";992 this.test_primary_interface_of(desc, obj, exception, expected_typeof);993 var current_interface = this;994 while (current_interface)995 {996 if (!(current_interface.name in this.array.members))997 {998 throw "Interface " + current_interface.name + " not found (inherited by " + this.name + ")";999 }1000 if (current_interface.prevent_multiple_testing && current_interface.already_tested)1001 {1002 return;1003 }1004 current_interface.test_interface_of(desc, obj, exception, expected_typeof);1005 current_interface = this.array.members[current_interface.base];1006 }1007};1008IdlInterface.prototype.test_primary_interface_of = function(desc, obj, exception, expected_typeof)1009{1010 1011 1012 1013 1014 if (!this.has_extended_attribute("NoInterfaceObject")1015 && (typeof obj != expected_typeof || obj instanceof Object))1016 {1017 test(function()1018 {1019 assert_equals(exception, null, "Unexpected exception when evaluating object");1020 assert_equals(typeof obj, expected_typeof, "wrong typeof object");1021 assert_own_property(self, this.name,1022 "self does not have own property " + format_value(this.name));1023 assert_own_property(self[this.name], "prototype",1024 'interface "' + this.name + '" does not have own property "prototype"');1025 1026 1027 1028 1029 assert_equals(Object.getPrototypeOf(obj),1030 self[this.name].prototype,1031 desc + "'s prototype is not " + this.name + ".prototype");1032 }.bind(this), this.name + " must be primary interface of " + desc);1033 }1034 1035 1036 1037 test(function()1038 {1039 assert_equals(exception, null, "Unexpected exception when evaluating object");1040 assert_equals(typeof obj, expected_typeof, "wrong typeof object");1041 assert_class_string(obj, this.name, "class string of " + desc);1042 if (!this.has_stringifier())1043 {1044 assert_equals(String(obj), "[object " + this.name + "]", "String(" + desc + ")");1045 }1046 }.bind(this), "Stringification of " + desc);1047};1048IdlInterface.prototype.test_interface_of = function(desc, obj, exception, expected_typeof)1049{1050 1051 this.already_tested = true;1052 for (var i = 0; i < this.members.length; i++)1053 {1054 var member = this.members[i];1055 if (member.type == "attribute" && member.isUnforgeable)1056 {1057 test(function()1058 {1059 assert_equals(exception, null, "Unexpected exception when evaluating object");1060 assert_equals(typeof obj, expected_typeof, "wrong typeof object");1061 this.do_interface_attribute_asserts(obj, member);1062 }.bind(this), this.name + " interface: " + desc + ' must have own property "' + member.name + '"');1063 }1064 else if (member.type == "operation" &&1065 member.name &&1066 member.isUnforgeable)1067 {1068 test(function()1069 {1070 assert_equals(exception, null, "Unexpected exception when evaluating object");1071 assert_equals(typeof obj, expected_typeof, "wrong typeof object");1072 assert_own_property(obj, member.name,1073 "Doesn't have the unforgeable operation property");1074 this.do_member_operation_asserts(obj, member);1075 }.bind(this), this.name + " interface: " + desc + ' must have own property "' + member.name + '"');1076 }1077 else if ((member.type == "const"1078 || member.type == "attribute"1079 || member.type == "operation")1080 && member.name)1081 {1082 test(function()1083 {1084 assert_equals(exception, null, "Unexpected exception when evaluating object");1085 assert_equals(typeof obj, expected_typeof, "wrong typeof object");1086 if (!member["static"]) {1087 if (!this.is_global()) {1088 assert_inherits(obj, member.name);1089 } else {1090 assert_own_property(obj, member.name);1091 }1092 if (member.type == "const")1093 {1094 assert_equals(obj[member.name], constValue(member.value));1095 }1096 if (member.type == "attribute")1097 {1098 1099 1100 1101 var property, thrown = false;1102 try1103 {1104 property = obj[member.name];1105 }1106 catch (e)1107 {1108 thrown = true;1109 }1110 if (!thrown)1111 {1112 this.array.assert_type_is(property, member.idlType);1113 }1114 }1115 if (member.type == "operation")1116 {1117 assert_equals(typeof obj[member.name], "function");1118 }1119 }1120 }.bind(this), this.name + " interface: " + desc + ' must inherit property "' + member.name + '" with the proper type (' + i + ')');1121 }1122 1123 1124 1125 if (member.type == "operation" && member.name && member.arguments.length)1126 {1127 test(function()1128 {1129 assert_equals(exception, null, "Unexpected exception when evaluating object");1130 assert_equals(typeof obj, expected_typeof, "wrong typeof object");1131 if (!member["static"]) {1132 if (!this.is_global() && !member.isUnforgeable) {1133 assert_inherits(obj, member.name);1134 } else {1135 assert_own_property(obj, member.name);1136 }1137 }1138 else1139 {1140 assert_false(member.name in obj);1141 }1142 var minLength = minOverloadLength(this.members.filter(function(m) {1143 return m.type == "operation" && m.name == member.name;1144 }));1145 var args = [];1146 for (var i = 0; i < minLength; i++) {1147 assert_throws(new TypeError(), function()1148 {1149 obj[member.name].apply(obj, args);1150 }.bind(this), "Called with " + i + " arguments");1151 args.push(create_suitable_object(member.arguments[i].idlType));1152 }1153 }.bind(this), this.name + " interface: calling " + member.name +1154 "(" + member.arguments.map(function(m) { return m.idlType.idlType; }) +1155 ") on " + desc + " with too few arguments must throw TypeError");1156 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.minOverloadLength(function(err, data) {4 if (err) {5 console.error(err);6 } else {7 console.log(data);8 }9});10var wpt = require('webpagetest');11var wpt = new WebPageTest('www.webpagetest.org');12 if (err) {13 console.error(err);14 } else {15 console.log(data);16 }17});18var wpt = require('webpagetest');19var wpt = new WebPageTest('www.webpagetest.org');20var options = {21};22 if (err) {23 console.error(err);24 } else {25 console.log(data);26 }27});28var wpt = require('webpagetest');29var wpt = new WebPageTest('www.webpagetest.org');30 if (err) {31 console.error(err);32 } else {33 console.log(data);34 }35});36var wpt = require('webpagetest');37var wpt = new WebPageTest('www.webpagetest.org');38 if (err) {39 console.error(err);40 } else {41 console.log(data);42 }43});

Full Screen

Using AI Code Generation

copy

Full Screen

1CKEDITOR.replace( 'editor1', {2 on: {3 instanceReady: function( evt ) {4 var editor = evt.editor;5 editor.plugins.wptextpattern.addRule( {6 } );7 }8 }9} );

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = new wpt('your api key');3test.minOverloadLength(function(err, data) {4 if (err) return console.error(err);5 console.log(data);6});7### test.minOverloadLength([callback])8var wpt = require('webpagetest');9var test = new wpt('your api key');10test.minOverloadLength().then(function(data) {11 console.log(data);12}).catch(function(err) {13 console.error(err);14});15### test.getLocations([callback])

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var options = {3};4wptools.minOverloadLength('wikipedia', options, function(err, res) {5 if (err) {6 console.log(err);7 } else {8 console.log(res);9 }10});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wiki = new wptools('Albert Einstein');3wiki.minOverloadLength(function(err, res) {4 if (err) {5 console.log('error:', err);6 } else {7 console.log('minOverloadLength:', res);8 }9});10var wptools = require('wptools');11var wiki = new wptools('Albert Einstein');12wiki.minOverloadLength(function(err, res) {13 if (err) {14 console.log('error:', err);15 } else {16 console.log('minOverloadLength:', res);17 }18});19var wptools = require('wptools');20var wiki = new wptools('Albert Einstein');21wiki.minOverloadLength(function(err, res) {22 if (err) {23 console.log('error:', err);24 } else {25 console.log('minOverloadLength:', res);26 }27});28var wptools = require('wptools');29var wiki = new wptools('Albert Einstein');30wiki.minOverloadLength(function(err, res) {31 if (err) {32 console.log('error:', err);33 } else {34 console.log('minOverloadLength:', res);35 }36});37var wptools = require('wptools');38var wiki = new wptools('Albert Einstein');39wiki.minOverloadLength(function(err, res) {40 if (err) {41 console.log('error:', err);42 } else {43 console.log('minOverloadLength:', res);44 }45});46var wptools = require('wptools');47var wiki = new wptools('Albert Einstein');

Full Screen

Using AI Code Generation

copy

Full Screen

1CKEDITOR.plugins.add('minOverloadLength', {2 init: function (editor) {3 editor.on('instanceReady', function (e) {4 var editor = e.editor;5 var textpattern = editor.plugins.textpattern;6 var minOverloadLength = textpattern.minOverloadLength;7 console.log("Value of minOverloadLength is " + minOverloadLength);8 });9 }10});11CKEDITOR.plugins.add('minOverloadLength', {12 init: function (editor) {13 editor.on('instanceReady', function (e) {14 var editor = e.editor;15 var textpattern = editor.plugins.textpattern;16 var minOverloadLength = textpattern.minOverloadLength;17 console.log("Value of minOverloadLength is " + minOverloadLength);18 });19 }20});21CKEDITOR.plugins.add('minOverloadLength', {22 init: function (editor) {23 editor.on('instanceReady', function (e) {24 var editor = e.editor;25 var textpattern = editor.plugins.textpattern;26 var minOverloadLength = textpattern.minOverloadLength;27 console.log("Value of minOverloadLength is " + minOverloadLength);28 });29 }30});31CKEDITOR.plugins.add('minOverloadLength', {32 init: function (editor) {33 editor.on('instanceReady', function (e) {34 var editor = e.editor;35 var textpattern = editor.plugins.textpattern;36 var minOverloadLength = textpattern.minOverloadLength;37 console.log("Value of minOverloadLength is " + minOverloadLength);38 });39 }40});41CKEDITOR.plugins.add('minOverloadLength', {42 init: function (editor) {43 editor.on('instanceReady', function (e) {44 var editor = e.editor;45 var textpattern = editor.plugins.textpattern;46 var minOverloadLength = textpattern.minOverloadLength;47 console.log("Value

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptextpattern = require('wptextpattern');2var str = 'This is a test string';3var minOverloadLength = 2;4var overloadedStr = wptextpattern.minOverloadLength(str, minOverloadLength);5console.log(overloadedStr);6var wptextpattern = require('wptextpattern');7var str = 'This is a test string';8var maxOverloadLength = 2;9var overloadedStr = wptextpattern.maxOverloadLength(str, maxOverloadLength);10console.log(overloadedStr);11var wptextpattern = require('wptextpattern');12var str = 'This is a test string';13var minOverloadLength = 2;14var maxOverloadLength = 3;15var overloadedStr = wptextpattern.minMaxOverloadLength(str, minOverloadLength, maxOverloadLength);16console.log(overloadedStr);17var wptextpattern = require('wptextpattern');18var str = 'This is a test string';19var minOverloadLength = 2;20var char = 'a';

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var options = {3};4var test = new wpt(options);5test.runTest(function (err, data) {6 if (err) {7 console.log(err);8 } else {9 console.log(data);10 test.minOverloadLength(data.data.testId, function (err, data) {11 if (err) {12 console.log(err);13 } else {14 console.log(data);15 }16 });17 }18});19## test.minOverloadLength(testId, callback)20var wpt = require('wpt');21var options = {22};23var test = new wpt(options);24test.runTest(function (err, data) {25 if (err) {26 console.log(err);27 } else {28 console.log(data);29 test.minOverloadLength(data.data.testId, function (err, data) {30 if (err) {31 console.log(err);32 } else {33 console.log(data);34 }35 });36 }37});38## test.minOverloadTime(testId, callback)39var wpt = require('w

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = new wpt('A.4e4a5d5f9a9c1e5d1a2b2c4c4e4a4a4');3test.minOverloadLength(function(err, data) {4 console.log(data);5});6var wpt = require('webpagetest');7var test = new wpt('A.4e4a5d5f9a9c1e5d1a2b2c4c4e4a4a4');8test.minOverloadTime(function(err, data) {9 console.log(data);10});11var wpt = require('webpagetest');12var test = new wpt('A.4e4a5d5f9a9c1e5d1a2b2c4c4e4a4a4');13 console.log(data);14});15var wpt = require('webpagetest');16var test = new wpt('A.4e4a5d5f9a9c1e5d1a2b2c4c4e4a4a4');17test.testStatus('140401_9T_1c7a', function(err, data) {18 console.log(data);19});20var wpt = require('webpagetest');21var test = new wpt('A.4e4a5d5f9a9c1e5d1a2b2c4c4e4a4a4');22test.testResults('140401_9T_1c7a', function(err, data) {23 console.log(data);24});

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