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

Side by Side Diff: LayoutTests/http/tests/serviceworker/resources/worker-test-harness.js

Issue 430993002: [ServiceWorker] CacheStorage tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * worker-test-harness should be considered a temporary polyfill around 2 * worker-test-harness should be considered a temporary polyfill around
3 * testharness.js for supporting Service Worker based tests. It should not be 3 * testharness.js for supporting Service Worker based tests. It should not be
4 * necessary once the test harness is able to drive worker based tests natively. 4 * necessary once the test harness is able to drive worker based tests natively.
5 * See https://github.com/w3c/testharness.js/pull/82 for status of effort to 5 * See https://github.com/w3c/testharness.js/pull/82 for status of effort to
6 * update upstream testharness.js. Once the upstreaming is complete, tests that 6 * update upstream testharness.js. Once the upstreaming is complete, tests that
7 * reference worker-test-harness should be updated to directly import 7 * reference worker-test-harness should be updated to directly import
8 * testharness.js. 8 * testharness.js.
9 */ 9 */
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // boilerplate for testing with promises. 77 // boilerplate for testing with promises.
78 function promise_test(func, name, properties) { 78 function promise_test(func, name, properties) {
79 properties = properties || {}; 79 properties = properties || {};
80 var test = async_test(name, properties); 80 var test = async_test(name, properties);
81 Promise.resolve(test.step(func, test, test)) 81 Promise.resolve(test.step(func, test, test))
82 .then(function() { test.done(); }) 82 .then(function() { test.done(); })
83 .catch(test.step_func(function(value) { 83 .catch(test.step_func(function(value) {
84 throw value; 84 throw value;
85 })); 85 }));
86 } 86 }
87
88 // Returns promise that fulfills after the provided |promise| is fulfilled. The
jsbell 2014/08/15 21:36:13 nit: Returns a promise...
asanka 2014/08/20 03:10:29 Done.
89 // |test| succeeds only if |promise| throws a DOM exception matching |code|. The
jsbell 2014/08/15 21:36:13 I don't believe this needs to be a DOMException, e
asanka 2014/08/20 03:10:29 Changed.
90 // optional |description| describes the test being performed.
91 // E.g.:
92 // expect_promise_throws(
93 // test, new Promise(...), // something that should throw
94 // // a DOM exception.
95 // 'NotFoundError',
96 // 'Should throw NotFoundError.');
97 function expect_promise_throws(test, promise, code, description) {
98 return promise.then(
99 test.step_func(function() {
100 throw "expect_promise_throws: " + description + " Promise did now throw. "
jsbell 2014/08/15 21:36:13 Use assert_unreached or unreached_func?
jsbell 2014/08/15 21:36:13 nit: line length (80 cols)
asanka 2014/08/20 03:10:29 Looks like it's exactly 80? Also I chose to throw
101 }),
102 test.step_func(function(e) {
103 assert_throws(code, function() { throw e; }, description);
104 }));
105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698