Chromium Code Reviews| Index: test/inspector/runtime/runtime-restore.js |
| diff --git a/test/inspector/runtime/runtime-restore.js b/test/inspector/runtime/runtime-restore.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5c2fea5768d9f1b92147ca0cf22ddb8592464063 |
| --- /dev/null |
| +++ b/test/inspector/runtime/runtime-restore.js |
| @@ -0,0 +1,77 @@ |
| +// Copyright 2017 the V8 project authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file.v8 |
| + |
| +InspectorTest.log('Checks that Runtime agent correctly restore its state.'); |
| + |
| +InspectorTest.addScript(` |
| +var formatter = { |
| + header: function(x) |
| + { |
| + return ["span", {}, "Header formatted ", x.name]; |
| + }, |
| + |
| + hasBody: function(x) |
| + { |
| + return true; |
| + }, |
| + |
| + body: function(x) |
| + { |
| + return ["span", {}, "Body formatted ", x.name] |
| + } |
| +}; |
| + |
| +devtoolsFormatters = [ formatter ]; |
| + |
| +//# sourceURL=test.js`) |
| + |
| +InspectorTest.runTestSuite([ |
| + function testExecutionContextsNotificationsOnRestore(next) { |
| + Protocol.Runtime.onExecutionContextsCleared(InspectorTest.logMessage); |
|
dgozman
2017/02/28 19:46:40
Future idea: automatic way to remove all listeners
|
| + Protocol.Runtime.onExecutionContextCreated(InspectorTest.logMessage); |
| + Protocol.Runtime.onExecutionContextDestroyed(InspectorTest.logMessage); |
| + Protocol.Runtime.enable() |
| + .then(reconnect) |
| + .then(Protocol.Runtime.disable) |
| + .then(() => { |
| + Protocol.Runtime.onExecutionContextsCleared(null); |
| + Protocol.Runtime.onExecutionContextCreated(null); |
| + Protocol.Runtime.onExecutionContextDestroyed(null); |
| + next() |
| + }); |
| + }, |
| + |
| + function testConsoleAPICalledAfterRestore(next) { |
| + Protocol.Runtime.onConsoleAPICalled(InspectorTest.logMessage); |
| + Protocol.Runtime.enable() |
| + .then(reconnect) |
| + .then(() => Protocol.Runtime.evaluate({ expression: 'console.log(42);' })) |
| + .then(Protocol.Runtime.disable) |
| + .then(() => { |
| + Protocol.Runtime.onConsoleAPICalled(null); |
| + next(); |
| + }); |
| + }, |
| + |
| + function testSetCustomObjectFormatterEnabled(next) { |
| + Protocol.Runtime.onConsoleAPICalled(InspectorTest.logMessage); |
| + // cleanup console message storage |
| + reconnect(); |
| + Protocol.Runtime.enable() |
| + .then(() => Protocol.Runtime.setCustomObjectFormatterEnabled({ enabled: true })) |
| + .then(reconnect) |
| + .then(() => Protocol.Runtime.evaluate({ expression: 'console.log({ name: 42 })'})) |
| + .then(InspectorTest.logMessage) |
| + .then(Protocol.Runtime.disable) |
| + .then(() => { |
| + Protocol.Runtime.onConsoleAPICalled(null); |
| + next(); |
| + }); |
| + }, |
| +]); |
| + |
| +function reconnect() { |
| + InspectorTest.logMessage('will reconnect..'); |
| + utils.reconnect(); |
| +} |