Chromium Code Reviews| 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..3b72d69b7194e0c96a4aa32b2df219c0693fcedf |
| --- /dev/null |
| +++ b/headless/test/bindings_test.js |
| @@ -0,0 +1,37 @@ |
| +// 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.require('chromium.DevTools.Connection'); |
| +goog.require('chromium.DevTools.DOM'); |
| +goog.require('chromium.DevTools.Runtime'); |
| +goog.provide('chromium.BindingsTest'); |
| + |
| +/** |
| + * Evaluates 1+1 and returns the result over the chromium.DevTools.Connection. |
| + */ |
| +chromium.BindingsTest.evalOneAddOne = function() { |
| + let connection = new chromium.DevTools.Connection(window.TabSocket); |
| + let Runtime = new chromium.DevTools.Runtime(connection); |
| + Runtime.Evaluate({'expression': '1+1'}).then(function(message) { |
| + connection.sendDevToolsMessage( |
| + '__Result', |
| + {'result': JSON.stringify(message.result.value)}); |
| + }); |
| +}; |
| + |
| +chromium.BindingsTest.listenForChildNodeCountUpdated = function() { |
| + let connection = new chromium.DevTools.Connection(window.TabSocket); |
| + let DOM = new chromium.DevTools.DOM(connection); |
| + DOM.OnChildNodeCountUpdated(function(params) { |
| + connection.sendDevToolsMessage('__Result', |
| + {'result': JSON.stringify(params)}); |
| + }); |
| + 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.
|
| + 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.
|
| + // Create a new div which should trigger the event. |
| + let div = document.createElement('div'); |
| + document.body.appendChild(div); |
| + }); |
| + }); |
| +}; |