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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 goog.module('chromium.BindingsTest');
6 // Needed to let C++ invoke the test.
7 goog.module.declareLegacyNamespace();
8
9 const Connection = goog.require('chromium.DevTools.Connection');
10 const DOM = goog.require('chromium.DevTools.DOM');
11 const Runtime = goog.require('chromium.DevTools.Runtime');
12
13 /**
14 * A trivial test which is invoked from C++ by HeadlessJsBindingsTest.
15 */
16 class BindingsTest {
17 constructor() {}
18
19 /**
20 * Evaluates 1+1 and returns the result over the chromium.DevTools.Connection.
21 */
22 evalOneAddOne() {
23 let connection = new Connection(window.TabSocket);
24 let runtime = new Runtime(connection);
25 runtime.Evaluate({'expression': '1+1'}).then(function(message) {
26 connection.sendDevToolsMessage(
27 '__Result',
28 {'result': JSON.stringify(message.result.value)});
29 });
30 }
31
32 /**
33 * Evaluates 1+1 and returns the result over the chromium.DevTools.Connection.
34 */
35 listenForChildNodeCountUpdated() {
36 let connection = new Connection(window.TabSocket);
37 let dom = new DOM(connection);
38 dom.OnChildNodeCountUpdated(function(params) {
39 connection.sendDevToolsMessage('__Result',
40 {'result': JSON.stringify(params)});
41 });
42 dom.Enable().then(function() {
43 return dom.GetDocument({});
44 }).then(function() {
45 // Create a new div which should trigger the event.
46 let div = document.createElement('div');
47 document.body.appendChild(div);
48 });
49 }
50 }
51
52 exports = BindingsTest;
OLDNEW
« 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