Best JavaScript code snippet using wpt
idlharness.js
Source:idlharness.js
...79 });80 }81 }82}83function awaitNCallbacks(n, cb, ctx) {84 var counter = 0;85 return function() {86 counter++;87 if (counter >= n) {88 cb();89 }90 };91}92/// IdlArray ///93// Entry point94self.IdlArray = function()95//@{96{97 /**98 * A map from strings to the corresponding named IdlObject, such as99 * IdlInterface or IdlException. These are the things that test() will run100 * tests on.101 */102 this.members = {};103 /**104 * A map from strings to arrays of strings. The keys are interface or105 * exception names, and are expected to also exist as keys in this.members106 * (otherwise they'll be ignored). This is populated by add_objects() --107 * see documentation at the start of the file. The actual tests will be108 * run by calling this.members[name].test_object(obj) for each obj in109 * this.objects[name]. obj is a string that will be eval'd to produce a110 * JavaScript value, which is supposed to be an object implementing the111 * given IdlObject (interface, exception, etc.).112 */113 this.objects = {};114 /**115 * When adding multiple collections of IDLs one at a time, an earlier one116 * might contain a partial interface or implements statement that depends117 * on a later one. Save these up and handle them right before we run118 * tests.119 *120 * .partials is simply an array of objects from WebIDLParser.js'121 * "partialinterface" production. .implements maps strings to arrays of122 * strings, such that123 *124 * A implements B;125 * A implements C;126 * D implements E;127 *128 * results in { A: ["B", "C"], D: ["E"] }.129 */130 this.partials = [];131 this["implements"] = {};132};133//@}134IdlArray.prototype.add_idls = function(raw_idls)135//@{136{137 /** Entry point. See documentation at beginning of file. */138 this.internal_add_idls(WebIDL2.parse(raw_idls));139};140//@}141IdlArray.prototype.add_untested_idls = function(raw_idls)142//@{143{144 /** Entry point. See documentation at beginning of file. */145 var parsed_idls = WebIDL2.parse(raw_idls);146 for (var i = 0; i < parsed_idls.length; i++)147 {148 parsed_idls[i].untested = true;149 if ("members" in parsed_idls[i])150 {151 for (var j = 0; j < parsed_idls[i].members.length; j++)152 {153 parsed_idls[i].members[j].untested = true;154 }155 }156 }157 this.internal_add_idls(parsed_idls);158};159//@}160IdlArray.prototype.internal_add_idls = function(parsed_idls)161//@{162{163 /**164 * Internal helper called by add_idls() and add_untested_idls().165 * parsed_idls is an array of objects that come from WebIDLParser.js's166 * "definitions" production. The add_untested_idls() entry point167 * additionally sets an .untested property on each object (and its168 * .members) so that they'll be skipped by test() -- they'll only be169 * used for base interfaces of tested interfaces, return types, etc.170 */171 parsed_idls.forEach(function(parsed_idl)172 {173 if (parsed_idl.type == "interface" && parsed_idl.partial)174 {175 this.partials.push(parsed_idl);176 return;177 }178 if (parsed_idl.type == "implements")179 {180 if (!(parsed_idl.target in this["implements"]))181 {182 this["implements"][parsed_idl.target] = [];183 }184 this["implements"][parsed_idl.target].push(parsed_idl["implements"]);185 return;186 }187 parsed_idl.array = this;188 if (parsed_idl.name in this.members)189 {190 throw "Duplicate identifier " + parsed_idl.name;191 }192 switch(parsed_idl.type)193 {194 case "interface":195 this.members[parsed_idl.name] =196 new IdlInterface(parsed_idl, /* is_callback = */ false);197 break;198 case "dictionary":199 // Nothing to test, but we need the dictionary info around for type200 // checks201 this.members[parsed_idl.name] = new IdlDictionary(parsed_idl);202 break;203 case "typedef":204 this.members[parsed_idl.name] = new IdlTypedef(parsed_idl);205 break;206 case "callback":207 // TODO208 console.log("callback not yet supported");209 break;210 case "enum":211 this.members[parsed_idl.name] = new IdlEnum(parsed_idl);212 break;213 case "callback interface":214 this.members[parsed_idl.name] =215 new IdlInterface(parsed_idl, /* is_callback = */ true);216 break;217 default:218 throw parsed_idl.name + ": " + parsed_idl.type + " not yet supported";219 }220 }.bind(this));221};222//@}223IdlArray.prototype.add_objects = function(dict)224//@{225{226 /** Entry point. See documentation at beginning of file. */227 for (var k in dict)228 {229 if (k in this.objects)230 {231 this.objects[k] = this.objects[k].concat(dict[k]);232 }233 else234 {235 this.objects[k] = dict[k];236 }237 }238};239//@}240IdlArray.prototype.prevent_multiple_testing = function(name)241//@{242{243 /** Entry point. See documentation at beginning of file. */244 this.members[name].prevent_multiple_testing = true;245};246//@}247IdlArray.prototype.recursively_get_implements = function(interface_name)248//@{249{250 /**251 * Helper function for test(). Returns an array of things that implement252 * interface_name, so if the IDL contains253 *254 * A implements B;255 * B implements C;256 * B implements D;257 *258 * then recursively_get_implements("A") should return ["B", "C", "D"].259 */260 var ret = this["implements"][interface_name];261 if (ret === undefined)262 {263 return [];264 }265 for (var i = 0; i < this["implements"][interface_name].length; i++)266 {267 ret = ret.concat(this.recursively_get_implements(ret[i]));268 if (ret.indexOf(ret[i]) != ret.lastIndexOf(ret[i]))269 {270 throw "Circular implements statements involving " + ret[i];271 }272 }273 return ret;274};275//@}276IdlArray.prototype.test = function()277//@{278{279 /** Entry point. See documentation at beginning of file. */280 // First merge in all the partial interfaces and implements statements we281 // encountered.282 this.partials.forEach(function(parsed_idl)283 {284 if (!(parsed_idl.name in this.members)285 || !(this.members[parsed_idl.name] instanceof IdlInterface))286 {287 throw "Partial interface " + parsed_idl.name + " with no original interface";288 }289 if (parsed_idl.extAttrs)290 {291 parsed_idl.extAttrs.forEach(function(extAttr)292 {293 this.members[parsed_idl.name].extAttrs.push(extAttr);294 }.bind(this));295 }296 parsed_idl.members.forEach(function(member)297 {298 this.members[parsed_idl.name].members.push(new IdlInterfaceMember(member));299 }.bind(this));300 }.bind(this));301 this.partials = [];302 for (var lhs in this["implements"])303 {304 this.recursively_get_implements(lhs).forEach(function(rhs)305 {306 var errStr = lhs + " implements " + rhs + ", but ";307 if (!(lhs in this.members)) throw errStr + lhs + " is undefined.";308 if (!(this.members[lhs] instanceof IdlInterface)) throw errStr + lhs + " is not an interface.";309 if (!(rhs in this.members)) throw errStr + rhs + " is undefined.";310 if (!(this.members[rhs] instanceof IdlInterface)) throw errStr + rhs + " is not an interface.";311 this.members[rhs].members.forEach(function(member)312 {313 this.members[lhs].members.push(new IdlInterfaceMember(member));314 }.bind(this));315 }.bind(this));316 }317 this["implements"] = {};318 // Now run test() on every member, and test_object() for every object.319 for (var name in this.members)320 {321 this.members[name].test();322 if (name in this.objects)323 {324 this.objects[name].forEach(function(str)325 {326 this.members[name].test_object(str);327 }.bind(this));328 }329 }330};331//@}332IdlArray.prototype.assert_type_is = function(value, type)333//@{334{335 /**336 * Helper function that tests that value is an instance of type according337 * to the rules of WebIDL. value is any JavaScript value, and type is an338 * object produced by WebIDLParser.js' "type" production. That production339 * is fairly elaborate due to the complexity of WebIDL's types, so it's340 * best to look at the grammar to figure out what properties it might have.341 */342 if (type.idlType == "any")343 {344 // No assertions to make345 return;346 }347 if (type.nullable && value === null)348 {349 // This is fine350 return;351 }352 if (type.array)353 {354 // TODO: not supported yet355 return;356 }357 if (type.sequence)358 {359 assert_true(Array.isArray(value), "is not array");360 if (!value.length)361 {362 // Nothing we can do.363 return;364 }365 this.assert_type_is(value[0], type.idlType.idlType);366 return;367 }368 type = type.idlType;369 switch(type)370 {371 case "void":372 assert_equals(value, undefined);373 return;374 case "boolean":375 assert_equals(typeof value, "boolean");376 return;377 case "byte":378 assert_equals(typeof value, "number");379 assert_equals(value, Math.floor(value), "not an integer");380 assert_true(-128 <= value && value <= 127, "byte " + value + " not in range [-128, 127]");381 return;382 case "octet":383 assert_equals(typeof value, "number");384 assert_equals(value, Math.floor(value), "not an integer");385 assert_true(0 <= value && value <= 255, "octet " + value + " not in range [0, 255]");386 return;387 case "short":388 assert_equals(typeof value, "number");389 assert_equals(value, Math.floor(value), "not an integer");390 assert_true(-32768 <= value && value <= 32767, "short " + value + " not in range [-32768, 32767]");391 return;392 case "unsigned short":393 assert_equals(typeof value, "number");394 assert_equals(value, Math.floor(value), "not an integer");395 assert_true(0 <= value && value <= 65535, "unsigned short " + value + " not in range [0, 65535]");396 return;397 case "long":398 assert_equals(typeof value, "number");399 assert_equals(value, Math.floor(value), "not an integer");400 assert_true(-2147483648 <= value && value <= 2147483647, "long " + value + " not in range [-2147483648, 2147483647]");401 return;402 case "unsigned long":403 assert_equals(typeof value, "number");404 assert_equals(value, Math.floor(value), "not an integer");405 assert_true(0 <= value && value <= 4294967295, "unsigned long " + value + " not in range [0, 4294967295]");406 return;407 case "long long":408 assert_equals(typeof value, "number");409 return;410 case "unsigned long long":411 case "DOMTimeStamp":412 assert_equals(typeof value, "number");413 assert_true(0 <= value, "unsigned long long is negative");414 return;415 case "float":416 case "double":417 case "DOMHighResTimeStamp":418 case "unrestricted float":419 case "unrestricted double":420 // TODO: distinguish these cases421 assert_equals(typeof value, "number");422 return;423 case "DOMString":424 case "ByteString":425 case "USVString":426 // TODO: https://github.com/w3c/testharness.js/issues/92427 assert_equals(typeof value, "string");428 return;429 case "object":430 assert_true(typeof value == "object" || typeof value == "function", "wrong type: not object or function");431 return;432 }433 if (!(type in this.members))434 {435 throw "Unrecognized type " + type;436 }437 if (this.members[type] instanceof IdlInterface)438 {439 // We don't want to run the full440 // IdlInterface.prototype.test_instance_of, because that could result441 // in an infinite loop. TODO: This means we don't have tests for442 // NoInterfaceObject interfaces, and we also can't test objects that443 // come from another self.444 assert_true(typeof value == "object" || typeof value == "function", "wrong type: not object or function");445 if (value instanceof Object446 && !this.members[type].has_extended_attribute("NoInterfaceObject")447 && type in self)448 {449 assert_true(value instanceof self[type], "not instanceof " + type);450 }451 }452 else if (this.members[type] instanceof IdlEnum)453 {454 assert_equals(typeof value, "string");455 }456 else if (this.members[type] instanceof IdlDictionary)457 {458 // TODO: Test when we actually have something to test this on459 }460 else if (this.members[type] instanceof IdlTypedef)461 {462 // TODO: Test when we actually have something to test this on463 }464 else465 {466 throw "Type " + type + " isn't an interface or dictionary";467 }468};469//@}470/// IdlObject ///471function IdlObject() {}472IdlObject.prototype.test = function()473//@{474{475 /**476 * By default, this does nothing, so no actual tests are run for IdlObjects477 * that don't define any (e.g., IdlDictionary at the time of this writing).478 */479};480//@}481IdlObject.prototype.has_extended_attribute = function(name)482//@{483{484 /**485 * This is only meaningful for things that support extended attributes,486 * such as interfaces, exceptions, and members.487 */488 return this.extAttrs.some(function(o)489 {490 return o.name == name;491 });492};493//@}494/// IdlDictionary ///495// Used for IdlArray.prototype.assert_type_is496function IdlDictionary(obj)497//@{498{499 /**500 * obj is an object produced by the WebIDLParser.js "dictionary"501 * production.502 */503 /** Self-explanatory. */504 this.name = obj.name;505 /** An array of objects produced by the "dictionaryMember" production. */506 this.members = obj.members;507 /**508 * The name (as a string) of the dictionary type we inherit from, or null509 * if there is none.510 */511 this.base = obj.inheritance;512}513//@}514IdlDictionary.prototype = Object.create(IdlObject.prototype);515/// IdlInterface ///516function IdlInterface(obj, is_callback) {517 /**518 * obj is an object produced by the WebIDLParser.js "interface" production.519 */520 /** Self-explanatory. */521 this.name = obj.name;522 /** A back-reference to our IdlArray. */523 this.array = obj.array;524 /**525 * An indicator of whether we should run tests on the interface object and526 * interface prototype object. Tests on members are controlled by .untested527 * on each member, not this.528 */529 this.untested = obj.untested;530 /** An array of objects produced by the "ExtAttr" production. */531 this.extAttrs = obj.extAttrs;532 /** An array of IdlInterfaceMembers. */533 this.members = obj.members.map(function(m){return new IdlInterfaceMember(m); });534 if (this.has_extended_attribute("Unforgeable")) {535 this.members536 .filter(function(m) { return !m["static"] && (m.type == "attribute" || m.type == "operation"); })537 .forEach(function(m) { return m.isUnforgeable = true; });538 }539 /**540 * The name (as a string) of the type we inherit from, or null if there is541 * none.542 */543 this.base = obj.inheritance;544 this._is_callback = is_callback;545}546IdlInterface.prototype = Object.create(IdlObject.prototype);547IdlInterface.prototype.is_callback = function()548//@{549{550 return this._is_callback;551};552//@}553IdlInterface.prototype.has_constants = function()554//@{555{556 return this.members.some(function(member) {557 return member.type === "const";558 });559};560//@}561IdlInterface.prototype.is_global = function()562//@{563{564 return this.extAttrs.some(function(attribute) {565 return attribute.name === "Global" ||566 attribute.name === "PrimaryGlobal";567 });568};569//@}570IdlInterface.prototype.test = function()571//@{572{573 if (this.has_extended_attribute("NoInterfaceObject"))574 {575 // No tests to do without an instance. TODO: We should still be able576 // to run tests on the prototype object, if we obtain one through some577 // other means.578 return;579 }580 if (!this.untested)581 {582 // First test things to do with the exception/interface object and583 // exception/interface prototype object.584 this.test_self();585 }586 // Then test things to do with its members (constants, fields, attributes,587 // operations, . . .). These are run even if .untested is true, because588 // members might themselves be marked as .untested. This might happen to589 // interfaces if the interface itself is untested but a partial interface590 // that extends it is tested -- then the interface itself and its initial591 // members will be marked as untested, but the members added by the partial592 // interface are still tested.593 this.test_members();594};595//@}596IdlInterface.prototype.test_self = function()597//@{598{599 test(function()600 {601 // This function tests WebIDL as of 2015-01-13.602 // TODO: Consider [Exposed].603 // "For every interface that is exposed in a given ECMAScript global604 // environment and:605 // * is a callback interface that has constants declared on it, or606 // * is a non-callback interface that is not declared with the607 // [NoInterfaceObject] extended attribute,608 // a corresponding property MUST exist on the ECMAScript global object.609 // The name of the property is the identifier of the interface, and its610 // value is an object called the interface object.611 // The property has the attributes { [[Writable]]: true,612 // [[Enumerable]]: false, [[Configurable]]: true }."613 if (this.is_callback() && !this.has_constants()) {614 return;615 }616 // TODO: Should we test here that the property is actually writable617 // etc., or trust getOwnPropertyDescriptor?618 assert_own_property(self, this.name,619 "self does not have own property " + format_value(this.name));620 var desc = Object.getOwnPropertyDescriptor(self, this.name);621 assert_false("get" in desc, "self's property " + format_value(this.name) + " has getter");622 assert_false("set" in desc, "self's property " + format_value(this.name) + " has setter");623 assert_true(desc.writable, "self's property " + format_value(this.name) + " is not writable");624 assert_false(desc.enumerable, "self's property " + format_value(this.name) + " is enumerable");625 assert_true(desc.configurable, "self's property " + format_value(this.name) + " is not configurable");626 if (this.is_callback()) {627 // "The internal [[Prototype]] property of an interface object for628 // a callback interface MUST be the Object.prototype object."629 assert_equals(Object.getPrototypeOf(self[this.name]), Object.prototype,630 "prototype of self's property " + format_value(this.name) + " is not Object.prototype");631 return;632 }633 // "The interface object for a given non-callback interface is a634 // function object."635 // "If an object is defined to be a function object, then it has636 // characteristics as follows:"637 // Its [[Prototype]] internal property is otherwise specified (see638 // below).639 // "* Its [[Get]] internal property is set as described in ECMA-262640 // section 9.1.8."641 // Not much to test for this.642 // "* Its [[Construct]] internal property is set as described in643 // ECMA-262 section 19.2.2.3."644 // Tested below if no constructor is defined. TODO: test constructors645 // if defined.646 // "* Its @@hasInstance property is set as described in ECMA-262647 // section 19.2.3.8, unless otherwise specified."648 // TODO649 // ES6 (rev 30) 19.1.3.6:650 // "Else, if O has a [[Call]] internal method, then let builtinTag be651 // "Function"."652 assert_class_string(self[this.name], "Function", "class string of " + this.name);653 // "The [[Prototype]] internal property of an interface object for a654 // non-callback interface is determined as follows:"655 var prototype = Object.getPrototypeOf(self[this.name]);656 if (this.base) {657 // "* If the interface inherits from some other interface, the658 // value of [[Prototype]] is the interface object for that other659 // interface."660 var has_interface_object =661 !this.array662 .members[this.base]663 .has_extended_attribute("NoInterfaceObject");664 if (has_interface_object) {665 assert_own_property(self, this.base,666 'should inherit from ' + this.base +667 ', but self has no such property');668 assert_equals(prototype, self[this.base],669 'prototype of ' + this.name + ' is not ' +670 this.base);671 }672 } else {673 // "If the interface doesn't inherit from any other interface, the674 // value of [[Prototype]] is %FunctionPrototype% ([ECMA-262],675 // section 6.1.7.4)."676 assert_equals(prototype, Function.prototype,677 "prototype of self's property " + format_value(this.name) + " is not Function.prototype");678 }679 if (!this.has_extended_attribute("Constructor")) {680 // "The internal [[Call]] method of the interface object behaves as681 // follows . . .682 //683 // "If I was not declared with a [Constructor] extended attribute,684 // then throw a TypeError."685 assert_throws(new TypeError(), function() {686 self[this.name]();687 }.bind(this), "interface object didn't throw TypeError when called as a function");688 assert_throws(new TypeError(), function() {689 new self[this.name]();690 }.bind(this), "interface object didn't throw TypeError when called as a constructor");691 }692 }.bind(this), this.name + " interface: existence and properties of interface object");693 if (!this.is_callback()) {694 test(function() {695 // This function tests WebIDL as of 2014-10-25.696 // https://heycam.github.io/webidl/#es-interface-call697 assert_own_property(self, this.name,698 "self does not have own property " + format_value(this.name));699 // "Interface objects for non-callback interfaces MUST have a700 // property named âlengthâ with attributes { [[Writable]]: false,701 // [[Enumerable]]: false, [[Configurable]]: true } whose value is702 // a Number."703 assert_own_property(self[this.name], "length");704 var desc = Object.getOwnPropertyDescriptor(self[this.name], "length");705 assert_false("get" in desc, this.name + ".length has getter");706 assert_false("set" in desc, this.name + ".length has setter");707 assert_false(desc.writable, this.name + ".length is writable");708 assert_false(desc.enumerable, this.name + ".length is enumerable");709 assert_true(desc.configurable, this.name + ".length is not configurable");710 var constructors = this.extAttrs711 .filter(function(attr) { return attr.name == "Constructor"; });712 var expected_length = minOverloadLength(constructors);713 assert_equals(self[this.name].length, expected_length, "wrong value for " + this.name + ".length");714 }.bind(this), this.name + " interface object length");715 }716 if (!this.is_callback() || this.has_constants()) {717 test(function() {718 // This function tests WebIDL as of 2015-11-17.719 // https://heycam.github.io/webidl/#interface-object720 assert_own_property(self, this.name,721 "self does not have own property " + format_value(this.name));722 // "All interface objects must have a property named ânameâ with723 // attributes { [[Writable]]: false, [[Enumerable]]: false,724 // [[Configurable]]: true } whose value is the identifier of the725 // corresponding interface."726 assert_own_property(self[this.name], "name");727 var desc = Object.getOwnPropertyDescriptor(self[this.name], "name");728 assert_false("get" in desc, this.name + ".name has getter");729 assert_false("set" in desc, this.name + ".name has setter");730 assert_false(desc.writable, this.name + ".name is writable");731 assert_false(desc.enumerable, this.name + ".name is enumerable");732 assert_true(desc.configurable, this.name + ".name is not configurable");733 assert_equals(self[this.name].name, this.name, "wrong value for " + this.name + ".name");734 }.bind(this), this.name + " interface object name");735 }736 // TODO: Test named constructors if I find any interfaces that have them.737 test(function()738 {739 // This function tests WebIDL as of 2015-01-21.740 // https://heycam.github.io/webidl/#interface-object741 if (this.is_callback() && !this.has_constants()) {742 return;743 }744 assert_own_property(self, this.name,745 "self does not have own property " + format_value(this.name));746 if (this.is_callback()) {747 assert_false("prototype" in self[this.name],748 this.name + ' should not have a "prototype" property');749 return;750 }751 // "An interface object for a non-callback interface must have a752 // property named âprototypeâ with attributes { [[Writable]]: false,753 // [[Enumerable]]: false, [[Configurable]]: false } whose value is an754 // object called the interface prototype object. This object has755 // properties that correspond to the regular attributes and regular756 // operations defined on the interface, and is described in more detail757 // in section 4.5.4 below."758 assert_own_property(self[this.name], "prototype",759 'interface "' + this.name + '" does not have own property "prototype"');760 var desc = Object.getOwnPropertyDescriptor(self[this.name], "prototype");761 assert_false("get" in desc, this.name + ".prototype has getter");762 assert_false("set" in desc, this.name + ".prototype has setter");763 assert_false(desc.writable, this.name + ".prototype is writable");764 assert_false(desc.enumerable, this.name + ".prototype is enumerable");765 assert_false(desc.configurable, this.name + ".prototype is configurable");766 // Next, test that the [[Prototype]] of the interface prototype object767 // is correct. (This is made somewhat difficult by the existence of768 // [NoInterfaceObject].)769 // TODO: Aryeh thinks there's at least other place in this file where770 // we try to figure out if an interface prototype object is771 // correct. Consolidate that code.772 // "The interface prototype object for a given interface A must have an773 // internal [[Prototype]] property whose value is returned from the774 // following steps:775 // "If A is declared with the [Global] or [PrimaryGlobal] extended776 // attribute, and A supports named properties, then return the named777 // properties object for A, as defined in section 4.5.5 below.778 // "Otherwise, if A is declared to inherit from another interface, then779 // return the interface prototype object for the inherited interface.780 // "Otherwise, if A is declared with the [ArrayClass] extended781 // attribute, then return %ArrayPrototype% ([ECMA-262], section782 // 6.1.7.4).783 // "Otherwise, return %ObjectPrototype% ([ECMA-262], section 6.1.7.4).784 // ([ECMA-262], section 15.2.4).785 if (this.name === "Window") {786 assert_class_string(Object.getPrototypeOf(self[this.name].prototype),787 'WindowProperties',788 'Class name for prototype of Window' +789 '.prototype is not "WindowProperties"');790 } else {791 var inherit_interface, inherit_interface_has_interface_object;792 if (this.base) {793 inherit_interface = this.base;794 inherit_interface_has_interface_object =795 !this.array796 .members[inherit_interface]797 .has_extended_attribute("NoInterfaceObject");798 } else if (this.has_extended_attribute('ArrayClass')) {799 inherit_interface = 'Array';800 inherit_interface_has_interface_object = true;801 } else {802 inherit_interface = 'Object';803 inherit_interface_has_interface_object = true;804 }805 if (inherit_interface_has_interface_object) {806 assert_own_property(self, inherit_interface,807 'should inherit from ' + inherit_interface + ', but self has no such property');808 assert_own_property(self[inherit_interface], 'prototype',809 'should inherit from ' + inherit_interface + ', but that object has no "prototype" property');810 assert_equals(Object.getPrototypeOf(self[this.name].prototype),811 self[inherit_interface].prototype,812 'prototype of ' + this.name + '.prototype is not ' + inherit_interface + '.prototype');813 } else {814 // We can't test that we get the correct object, because this is the815 // only way to get our hands on it. We only test that its class816 // string, at least, is correct.817 assert_class_string(Object.getPrototypeOf(self[this.name].prototype),818 inherit_interface + 'Prototype',819 'Class name for prototype of ' + this.name +820 '.prototype is not "' + inherit_interface + 'Prototype"');821 }822 }823 // "The class string of an interface prototype object is the824 // concatenation of the interfaceâs identifier and the string825 // âPrototypeâ."826 assert_class_string(self[this.name].prototype, this.name + "Prototype",827 "class string of " + this.name + ".prototype");828 // String() should end up calling {}.toString if nothing defines a829 // stringifier.830 if (!this.has_stringifier()) {831 assert_equals(String(self[this.name].prototype), "[object " + this.name + "Prototype]",832 "String(" + this.name + ".prototype)");833 }834 }.bind(this), this.name + " interface: existence and properties of interface prototype object");835 test(function()836 {837 if (this.is_callback() && !this.has_constants()) {838 return;839 }840 assert_own_property(self, this.name,841 "self does not have own property " + format_value(this.name));842 if (this.is_callback()) {843 assert_false("prototype" in self[this.name],844 this.name + ' should not have a "prototype" property');845 return;846 }847 assert_own_property(self[this.name], "prototype",848 'interface "' + this.name + '" does not have own property "prototype"');849 // "If the [NoInterfaceObject] extended attribute was not specified on850 // the interface, then the interface prototype object must also have a851 // property named âconstructorâ with attributes { [[Writable]]: true,852 // [[Enumerable]]: false, [[Configurable]]: true } whose value is a853 // reference to the interface object for the interface."854 assert_own_property(self[this.name].prototype, "constructor",855 this.name + '.prototype does not have own property "constructor"');856 var desc = Object.getOwnPropertyDescriptor(self[this.name].prototype, "constructor");857 assert_false("get" in desc, this.name + ".prototype.constructor has getter");858 assert_false("set" in desc, this.name + ".prototype.constructor has setter");859 assert_true(desc.writable, this.name + ".prototype.constructor is not writable");860 assert_false(desc.enumerable, this.name + ".prototype.constructor is enumerable");861 assert_true(desc.configurable, this.name + ".prototype.constructor in not configurable");862 assert_equals(self[this.name].prototype.constructor, self[this.name],863 this.name + '.prototype.constructor is not the same object as ' + this.name);864 }.bind(this), this.name + ' interface: existence and properties of interface prototype object\'s "constructor" property');865};866//@}867IdlInterface.prototype.test_member_const = function(member)868//@{869{870 if (!this.has_constants()) {871 throw "Internal error: test_member_const called without any constants";872 }873 test(function()874 {875 assert_own_property(self, this.name,876 "self does not have own property " + format_value(this.name));877 // "For each constant defined on an interface A, there must be878 // a corresponding property on the interface object, if it879 // exists."880 assert_own_property(self[this.name], member.name);881 // "The value of the property is that which is obtained by882 // converting the constantâs IDL value to an ECMAScript883 // value."884 assert_equals(self[this.name][member.name], constValue(member.value),885 "property has wrong value");886 // "The property has attributes { [[Writable]]: false,887 // [[Enumerable]]: true, [[Configurable]]: false }."888 var desc = Object.getOwnPropertyDescriptor(self[this.name], member.name);889 assert_false("get" in desc, "property has getter");890 assert_false("set" in desc, "property has setter");891 assert_false(desc.writable, "property is writable");892 assert_true(desc.enumerable, "property is not enumerable");893 assert_false(desc.configurable, "property is configurable");894 }.bind(this), this.name + " interface: constant " + member.name + " on interface object");895 // "In addition, a property with the same characteristics must896 // exist on the interface prototype object."897 test(function()898 {899 assert_own_property(self, this.name,900 "self does not have own property " + format_value(this.name));901 if (this.is_callback()) {902 assert_false("prototype" in self[this.name],903 this.name + ' should not have a "prototype" property');904 return;905 }906 assert_own_property(self[this.name], "prototype",907 'interface "' + this.name + '" does not have own property "prototype"');908 assert_own_property(self[this.name].prototype, member.name);909 assert_equals(self[this.name].prototype[member.name], constValue(member.value),910 "property has wrong value");911 var desc = Object.getOwnPropertyDescriptor(self[this.name], member.name);912 assert_false("get" in desc, "property has getter");913 assert_false("set" in desc, "property has setter");914 assert_false(desc.writable, "property is writable");915 assert_true(desc.enumerable, "property is not enumerable");916 assert_false(desc.configurable, "property is configurable");917 }.bind(this), this.name + " interface: constant " + member.name + " on interface prototype object");918};919//@}920IdlInterface.prototype.test_member_attribute = function(member)921//@{922{923 test(function()924 {925 if (this.is_callback() && !this.has_constants()) {926 return;927 }928 assert_own_property(self, this.name,929 "self does not have own property " + format_value(this.name));930 assert_own_property(self[this.name], "prototype",931 'interface "' + this.name + '" does not have own property "prototype"');932 if (member["static"]) {933 assert_own_property(self[this.name], member.name,934 "The interface object must have a property " +935 format_value(member.name));936 } else if (this.is_global()) {937 assert_own_property(self, member.name,938 "The global object must have a property " +939 format_value(member.name));940 assert_false(member.name in self[this.name].prototype,941 "The prototype object must not have a property " +942 format_value(member.name));943 var getter = Object.getOwnPropertyDescriptor(self, member.name).get;944 assert_equals(typeof(getter), "function",945 format_value(member.name) + " must have a getter");946 // Try/catch around the get here, since it can legitimately throw.947 // If it does, we obviously can't check for equality with direct948 // invocation of the getter.949 var gotValue;950 var propVal;951 try {952 propVal = self[member.name];953 gotValue = true;954 } catch (e) {955 gotValue = false;956 }957 if (gotValue) {958 assert_equals(propVal, getter.call(undefined),959 "Gets on a global should not require an explicit this");960 }961 this.do_interface_attribute_asserts(self, member);962 } else {963 assert_true(member.name in self[this.name].prototype,964 "The prototype object must have a property " +965 format_value(member.name));966 if (!member.has_extended_attribute("LenientThis")) {967 assert_throws(new TypeError(), function() {968 self[this.name].prototype[member.name];969 }.bind(this), "getting property on prototype object must throw TypeError");970 } else {971 assert_equals(self[this.name].prototype[member.name], undefined,972 "getting property on prototype object must return undefined");973 }974 this.do_interface_attribute_asserts(self[this.name].prototype, member);975 }976 }.bind(this), this.name + " interface: attribute " + member.name);977};978//@}979IdlInterface.prototype.test_member_operation = function(member)980//@{981{982 var a_test = async_test(this.name + " interface: operation " + member.name +983 "(" + member.arguments.map(984 function(m) {return m.idlType.idlType; } )985 +")");986 a_test.step(function()987 {988 // This function tests WebIDL as of 2015-12-29.989 // https://heycam.github.io/webidl/#es-operations990 if (this.is_callback() && !this.has_constants()) {991 a_test.done();992 return;993 }994 assert_own_property(self, this.name,995 "self does not have own property " + format_value(this.name));996 if (this.is_callback()) {997 assert_false("prototype" in self[this.name],998 this.name + ' should not have a "prototype" property');999 a_test.done();1000 return;1001 }1002 assert_own_property(self[this.name], "prototype",1003 'interface "' + this.name + '" does not have own property "prototype"');1004 // "For each unique identifier of an exposed operation defined on the1005 // interface, there must exist a corresponding property, unless the1006 // effective overload set for that identifier and operation and with an1007 // argument count of 0 has no entries."1008 // TODO: Consider [Exposed].1009 // "The location of the property is determined as follows:"1010 var memberHolderObject;1011 // "* If the operation is static, then the property exists on the1012 // interface object."1013 if (member["static"]) {1014 assert_own_property(self[this.name], member.name,1015 "interface object missing static operation");1016 memberHolderObject = self[this.name];1017 // "* Otherwise, [...] if the interface was declared with the [Global]1018 // or [PrimaryGlobal] extended attribute, then the property exists1019 // on every object that implements the interface."1020 } else if (this.is_global()) {1021 assert_own_property(self, member.name,1022 "global object missing non-static operation");1023 memberHolderObject = self;1024 // "* Otherwise, the property exists solely on the interfaceâs1025 // interface prototype object."1026 } else {1027 assert_own_property(self[this.name].prototype, member.name,1028 "interface prototype object missing non-static operation");1029 memberHolderObject = self[this.name].prototype;1030 }1031 this.do_member_operation_asserts(memberHolderObject, member, a_test);1032 }.bind(this));1033};1034//@}1035IdlInterface.prototype.do_member_operation_asserts = function(memberHolderObject, member, a_test)1036//@{1037{1038 var done = a_test.done.bind(a_test);1039 var operationUnforgeable = member.isUnforgeable;1040 var desc = Object.getOwnPropertyDescriptor(memberHolderObject, member.name);1041 // "The property has attributes { [[Writable]]: B,1042 // [[Enumerable]]: true, [[Configurable]]: B }, where B is false if the1043 // operation is unforgeable on the interface, and true otherwise".1044 assert_false("get" in desc, "property has getter");1045 assert_false("set" in desc, "property has setter");1046 assert_equals(desc.writable, !operationUnforgeable,1047 "property should be writable if and only if not unforgeable");1048 assert_true(desc.enumerable, "property is not enumerable");1049 assert_equals(desc.configurable, !operationUnforgeable,1050 "property should be configurable if and only if not unforgeable");1051 // "The value of the property is a Function object whose1052 // behavior is as follows . . ."1053 assert_equals(typeof memberHolderObject[member.name], "function",1054 "property must be a function");1055 // "The value of the Function objectâs âlengthâ property is1056 // a Number determined as follows:1057 // ". . .1058 // "Return the length of the shortest argument list of the1059 // entries in S."1060 assert_equals(memberHolderObject[member.name].length,1061 minOverloadLength(this.members.filter(function(m) {1062 return m.type == "operation" && m.name == member.name;1063 })),1064 "property has wrong .length");1065 // Make some suitable arguments1066 var args = member.arguments.map(function(arg) {1067 return create_suitable_object(arg.idlType);1068 });1069 // "Let O be a value determined as follows:1070 // ". . .1071 // "Otherwise, throw a TypeError."1072 // This should be hit if the operation is not static, there is1073 // no [ImplicitThis] attribute, and the this value is null.1074 //1075 // TODO: We currently ignore the [ImplicitThis] case. Except we manually1076 // check for globals, since otherwise we'll invoke window.close(). And we1077 // have to skip this test for anything that on the proto chain of "self",1078 // since that does in fact have implicit-this behavior.1079 if (!member["static"]) {1080 var cb;1081 if (!this.is_global() &&1082 memberHolderObject[member.name] != self[member.name])1083 {1084 cb = awaitNCallbacks(2, done);1085 throwOrReject(a_test, member, memberHolderObject[member.name], null, args,1086 "calling operation with this = null didn't throw TypeError", cb);1087 } else {1088 cb = awaitNCallbacks(1, done);1089 }1090 // ". . . If O is not null and is also not a platform object1091 // that implements interface I, throw a TypeError."1092 //1093 // TODO: Test a platform object that implements some other1094 // interface. (Have to be sure to get inheritance right.)1095 throwOrReject(a_test, member, memberHolderObject[member.name], {}, args,1096 "calling operation with this = {} didn't throw TypeError", cb);1097 } else {1098 done();1099 }1100}1101//@}1102IdlInterface.prototype.test_member_stringifier = function(member)1103//@{1104{1105 test(function()1106 {1107 if (this.is_callback() && !this.has_constants()) {1108 return;1109 }1110 assert_own_property(self, this.name,1111 "self does not have own property " + format_value(this.name));1112 if (this.is_callback()) {1113 assert_false("prototype" in self[this.name],1114 this.name + ' should not have a "prototype" property');1115 return;1116 }1117 assert_own_property(self[this.name], "prototype",1118 'interface "' + this.name + '" does not have own property "prototype"');1119 // ". . . the property exists on the interface prototype object."1120 var interfacePrototypeObject = self[this.name].prototype;1121 assert_own_property(self[this.name].prototype, "toString",1122 "interface prototype object missing non-static operation");1123 var stringifierUnforgeable = member.isUnforgeable;1124 var desc = Object.getOwnPropertyDescriptor(interfacePrototypeObject, "toString");1125 // "The property has attributes { [[Writable]]: B,1126 // [[Enumerable]]: true, [[Configurable]]: B }, where B is false if the1127 // stringifier is unforgeable on the interface, and true otherwise."1128 assert_false("get" in desc, "property has getter");1129 assert_false("set" in desc, "property has setter");1130 assert_equals(desc.writable, !stringifierUnforgeable,1131 "property should be writable if and only if not unforgeable");1132 assert_true(desc.enumerable, "property is not enumerable");1133 assert_equals(desc.configurable, !stringifierUnforgeable,1134 "property should be configurable if and only if not unforgeable");1135 // "The value of the property is a Function object, which behaves as1136 // follows . . ."1137 assert_equals(typeof interfacePrototypeObject.toString, "function",1138 "property must be a function");1139 // "The value of the Function objectâs âlengthâ property is the Number1140 // value 0."1141 assert_equals(interfacePrototypeObject.toString.length, 0,1142 "property has wrong .length");1143 // "Let O be the result of calling ToObject on the this value."1144 assert_throws(new TypeError(), function() {1145 self[this.name].prototype.toString.apply(null, []);1146 }, "calling stringifier with this = null didn't throw TypeError");1147 // "If O is not an object that implements the interface on which the1148 // stringifier was declared, then throw a TypeError."1149 //1150 // TODO: Test a platform object that implements some other1151 // interface. (Have to be sure to get inheritance right.)1152 assert_throws(new TypeError(), function() {1153 self[this.name].prototype.toString.apply({}, []);1154 }, "calling stringifier with this = {} didn't throw TypeError");1155 }.bind(this), this.name + " interface: stringifier");1156};1157//@}1158IdlInterface.prototype.test_members = function()1159//@{1160{1161 for (var i = 0; i < this.members.length; i++)1162 {1163 var member = this.members[i];1164 if (member.untested) {1165 continue;1166 }1167 switch (member.type) {1168 case "const":1169 this.test_member_const(member);1170 break;1171 case "attribute":1172 // For unforgeable attributes, we do the checks in1173 // test_interface_of instead.1174 if (!member.isUnforgeable)1175 {1176 this.test_member_attribute(member);1177 }1178 break;1179 case "operation":1180 // TODO: Need to correctly handle multiple operations with the same1181 // identifier.1182 // For unforgeable operations, we do the checks in1183 // test_interface_of instead.1184 if (member.name) {1185 if (!member.isUnforgeable)1186 {1187 this.test_member_operation(member);1188 }1189 } else if (member.stringifier) {1190 this.test_member_stringifier(member);1191 }1192 break;1193 default:1194 // TODO: check more member types.1195 break;1196 }1197 }1198};1199//@}1200IdlInterface.prototype.test_object = function(desc)1201//@{1202{1203 var obj, exception = null;1204 try1205 {1206 obj = eval(desc);1207 }1208 catch(e)1209 {1210 exception = e;1211 }1212 var expected_typeof =1213 this.members.some(function(member) { return member.legacycaller; })1214 ? "function"1215 : "object";1216 this.test_primary_interface_of(desc, obj, exception, expected_typeof);1217 var current_interface = this;1218 while (current_interface)1219 {1220 if (!(current_interface.name in this.array.members))1221 {1222 throw "Interface " + current_interface.name + " not found (inherited by " + this.name + ")";1223 }1224 if (current_interface.prevent_multiple_testing && current_interface.already_tested)1225 {1226 return;1227 }1228 current_interface.test_interface_of(desc, obj, exception, expected_typeof);1229 current_interface = this.array.members[current_interface.base];1230 }1231};1232//@}1233IdlInterface.prototype.test_primary_interface_of = function(desc, obj, exception, expected_typeof)1234//@{1235{1236 // We can't easily test that its prototype is correct if there's no1237 // interface object, or the object is from a different global environment1238 // (not instanceof Object). TODO: test in this case that its prototype at1239 // least looks correct, even if we can't test that it's actually correct.1240 if (!this.has_extended_attribute("NoInterfaceObject")1241 && (typeof obj != expected_typeof || obj instanceof Object))1242 {1243 test(function()1244 {1245 assert_equals(exception, null, "Unexpected exception when evaluating object");1246 assert_equals(typeof obj, expected_typeof, "wrong typeof object");1247 assert_own_property(self, this.name,1248 "self does not have own property " + format_value(this.name));1249 assert_own_property(self[this.name], "prototype",1250 'interface "' + this.name + '" does not have own property "prototype"');1251 // "The value of the internal [[Prototype]] property of the1252 // platform object is the interface prototype object of the primary1253 // interface from the platform objectâs associated global1254 // environment."1255 assert_equals(Object.getPrototypeOf(obj),1256 self[this.name].prototype,1257 desc + "'s prototype is not " + this.name + ".prototype");1258 }.bind(this), this.name + " must be primary interface of " + desc);1259 }1260 // "The class string of a platform object that implements one or more1261 // interfaces must be the identifier of the primary interface of the1262 // platform object."1263 test(function()1264 {1265 assert_equals(exception, null, "Unexpected exception when evaluating object");1266 assert_equals(typeof obj, expected_typeof, "wrong typeof object");1267 assert_class_string(obj, this.name, "class string of " + desc);1268 if (!this.has_stringifier())1269 {1270 assert_equals(String(obj), "[object " + this.name + "]", "String(" + desc + ")");1271 }1272 }.bind(this), "Stringification of " + desc);1273};1274//@}1275IdlInterface.prototype.test_interface_of = function(desc, obj, exception, expected_typeof)1276//@{1277{1278 // TODO: Indexed and named properties, more checks on interface members1279 this.already_tested = true;1280 for (var i = 0; i < this.members.length; i++)1281 {1282 var member = this.members[i];1283 if (member.type == "attribute" && member.isUnforgeable)1284 {1285 test(function()1286 {1287 assert_equals(exception, null, "Unexpected exception when evaluating object");1288 assert_equals(typeof obj, expected_typeof, "wrong typeof object");1289 this.do_interface_attribute_asserts(obj, member);1290 }.bind(this), this.name + " interface: " + desc + ' must have own property "' + member.name + '"');1291 }1292 else if (member.type == "operation" &&1293 member.name &&1294 member.isUnforgeable)1295 {1296 var a_test = async_test(this.name + " interface: " + desc + ' must have own property "' + member.name + '"');1297 a_test.step(function()1298 {1299 assert_equals(exception, null, "Unexpected exception when evaluating object");1300 assert_equals(typeof obj, expected_typeof, "wrong typeof object");1301 assert_own_property(obj, member.name,1302 "Doesn't have the unforgeable operation property");1303 this.do_member_operation_asserts(obj, member, a_test);1304 }.bind(this));1305 }1306 else if ((member.type == "const"1307 || member.type == "attribute"1308 || member.type == "operation")1309 && member.name)1310 {1311 test(function()1312 {1313 assert_equals(exception, null, "Unexpected exception when evaluating object");1314 assert_equals(typeof obj, expected_typeof, "wrong typeof object");1315 if (!member["static"]) {1316 if (!this.is_global()) {1317 assert_inherits(obj, member.name);1318 } else {1319 assert_own_property(obj, member.name);1320 }1321 if (member.type == "const")1322 {1323 assert_equals(obj[member.name], constValue(member.value));1324 }1325 if (member.type == "attribute")1326 {1327 // Attributes are accessor properties, so they might1328 // legitimately throw an exception rather than returning1329 // anything.1330 var property, thrown = false;1331 try1332 {1333 property = obj[member.name];1334 }1335 catch (e)1336 {1337 thrown = true;1338 }1339 if (!thrown)1340 {1341 this.array.assert_type_is(property, member.idlType);1342 }1343 }1344 if (member.type == "operation")1345 {1346 assert_equals(typeof obj[member.name], "function");1347 }1348 }1349 }.bind(this), this.name + " interface: " + desc + ' must inherit property "' + member.name + '" with the proper type (' + i + ')');1350 }1351 // TODO: This is wrong if there are multiple operations with the same1352 // identifier.1353 // TODO: Test passing arguments of the wrong type.1354 if (member.type == "operation" && member.name && member.arguments.length)1355 {1356 var a_test = async_test( this.name + " interface: calling " + member.name +1357 "(" + member.arguments.map(function(m) { return m.idlType.idlType; }) +1358 ") on " + desc + " with too few arguments must throw TypeError");1359 a_test.step(function()1360 {1361 assert_equals(exception, null, "Unexpected exception when evaluating object");1362 assert_equals(typeof obj, expected_typeof, "wrong typeof object");1363 if (!member["static"]) {1364 if (!this.is_global() && !member.isUnforgeable) {1365 assert_inherits(obj, member.name);1366 } else {1367 assert_own_property(obj, member.name);1368 }1369 }1370 else1371 {1372 assert_false(member.name in obj);1373 }1374 var minLength = minOverloadLength(this.members.filter(function(m) {1375 return m.type == "operation" && m.name == member.name;1376 }));1377 var args = [];1378 var cb = awaitNCallbacks(minLength, a_test.done.bind(a_test));1379 for (var i = 0; i < minLength; i++) {1380 throwOrReject(a_test, member, obj[member.name], obj, args, "Called with " + i + " arguments", cb);1381 args.push(create_suitable_object(member.arguments[i].idlType));1382 }1383 if (minLength === 0) {1384 cb();1385 }1386 }.bind(this));1387 }1388 }1389};1390//@}1391IdlInterface.prototype.has_stringifier = function()1392//@{...
Using AI Code Generation
1var wptools = require('wptools');2var title = 'Barack Obama';3var page = wptools.page(title);4page.getWikiText(function(err, resp) {5 if (err) {6 console.log(err);7 }8 else {9 console.log(resp);10 }11});12var wptools = require('wptools');13var title = 'Barack Obama';14var page = wptools.page(title);15page.getWikiTextAsync()16 .then(function(resp) {17 console.log(resp);18 })19 .catch(function(err) {20 console.log(err);21 });22var wptools = require('wptools');23var title = 'Barack Obama';24var page = wptools.page(title);25async function getWikiText() {26 try {27 var resp = await page.getWikiTextAsyncAwait();28 console.log(resp);29 }30 catch (err) {31 console.log(err);32 }33}34getWikiText();35var wptools = require('wptools');36var title = 'Barack Obama';37var page = wptools.page(title);38async function getWikiText() {39 try {40 var resp = await page.getWikiTextAsyncAwait();41 console.log(resp);42 }43 catch (err) {44 console.log(err);45 }46}47getWikiText();48var wptools = require('wptools');49var title = 'Barack Obama';50var page = wptools.page(title);51async function getWikiText() {52 try {53 var resp = await page.getWikiTextAsyncAwait();54 console.log(resp);55 }56 catch (err) {57 console.log(err);58 }59}60getWikiText();
Using AI Code Generation
1var wptools = require('wptools');2var fs = require('fs');3var path = require('path');4var _ = require('lodash');5var Q = require('q');6var async = require('async');7var request = require('request');8var count = 0;9var input = "A";10var searchInput = url + input + "&format=json&callback=?";11var callback = function (err, data) {12 if (err) {13 console.log(err);14 } else {15 console.log(data);16 }17};18var search = function (input) {19 var deferred = Q.defer();20 var searchInput = url + input + "&format=json&callback=?";21 request(searchInput, function (err, data) {22 if (err) {23 deferred.reject(err);24 } else {25 deferred.resolve(data);26 }27 });28 return deferred.promise;29};
Using AI Code Generation
1var wptools = require('../index.js');2var pageName = 'Albert Einstein';3var options = {4};5var page = wptools.page(pageName, options);6page.get(function(err, resp) {7 if (err) {8 console.log(err);9 return;10 }11 console.log(resp);12});
Using AI Code Generation
1var wptools = require('wptools');2wptools.page('Albert Einstein').then(function(page){3 page.getImages().then(function(images){4 console.log(images);5 });6});
Using AI Code Generation
1const wptools = require('wptools');2const fs = require('fs');3async function getWikiData() {4 const data = await wptools.getWikiData({5 });6 const json = JSON.stringify(data, null, 2);7 fs.writeFileSync('test.json', json, 'utf8');8}9getWikiData();10### wptools.getWikiData(options)
Using AI Code Generation
1var wptools = require('wptools');2var options = {3};4wptools.page('Wikipedia', options).then(function(page) {5 page.links().then(function(links) {6 console.log(links.length);7 });8});
Using AI Code Generation
1var wptools = require('wptools');2var title = "Barack Obama";3var lang = "en";4var options = {};5var wp = wptools.page(title, lang, options);6wp.get(function(err, info) {7 if (err) {8 console.log(err);9 } else {10 console.log(info);11 }12});13wp.get(function(err, info) {14 if (err) {15 console.log(err);16 } else {17 console.log(info);18 }19});20wp.get(function(err, info) {21 if (err) {22 console.log(err);23 } else {24 console.log(info);25 }26});27wp.get(function(err, info) {28 if (err) {29 console.log(err);30 } else {31 console.log(info);32 }33});34wp.get(function(err, info) {35 if (err) {36 console.log(err);37 } else {38 console.log(info);39 }40});41wp.get(function(err, info) {42 if (err) {43 console.log(err);44 } else {45 console.log(info);46 }47});48wp.get(function(err, info) {49 if (err) {50 console.log(err);51 } else {52 console.log(info);53 }54});55wp.get(function(err, info) {56 if (err) {57 console.log(err);58 } else {59 console.log(info);60 }61});62wp.get(function(err, info) {63 if (err) {64 console.log(err);65 } else {66 console.log(info);67 }68});69wp.get(function(err, info) {70 if (err) {71 console.log(err);72 } else {73 console.log(info);74 }75});
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!