OLD | NEW |
(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; |
OLD | NEW |