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

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: Make the JS better 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
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.require('chromium.DevTools.Connection');
6 goog.require('chromium.DevTools.DOM');
7 goog.require('chromium.DevTools.Runtime');
8 goog.provide('chromium.BindingsTest');
9
10 /**
11 * Evaluates 1+1 and returns the result over the chromium.DevTools.Connection.
12 */
13 chromium.BindingsTest.evalOneAddOne = function() {
14 let connection = new chromium.DevTools.Connection(window.TabSocket);
15 let Runtime = new chromium.DevTools.Runtime(connection);
16 Runtime.Evaluate({'expression': '1+1'}).then(function(message) {
17 connection.sendDevToolsMessage(
18 '__Result',
19 {'result': JSON.stringify(message.result.value)});
20 });
21 };
22
23 chromium.BindingsTest.listenForChildNodeCountUpdated = function() {
24 let connection = new chromium.DevTools.Connection(window.TabSocket);
25 let DOM = new chromium.DevTools.DOM(connection);
26 DOM.OnChildNodeCountUpdated(function(params) {
27 connection.sendDevToolsMessage('__Result',
28 {'result': JSON.stringify(params)});
29 });
30 DOM.Enable().then(function() {
dpapad 2017/06/07 17:49:23 Prefer Promise chaining over nesting where possibl
alex clarke (OOO till 29th) 2017/06/08 10:33:16 Done.
31 DOM.GetDocument({}).then(function(result) {
dpapad 2017/06/07 17:49:23 |result| is not being used anywhere. Can you omit
alex clarke (OOO till 29th) 2017/06/08 10:33:16 Done.
32 // Create a new div which should trigger the event.
33 let div = document.createElement('div');
34 document.body.appendChild(div);
35 });
36 });
37 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698