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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/streams/resources/test-utils.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/streams/resources/test-utils.js b/third_party/WebKit/LayoutTests/http/tests/streams/resources/test-utils.js
index cc47898a608e93d5e5664d017607b4f4709f5370..723021e6153862dcb58df27a6cfdec5000270802 100644
--- a/third_party/WebKit/LayoutTests/http/tests/streams/resources/test-utils.js
+++ b/third_party/WebKit/LayoutTests/http/tests/streams/resources/test-utils.js
@@ -1,4 +1,6 @@
'use strict';
+// This file already exists upstream. We are duplicating and updating it here. Be sure to override the existing one
+// when upstreaming.
self.getterRejects = (t, obj, getterName, target) => {
const getter = Object.getOwnPropertyDescriptor(obj, getterName).get;
@@ -6,10 +8,10 @@ self.getterRejects = (t, obj, getterName, target) => {
return promise_rejects(t, new TypeError(), getter.call(target));
};
-self.methodRejects = (t, obj, methodName, target) => {
+self.methodRejects = (t, obj, methodName, target, args) => {
const method = obj[methodName];
- return promise_rejects(t, new TypeError(), method.call(target));
+ return promise_rejects(t, new TypeError(), method.apply(target, args));
};
self.getterThrows = (obj, getterName, target) => {
@@ -41,3 +43,11 @@ self.garbageCollect = () => {
};
self.delay = ms => new Promise(resolve => step_timeout(resolve, ms));
+
+// For tests which verify that the implementation doesn't do something it shouldn't, it's better not to use a
+// timeout. Instead, assume that any reasonable implementation is going to finish work after 2 times around the event
+// loop, and use flushAsyncEvents().then(() => assert_array_equals(...));
+// Some tests include promise resolutions which may mean the test code takes a couple of event loop visits itself. So go
+// around an extra 2 times to avoid complicating those tests.
+// TODO(ricea): Upstream this function to w3c repository.
+self.flushAsyncEvents = () => delay(0).then(() => delay(0)).then(() => delay(0)).then(() => delay(0));
« 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