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

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: Update test expectations Created 6 years, 2 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
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/test-helpers.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 /* 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 a promise that fulfills after the provided |promise| is fulfilled.
89 // The |test| succeeds only if |promise| rejects with an exception matching
90 // |code|. Accepted values for |code| follow those accepted for assert_throws().
91 // The optional |description| describes the test being performed.
92 // E.g.:
93 // assert_promise_rejects(
94 // new Promise(...), // something that should throw an exception.
95 // 'NotFoundError',
96 // 'Should throw NotFoundError.');
97 //
98 // assert_promise_rejects(
99 // new Promise(...),
100 // new TypeError(),
101 // 'Should throw TypeError');
102 function assert_promise_rejects(promise, code, description) {
103 return promise.then(
104 function() {
105 throw 'assert_promise_rejects: ' + description + ' Promise did not throw.' ;
106 },
107 function(e) {
108 if (code !== undefined) {
109 assert_throws(code, function() { throw e; }, description);
110 }
111 });
112 }
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/test-helpers.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698