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

Unified Diff: third_party/WebKit/LayoutTests/resources/mojo-helpers.js

Issue 1470823002: Enable builtin Mojo JS modules in layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@usb-testing
Patch Set: oops, clumsy Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/resources/mojo-helpers.js
diff --git a/third_party/WebKit/LayoutTests/resources/mojo-helpers.js b/third_party/WebKit/LayoutTests/resources/mojo-helpers.js
new file mode 100644
index 0000000000000000000000000000000000000000..8752dd16989983ce2aea49bc3eaa26e35a1f4f8b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/resources/mojo-helpers.js
@@ -0,0 +1,37 @@
+/*
+ * mojo-helpers contains extensions to testharness.js useful for consuming
+ * and mocking Mojo services directly within test code.
+ */
+'use strict';
+
+// Runs a promise_test which depends on the Mojo system API modules available to
+// all layout tests. The test implementation function is called with an Object
+// that exposes common Mojo module interfaces.
+function mojo_test(func, name, properties) {
+ // Fix up the global window.define, since all baked-in Mojo modules expect to
+ // find it there.
+ window.define = mojo.define;
+
+ promise_test(() => {
+ return new Promise((resolve, reject) => {
+ define('Mojo layout test module: ' + name, [
+ 'mojo/public/js/core',
+ 'mojo/public/js/router',
+ 'content/public/renderer/service_provider',
+ ], (core, router, serviceProvider) => {
+ try {
+ resolve(func({
+ core: core,
+ router: router,
+
+ // |serviceProvider| is a bit of a misnomer. It should probably be
+ // called |serviceRegistry|, so let's call it that here.
+ serviceRegistry: serviceProvider,
+ }));
+ } catch (e) {
+ reject(e);
+ }
+ });
+ });
+ }, name, properties);
+}

Powered by Google App Engine
This is Rietveld 408576698