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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/streams/resources/test-utils.js

Issue 2500833002: Import latest WritableStream tests from upstream (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | third_party/WebKit/LayoutTests/http/tests/streams/writable-streams/aborting.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 'use strict'; 1 'use strict';
2 // This file already exists upstream. We are duplicating and updating it here. B e sure to override the existing one
3 // when upstreaming.
2 4
3 self.getterRejects = (t, obj, getterName, target) => { 5 self.getterRejects = (t, obj, getterName, target) => {
4 const getter = Object.getOwnPropertyDescriptor(obj, getterName).get; 6 const getter = Object.getOwnPropertyDescriptor(obj, getterName).get;
5 7
6 return promise_rejects(t, new TypeError(), getter.call(target)); 8 return promise_rejects(t, new TypeError(), getter.call(target));
7 }; 9 };
8 10
9 self.methodRejects = (t, obj, methodName, target) => { 11 self.methodRejects = (t, obj, methodName, target, args) => {
10 const method = obj[methodName]; 12 const method = obj[methodName];
11 13
12 return promise_rejects(t, new TypeError(), method.call(target)); 14 return promise_rejects(t, new TypeError(), method.apply(target, args));
13 }; 15 };
14 16
15 self.getterThrows = (obj, getterName, target) => { 17 self.getterThrows = (obj, getterName, target) => {
16 const getter = Object.getOwnPropertyDescriptor(obj, getterName).get; 18 const getter = Object.getOwnPropertyDescriptor(obj, getterName).get;
17 19
18 assert_throws(new TypeError(), () => getter.call(target), getterName + ' shoul d throw a TypeError'); 20 assert_throws(new TypeError(), () => getter.call(target), getterName + ' shoul d throw a TypeError');
19 }; 21 };
20 22
21 self.methodThrows = (obj, methodName, target, args) => { 23 self.methodThrows = (obj, methodName, target, args) => {
22 const method = obj[methodName]; 24 const method = obj[methodName];
(...skipping 11 matching lines...) Expand all
34 GCController.collect(); 36 GCController.collect();
35 } else { 37 } else {
36 /* eslint-disable no-console */ 38 /* eslint-disable no-console */
37 console.warn('Tests are running without the ability to do manual garbage col lection. They will still work, but ' + 39 console.warn('Tests are running without the ability to do manual garbage col lection. They will still work, but ' +
38 'coverage will be suboptimal.'); 40 'coverage will be suboptimal.');
39 /* eslint-enable no-console */ 41 /* eslint-enable no-console */
40 } 42 }
41 }; 43 };
42 44
43 self.delay = ms => new Promise(resolve => step_timeout(resolve, ms)); 45 self.delay = ms => new Promise(resolve => step_timeout(resolve, ms));
46
47 // For tests which verify that the implementation doesn't do something it should n't, it's better not to use a
48 // timeout. Instead, assume that any reasonable implementation is going to finis h work after 2 times around the event
49 // loop, and use flushAsyncEvents().then(() => assert_array_equals(...));
50 // Some tests include promise resolutions which may mean the test code takes a c ouple of event loop visits itself. So go
51 // around an extra 2 times to avoid complicating those tests.
52 // TODO(ricea): Upstream this function to w3c repository.
53 self.flushAsyncEvents = () => delay(0).then(() => delay(0)).then(() => delay(0)) .then(() => delay(0));
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/streams/writable-streams/aborting.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698