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

Unified Diff: test/inspector/sessions/runtime-command-line-api.js

Issue 2916803005: [inspector] Create InjectedScript per session in each context (Closed)
Patch Set: rebased 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/inspector/protocol-test.js ('k') | test/inspector/sessions/runtime-command-line-api-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/inspector/sessions/runtime-command-line-api.js
diff --git a/test/inspector/sessions/runtime-command-line-api.js b/test/inspector/sessions/runtime-command-line-api.js
new file mode 100644
index 0000000000000000000000000000000000000000..078783ac659930dc1387038357c41663dda32be3
--- /dev/null
+++ b/test/inspector/sessions/runtime-command-line-api.js
@@ -0,0 +1,76 @@
+// 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.
+
+InspectorTest.log('Tests that multiple sessions do not share command line api.');
+
+(async function test() {
+ var contextGroup = new InspectorTest.ContextGroup();
+ var session1 = contextGroup.connect();
+ await session1.Protocol.Runtime.enable();
+ session1.Protocol.Runtime.onInspectRequested(message => {
+ InspectorTest.log('inspectRequested from 1');
+ InspectorTest.logMessage(message);
+ });
+ var session2 = contextGroup.connect();
+ await session2.Protocol.Runtime.enable();
+ session2.Protocol.Runtime.onInspectRequested(message => {
+ InspectorTest.log('inspectRequested from 2');
+ InspectorTest.logMessage(message);
+ });
+
+ InspectorTest.log('Setting $0 in 1');
+ await session1.addInspectedObject(42);
+ InspectorTest.log('Evaluating $0 in 1');
+ InspectorTest.logMessage(await session1.Protocol.Runtime.evaluate({expression: '$0', includeCommandLineAPI: true}));
+ InspectorTest.log('Evaluating $0 in 2');
+ InspectorTest.logMessage(await session2.Protocol.Runtime.evaluate({expression: '$0', includeCommandLineAPI: true}));
+
+ InspectorTest.log('Setting $0 in 2');
+ await session2.addInspectedObject(17);
+ InspectorTest.log('Evaluating $0 in 1');
+ InspectorTest.logMessage(await session1.Protocol.Runtime.evaluate({expression: '$0', includeCommandLineAPI: true}));
+ InspectorTest.log('Evaluating $0 in 2');
+ InspectorTest.logMessage(await session2.Protocol.Runtime.evaluate({expression: '$0', includeCommandLineAPI: true}));
+
+ InspectorTest.log('Setting $_ in 1');
+ await session1.Protocol.Runtime.evaluate({expression: '42', objectGroup: 'console', includeCommandLineAPI: true});
+ InspectorTest.log('Evaluating $_ in 1');
+ InspectorTest.logMessage(await session1.Protocol.Runtime.evaluate({expression: '$_', includeCommandLineAPI: true}));
+ InspectorTest.log('Evaluating $_ in 2');
+ InspectorTest.logMessage(await session2.Protocol.Runtime.evaluate({expression: '$_', includeCommandLineAPI: true}));
+
+ InspectorTest.log('Setting $_ in 2');
+ await session2.Protocol.Runtime.evaluate({expression: '17', objectGroup: 'console', includeCommandLineAPI: true});
+ InspectorTest.log('Evaluating $_ in 1');
+ InspectorTest.logMessage(await session1.Protocol.Runtime.evaluate({expression: '$_', includeCommandLineAPI: true}));
+ InspectorTest.log('Evaluating $_ in 2');
+ InspectorTest.logMessage(await session2.Protocol.Runtime.evaluate({expression: '$_', includeCommandLineAPI: true}));
+
+ InspectorTest.log('Inspecting in 1');
+ await session1.Protocol.Runtime.evaluate({expression: 'var inspect1=inspect; inspect(42)', includeCommandLineAPI: true});
+ InspectorTest.log('Inspecting in 1 through variable');
+ await session1.Protocol.Runtime.evaluate({expression: 'inspect1(42)', includeCommandLineAPI: true});
+ InspectorTest.log('Inspecting in 2');
+ await session2.Protocol.Runtime.evaluate({expression: 'var inspect2=inspect; inspect(17)', includeCommandLineAPI: true});
+ InspectorTest.log('Inspecting in 2 through variable');
+ await session2.Protocol.Runtime.evaluate({expression: 'inspect2(17)', includeCommandLineAPI: true});
+ InspectorTest.log('Inspecting in 2 through variable from 1');
+ await session2.Protocol.Runtime.evaluate({expression: 'inspect1(42)', includeCommandLineAPI: true});
+
+ InspectorTest.log('Disconnecting 1');
+ session1.disconnect();
+
+ InspectorTest.log('Evaluating $0 in 2');
+ InspectorTest.logMessage(await session2.Protocol.Runtime.evaluate({expression: '$0', includeCommandLineAPI: true}));
+ InspectorTest.log('Evaluating $_ in 2');
+ InspectorTest.logMessage(await session2.Protocol.Runtime.evaluate({expression: '$_', includeCommandLineAPI: true}));
+ InspectorTest.log('Inspecting in 2');
+ await session2.Protocol.Runtime.evaluate({expression: 'inspect(17)', includeCommandLineAPI: true});
+ InspectorTest.log('Inspecting in 2 through variable from 1');
+ await session2.Protocol.Runtime.evaluate({expression: 'inspect1(42)', includeCommandLineAPI: true});
+ InspectorTest.log('Inspecting in 2 through variable');
+ await session2.Protocol.Runtime.evaluate({expression: 'inspect2(17)', includeCommandLineAPI: true});
+
+ InspectorTest.completeTest();
+})();
« no previous file with comments | « test/inspector/protocol-test.js ('k') | test/inspector/sessions/runtime-command-line-api-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698