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

Side by Side Diff: third_party/WebKit/LayoutTests/resources/testharness.js

Issue 2657583002: Import wpt@cf62b859e6b890abc34f8140d185ba91df95c5b6 (Closed)
Patch Set: Modify TestExpectations or download new baselines for tests. Created 3 years, 10 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
« no previous file with comments | « third_party/WebKit/LayoutTests/resources/idlharness.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /*global self*/ 1 /*global self*/
2 /*jshint latedef: nofunc*/ 2 /*jshint latedef: nofunc*/
3 /* 3 /*
4 Distributed under both the W3C Test Suite License [1] and the W3C 4 Distributed under both the W3C Test Suite License [1] and the W3C
5 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the 5 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the
6 policies and contribution forms [3]. 6 policies and contribution forms [3].
7 7
8 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license 8 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license
9 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license 9 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license
10 [3] http://www.w3.org/2004/10/27-testcases 10 [3] http://www.w3.org/2004/10/27-testcases
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 * inside a shared web worker. 382 * inside a shared web worker.
383 */ 383 */
384 function SharedWorkerTestEnvironment() { 384 function SharedWorkerTestEnvironment() {
385 WorkerTestEnvironment.call(this); 385 WorkerTestEnvironment.call(this);
386 var this_obj = this; 386 var this_obj = this;
387 // Shared workers receive message ports via the 'onconnect' event for 387 // Shared workers receive message ports via the 'onconnect' event for
388 // each connection. 388 // each connection.
389 self.addEventListener("connect", 389 self.addEventListener("connect",
390 function(message_event) { 390 function(message_event) {
391 this_obj._add_message_port(message_event.source); 391 this_obj._add_message_port(message_event.source);
392 }); 392 }, false);
393 } 393 }
394 SharedWorkerTestEnvironment.prototype = Object.create(WorkerTestEnvironment. prototype); 394 SharedWorkerTestEnvironment.prototype = Object.create(WorkerTestEnvironment. prototype);
395 395
396 SharedWorkerTestEnvironment.prototype.on_tests_ready = function() { 396 SharedWorkerTestEnvironment.prototype.on_tests_ready = function() {
397 WorkerTestEnvironment.prototype.on_tests_ready.call(this); 397 WorkerTestEnvironment.prototype.on_tests_ready.call(this);
398 // In the absence of an onload notification, we a require shared 398 // In the absence of an onload notification, we a require shared
399 // workers to explicitly signal when the tests are done. 399 // workers to explicitly signal when the tests are done.
400 tests.wait_for_finish = true; 400 tests.wait_for_finish = true;
401 }; 401 };
402 402
(...skipping 20 matching lines...) Expand all
423 // ServiceWorkers yet. 423 // ServiceWorkers yet.
424 this_obj._add_message_port(event.ports[0]); 424 this_obj._add_message_port(event.ports[0]);
425 event.ports[0].start(); 425 event.ports[0].start();
426 } else { 426 } else {
427 // If there is no MessageChannel, then attempt to 427 // If there is no MessageChannel, then attempt to
428 // use the MessageEvent.source to send results 428 // use the MessageEvent.source to send results
429 // back to the main window. 429 // back to the main window.
430 this_obj._add_message_port(event.source); 430 this_obj._add_message_port(event.source);
431 } 431 }
432 } 432 }
433 }); 433 }, false);
434 434
435 // The oninstall event is received after the service worker script and 435 // The oninstall event is received after the service worker script and
436 // all imported scripts have been fetched and executed. It's the 436 // all imported scripts have been fetched and executed. It's the
437 // equivalent of an onload event for a document. All tests should have 437 // equivalent of an onload event for a document. All tests should have
438 // been added by the time this event is received, thus it's not 438 // been added by the time this event is received, thus it's not
439 // necessary to wait until the onactivate event. 439 // necessary to wait until the onactivate event.
440 on_event(self, "install", 440 on_event(self, "install",
441 function(event) { 441 function(event) {
442 this_obj.all_loaded = true; 442 this_obj.all_loaded = true;
443 if (this_obj.on_loaded_callback) { 443 if (this_obj.on_loaded_callback) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 } 579 }
580 // We need to null out waitingFor before calling the resolve functio n 580 // We need to null out waitingFor before calling the resolve functio n
581 // since the Promise's resolve handlers may call wait_for() which wi ll 581 // since the Promise's resolve handlers may call wait_for() which wi ll
582 // need to set waitingFor. 582 // need to set waitingFor.
583 var resolveFunc = waitingFor.resolve; 583 var resolveFunc = waitingFor.resolve;
584 waitingFor = null; 584 waitingFor = null;
585 resolveFunc(evt); 585 resolveFunc(evt);
586 }); 586 });
587 587
588 for (var i = 0; i < eventTypes.length; i++) { 588 for (var i = 0; i < eventTypes.length; i++) {
589 watchedNode.addEventListener(eventTypes[i], eventHandler); 589 watchedNode.addEventListener(eventTypes[i], eventHandler, false);
590 } 590 }
591 591
592 /** 592 /**
593 * Returns a Promise that will resolve after the specified event or 593 * Returns a Promise that will resolve after the specified event or
594 * series of events has occured. 594 * series of events has occured.
595 */ 595 */
596 this.wait_for = function(types) { 596 this.wait_for = function(types) {
597 if (waitingFor) { 597 if (waitingFor) {
598 return Promise.reject('Already waiting for an event or events'); 598 return Promise.reject('Already waiting for an event or events');
599 } 599 }
600 if (typeof types == 'string') { 600 if (typeof types == 'string') {
601 types = [types]; 601 types = [types];
602 } 602 }
603 return new Promise(function(resolve, reject) { 603 return new Promise(function(resolve, reject) {
604 waitingFor = { 604 waitingFor = {
605 types: types, 605 types: types,
606 resolve: resolve, 606 resolve: resolve,
607 reject: reject 607 reject: reject
608 }; 608 };
609 }); 609 });
610 }; 610 };
611 611
612 function stop_watching() { 612 function stop_watching() {
613 for (var i = 0; i < eventTypes.length; i++) { 613 for (var i = 0; i < eventTypes.length; i++) {
614 watchedNode.removeEventListener(eventTypes[i], eventHandler); 614 watchedNode.removeEventListener(eventTypes[i], eventHandler, fal se);
615 } 615 }
616 }; 616 };
617 617
618 test.add_cleanup(stop_watching); 618 test.add_cleanup(stop_watching);
619 619
620 return this; 620 return this;
621 } 621 }
622 expose(EventWatcher, 'EventWatcher'); 622 expose(EventWatcher, 'EventWatcher');
623 623
624 function setup(func_or_properties, maybe_properties) 624 function setup(func_or_properties, maybe_properties)
(...skipping 2037 matching lines...) Expand 10 before | Expand all | Expand 10 after
2662 } 2662 }
2663 return supports; 2663 return supports;
2664 } 2664 }
2665 2665
2666 /** 2666 /**
2667 * Setup globals 2667 * Setup globals
2668 */ 2668 */
2669 2669
2670 var tests = new Tests(); 2670 var tests = new Tests();
2671 2671
2672 addEventListener("error", function(e) { 2672 var error_handler = function(e) {
2673 if (tests.file_is_test) { 2673 if (tests.file_is_test) {
2674 var test = tests.tests[0]; 2674 var test = tests.tests[0];
2675 if (test.phase >= test.phases.HAS_RESULT) { 2675 if (test.phase >= test.phases.HAS_RESULT) {
2676 return; 2676 return;
2677 } 2677 }
2678 test.set_status(test.FAIL, e.message, e.stack); 2678 test.set_status(test.FAIL, e.message, e.stack);
2679 test.phase = test.phases.HAS_RESULT; 2679 test.phase = test.phases.HAS_RESULT;
2680 test.done(); 2680 test.done();
2681 done(); 2681 done();
2682 } else if (!tests.allow_uncaught_exception) { 2682 } else if (!tests.allow_uncaught_exception) {
2683 tests.status.status = tests.status.ERROR; 2683 tests.status.status = tests.status.ERROR;
2684 tests.status.message = e.message; 2684 tests.status.message = e.message;
2685 tests.status.stack = e.stack; 2685 tests.status.stack = e.stack;
2686 } 2686 }
2687 }); 2687 };
2688
2689 addEventListener("error", error_handler, false);
2690 addEventListener("unhandledrejection", function(e){ error_handler(e.reason); }, false);
2688 2691
2689 test_environment.on_tests_ready(); 2692 test_environment.on_tests_ready();
2690 2693
2691 })(); 2694 })();
2692 // vim: set expandtab shiftwidth=4 tabstop=4: 2695 // vim: set expandtab shiftwidth=4 tabstop=4:
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/resources/idlharness.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698