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

Unified Diff: headless/test/bindings_test.js

Issue 2902583002: Add some closureised JS bindings for DevTools for use by headless embedder (Closed)
Patch Set: Try and fix python test Created 3 years, 6 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
« no previous file with comments | « headless/lib/tab_socket_externs.js ('k') | headless/test/headless_js_bindings_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/test/bindings_test.js
diff --git a/headless/test/bindings_test.js b/headless/test/bindings_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..cc035e1caedc77c85f1479f7df65037d551e21e0
--- /dev/null
+++ b/headless/test/bindings_test.js
@@ -0,0 +1,52 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+goog.module('chromium.BindingsTest');
+// Needed to let C++ invoke the test.
+goog.module.declareLegacyNamespace();
+
+const Connection = goog.require('chromium.DevTools.Connection');
+const DOM = goog.require('chromium.DevTools.DOM');
+const Runtime = goog.require('chromium.DevTools.Runtime');
+
+/**
+ * A trivial test which is invoked from C++ by HeadlessJsBindingsTest.
+ */
+class BindingsTest {
+ constructor() {}
+
+ /**
+ * Evaluates 1+1 and returns the result over the chromium.DevTools.Connection.
+ */
+ evalOneAddOne() {
+ let connection = new Connection(window.TabSocket);
+ let runtime = new Runtime(connection);
+ runtime.Evaluate({'expression': '1+1'}).then(function(message) {
+ connection.sendDevToolsMessage(
+ '__Result',
+ {'result': JSON.stringify(message.result.value)});
+ });
+ }
+
+ /**
+ * Evaluates 1+1 and returns the result over the chromium.DevTools.Connection.
+ */
+ listenForChildNodeCountUpdated() {
+ let connection = new Connection(window.TabSocket);
+ let dom = new DOM(connection);
+ dom.OnChildNodeCountUpdated(function(params) {
+ connection.sendDevToolsMessage('__Result',
+ {'result': JSON.stringify(params)});
+ });
+ dom.Enable().then(function() {
+ return dom.GetDocument({});
+ }).then(function() {
+ // Create a new div which should trigger the event.
+ let div = document.createElement('div');
+ document.body.appendChild(div);
+ });
+ }
+}
+
+exports = BindingsTest;
« no previous file with comments | « headless/lib/tab_socket_externs.js ('k') | headless/test/headless_js_bindings_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698