| 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;
|
|
|