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

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

Issue 1404523005: Implement author-constructible ReadableStream using V8 extras (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
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
new file mode 100644
index 0000000000000000000000000000000000000000..2ce3dc3c230a20925c5ebdb6c8440e84006aed0c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/streams/resources/test-utils.js
@@ -0,0 +1,55 @@
+'use strict';
+
+self.getterRejects = function(test, obj, getterName, target, endTest) {
+ var getter = Object.getOwnPropertyDescriptor(obj, getterName).get;
+
+ getter.call(target).then(
+ test.step_func(function() { assert_unreached(getterName + ' should not fulfill'); }),
+ test.step_func(function(e) {
+ assert_throws(new TypeError(), function() { throw e; }, getterName + ' should reject with a TypeError');
+ if (endTest === true) {
+ test.done();
+ }
+ }));
+};
+
+self.methodRejects = function (test, obj, methodName, target, endTest) {
+ var method = obj[methodName];
+
+ method.call(target).then(
+ test.step_func(function() { assert_unreached(methodName + ' should not fulfill'); }),
+ test.step_func(function(e) {
+ assert_throws(new TypeError(), function() { throw e; }, methodName + ' should reject with a TypeError');
+ if (endTest === true) {
+ test.done();
+ }
+ }));
+};
+
+self.getterThrows = function (obj, getterName, target) {
+ var getter = Object.getOwnPropertyDescriptor(obj, getterName).get;
+
+ assert_throws(new TypeError(), function() { getter.call(target); }, getterName + ' should throw a TypeError');
+};
+
+self.methodThrows = function (obj, methodName, target) {
+ var method = obj[methodName];
+
+ assert_throws(new TypeError(), function() { method.call(target); }, methodName + ' should throw a TypeError');
+};
+
+self.garbageCollect = () => {
+ if (self.gc) {
+ // Use --expose_gc for V8 (and Node.js)
+ // Exposed in SpiderMonkey shell as well
+ self.gc();
+ } else if (self.GCController) {
+ // Present in some WebKit development environments
+ GCController.collect();
+ } else {
+ console.warn('Tests are running without the ability to do manual garbage collection. They will still work, but ' +
+ 'coverage will be suboptimal.');
+ }
+};
+
+self.delay = ms => new Promise(resolve => setTimeout(resolve, ms));

Powered by Google App Engine
This is Rietveld 408576698