Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/resources/idlharness.js

Issue 2143653006: Import wpt@c875b4212a473363afe8c09f012edf201386cb5b (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update W3CImportExpectations Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 Distributed under both the W3C Test Suite License [1] and the W3C 2 Distributed under both the W3C Test Suite License [1] and the W3C
3 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the 3 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the
4 policies and contribution forms [3]. 4 policies and contribution forms [3].
5 5
6 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license 6 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license
7 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license 7 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license
8 [3] http://www.w3.org/2004/10/27-testcases 8 [3] http://www.w3.org/2004/10/27-testcases
9 */ 9 */
10 10
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 { 300 {
301 ret = ret.concat(this.recursively_get_implements(ret[i])); 301 ret = ret.concat(this.recursively_get_implements(ret[i]));
302 if (ret.indexOf(ret[i]) != ret.lastIndexOf(ret[i])) 302 if (ret.indexOf(ret[i]) != ret.lastIndexOf(ret[i]))
303 { 303 {
304 throw "Circular implements statements involving " + ret[i]; 304 throw "Circular implements statements involving " + ret[i];
305 } 305 }
306 } 306 }
307 return ret; 307 return ret;
308 }; 308 };
309 309
310 function exposed_in(globals) {
311 if ('document' in self) {
312 return globals.indexOf("Window") >= 0;
313 }
314 if ('DedicatedWorkerGlobalScope' in self &&
315 self instanceof DedicatedWorkerGlobalScope) {
316 return globals.indexOf("Worker") >= 0 ||
317 globals.indexOf("DedicatedWorker") >= 0;
318 }
319 if ('SharedWorkerGlobalScope' in self &&
320 self instanceof SharedWorkerGlobalScope) {
321 return globals.indexOf("Worker") >= 0 ||
322 globals.indexOf("SharedWorker") >= 0;
323 }
324 if ('ServiceWorkerGlobalScope' in self &&
325 self instanceof ServiceWorkerGlobalScope) {
326 return globals.indexOf("Worker") >= 0 ||
327 globals.indexOf("ServiceWorker") >= 0;
328 }
329 throw "Unexpected global object";
330 }
331
310 //@} 332 //@}
311 IdlArray.prototype.test = function() 333 IdlArray.prototype.test = function()
312 //@{ 334 //@{
313 { 335 {
314 /** Entry point. See documentation at beginning of file. */ 336 /** Entry point. See documentation at beginning of file. */
315 337
316 // First merge in all the partial interfaces and implements statements we 338 // First merge in all the partial interfaces and implements statements we
317 // encountered. 339 // encountered.
318 this.partials.forEach(function(parsed_idl) 340 this.partials.forEach(function(parsed_idl)
319 { 341 {
(...skipping 26 matching lines...) Expand all
346 if (!(rhs in this.members)) throw errStr + rhs + " is undefined."; 368 if (!(rhs in this.members)) throw errStr + rhs + " is undefined.";
347 if (!(this.members[rhs] instanceof IdlInterface)) throw errStr + rhs + " is not an interface."; 369 if (!(this.members[rhs] instanceof IdlInterface)) throw errStr + rhs + " is not an interface.";
348 this.members[rhs].members.forEach(function(member) 370 this.members[rhs].members.forEach(function(member)
349 { 371 {
350 this.members[lhs].members.push(new IdlInterfaceMember(member)); 372 this.members[lhs].members.push(new IdlInterfaceMember(member));
351 }.bind(this)); 373 }.bind(this));
352 }.bind(this)); 374 }.bind(this));
353 } 375 }
354 this["implements"] = {}; 376 this["implements"] = {};
355 377
378 Object.getOwnPropertyNames(this.members).forEach(function(memberName) {
379 var member = this.members[memberName];
380 if (!(member instanceof IdlInterface)) {
381 return;
382 }
383
384 var exposed = member.extAttrs.filter(function(a) { return a.name == "Exp osed" });
385 if (exposed.length > 1) {
386 throw "Unexpected Exposed extended attributes on " + memberName + ": " + exposed;
387 }
388
389 var globals = exposed.length === 1
390 ? exposed[0].rhs.value
391 : ["Window"];
392 member.exposed = exposed_in(globals);
393 }.bind(this));
394
356 // Now run test() on every member, and test_object() for every object. 395 // Now run test() on every member, and test_object() for every object.
357 for (var name in this.members) 396 for (var name in this.members)
358 { 397 {
359 this.members[name].test(); 398 this.members[name].test();
360 if (name in this.objects) 399 if (name in this.objects)
361 { 400 {
362 this.objects[name].forEach(function(str) 401 this.objects[name].forEach(function(str)
363 { 402 {
364 this.members[name].test_object(str); 403 this.members[name].test_object(str);
365 }.bind(this)); 404 }.bind(this));
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 //@{ 710 //@{
672 { 711 {
673 if (this.has_extended_attribute("NoInterfaceObject")) 712 if (this.has_extended_attribute("NoInterfaceObject"))
674 { 713 {
675 // No tests to do without an instance. TODO: We should still be able 714 // No tests to do without an instance. TODO: We should still be able
676 // to run tests on the prototype object, if we obtain one through some 715 // to run tests on the prototype object, if we obtain one through some
677 // other means. 716 // other means.
678 return; 717 return;
679 } 718 }
680 719
720 if (!this.exposed) {
721 test(function() {
722 assert_false(this.name in self);
723 }.bind(this), this.name + " interface: existence and properties of inter face object");
724 return;
725 }
726
681 if (!this.untested) 727 if (!this.untested)
682 { 728 {
683 // First test things to do with the exception/interface object and 729 // First test things to do with the exception/interface object and
684 // exception/interface prototype object. 730 // exception/interface prototype object.
685 this.test_self(); 731 this.test_self();
686 } 732 }
687 // Then test things to do with its members (constants, fields, attributes, 733 // Then test things to do with its members (constants, fields, attributes,
688 // operations, . . .). These are run even if .untested is true, because 734 // operations, . . .). These are run even if .untested is true, because
689 // members might themselves be marked as .untested. This might happen to 735 // members might themselves be marked as .untested. This might happen to
690 // interfaces if the interface itself is untested but a partial interface 736 // interfaces if the interface itself is untested but a partial interface
691 // that extends it is tested -- then the interface itself and its initial 737 // that extends it is tested -- then the interface itself and its initial
692 // members will be marked as untested, but the members added by the partial 738 // members will be marked as untested, but the members added by the partial
693 // interface are still tested. 739 // interface are still tested.
694 this.test_members(); 740 this.test_members();
695 }; 741 };
696 //@} 742 //@}
697 743
698 IdlInterface.prototype.test_self = function() 744 IdlInterface.prototype.test_self = function()
699 //@{ 745 //@{
700 { 746 {
701 test(function() 747 test(function()
702 { 748 {
703 // This function tests WebIDL as of 2015-01-13. 749 // This function tests WebIDL as of 2015-01-13.
704 // TODO: Consider [Exposed].
705 750
706 // "For every interface that is exposed in a given ECMAScript global 751 // "For every interface that is exposed in a given ECMAScript global
707 // environment and: 752 // environment and:
708 // * is a callback interface that has constants declared on it, or 753 // * is a callback interface that has constants declared on it, or
709 // * is a non-callback interface that is not declared with the 754 // * is a non-callback interface that is not declared with the
710 // [NoInterfaceObject] extended attribute, 755 // [NoInterfaceObject] extended attribute,
711 // a corresponding property MUST exist on the ECMAScript global object. 756 // a corresponding property MUST exist on the ECMAScript global object.
712 // The name of the property is the identifier of the interface, and its 757 // The name of the property is the identifier of the interface, and its
713 // value is an object called the interface object. 758 // value is an object called the interface object.
714 // The property has the attributes { [[Writable]]: true, 759 // The property has the attributes { [[Writable]]: true,
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 /** An array of values produced by the "typedef" production. */ 1841 /** An array of values produced by the "typedef" production. */
1797 this.values = obj.values; 1842 this.values = obj.values;
1798 1843
1799 } 1844 }
1800 //@} 1845 //@}
1801 1846
1802 IdlTypedef.prototype = Object.create(IdlObject.prototype); 1847 IdlTypedef.prototype = Object.create(IdlObject.prototype);
1803 1848
1804 }()); 1849 }());
1805 // vim: set expandtab shiftwidth=4 tabstop=4 foldmarker=@{,@} foldmethod=marker: 1850 // vim: set expandtab shiftwidth=4 tabstop=4 foldmarker=@{,@} foldmethod=marker:
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698