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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/streams/resources/test-utils.js

Issue 2642393002: Import wpt@40665266227e475bc4a56884247d8c09d78dfb6a (Closed)
Patch Set: rebaseline-cl Created 3 years, 11 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 'use strict'; 1 'use strict';
2 2
3 self.getterRejects = (t, obj, getterName, target) => { 3 self.getterRejects = (t, obj, getterName, target) => {
4 const getter = Object.getOwnPropertyDescriptor(obj, getterName).get; 4 const getter = Object.getOwnPropertyDescriptor(obj, getterName).get;
5 5
6 return promise_rejects(t, new TypeError(), getter.call(target)); 6 return promise_rejects(t, new TypeError(), getter.call(target));
7 }; 7 };
8 8
9 self.methodRejects = (t, obj, methodName, target) => { 9 self.methodRejects = (t, obj, methodName, target, args) => {
10 const method = obj[methodName]; 10 const method = obj[methodName];
11 11
12 return promise_rejects(t, new TypeError(), method.call(target)); 12 return promise_rejects(t, new TypeError(), method.apply(target, args));
13 }; 13 };
14 14
15 self.getterThrows = (obj, getterName, target) => { 15 self.getterThrows = (obj, getterName, target) => {
16 const getter = Object.getOwnPropertyDescriptor(obj, getterName).get; 16 const getter = Object.getOwnPropertyDescriptor(obj, getterName).get;
17 17
18 assert_throws(new TypeError(), () => getter.call(target), getterName + ' shoul d throw a TypeError'); 18 assert_throws(new TypeError(), () => getter.call(target), getterName + ' shoul d throw a TypeError');
19 }; 19 };
20 20
21 self.methodThrows = (obj, methodName, target, args) => { 21 self.methodThrows = (obj, methodName, target, args) => {
22 const method = obj[methodName]; 22 const method = obj[methodName];
(...skipping 11 matching lines...) Expand all
34 GCController.collect(); 34 GCController.collect();
35 } else { 35 } else {
36 /* eslint-disable no-console */ 36 /* eslint-disable no-console */
37 console.warn('Tests are running without the ability to do manual garbage col lection. They will still work, but ' + 37 console.warn('Tests are running without the ability to do manual garbage col lection. They will still work, but ' +
38 'coverage will be suboptimal.'); 38 'coverage will be suboptimal.');
39 /* eslint-enable no-console */ 39 /* eslint-enable no-console */
40 } 40 }
41 }; 41 };
42 42
43 self.delay = ms => new Promise(resolve => step_timeout(resolve, ms)); 43 self.delay = ms => new Promise(resolve => step_timeout(resolve, ms));
44
45 // For tests which verify that the implementation doesn't do something it should n't, it's better not to use a
46 // timeout. Instead, assume that any reasonable implementation is going to finis h work after 2 times around the event
47 // loop, and use flushAsyncEvents().then(() => assert_array_equals(...));
48 // Some tests include promise resolutions which may mean the test code takes a c ouple of event loop visits itself. So go
49 // around an extra 2 times to avoid complicating those tests.
50 self.flushAsyncEvents = () => delay(0).then(() => delay(0)).then(() => delay(0)) .then(() => delay(0));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698