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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/inspector/devtools-js/console/command-line-api.js

Issue 2975523002: DevTools: add console test helpers to new test runner & migrate a console test (Closed)
Patch Set: fix Created 3 years, 5 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
Index: third_party/WebKit/LayoutTests/http/tests/inspector/devtools-js/console/command-line-api.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/devtools-js/console/command-line-api.js b/third_party/WebKit/LayoutTests/http/tests/inspector/devtools-js/console/command-line-api.js
new file mode 100644
index 0000000000000000000000000000000000000000..d1ce0590860fa8e191093fe38b281cc9140f6925
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/devtools-js/console/command-line-api.js
@@ -0,0 +1,58 @@
+// 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.
+
+(async function() {
+ TestRunner.addResult('Tests that command line api works.\n');
+
+ await TestRunner.loadModule("console_test_runner");
+ await TestRunner.loadModule("elements_test_runner");
+ await TestRunner.loadPanel("console");
caseq 2017/07/12 01:04:33 I wonder whether these need to be sequential. Woul
chenwilliam 2017/07/12 22:02:57 I a/b tested it (ran this test 100 times) and the
+
+ var expressions = [
+ "String($0)",
+ "$3",
+ "String(keys([3,4]))",
+ "String(values([3,4]))",
+ "String($('#foo'))",
+ "String($('#foo', document.body))",
+ "String($('#foo', 'non-node'))",
+ "String($('#foo', $('#bar')))",
+ "String($$('p'))",
+ "String($$('p', document.body))",
+ "String($('foo'))",
+ "console.assert(keys(window).indexOf('__commandLineAPI') === -1)"
+ ];
+
+ await TestRunner.loadHTML(`
+ <p id="foo">
+ Tests that command line api works.
+ </p><p id="bar"></p>
+ `);
+
+ ElementsTestRunner.selectNodeWithId("foo", step1);
+
+ function step1(node) {
+ var expression = expressions.shift();
+ if (!expression) {
+ step2();
+ return;
+ }
+ Common.console.log("");
+ ConsoleTestRunner.evaluateInConsole(expression, step1);
caseq 2017/07/12 01:04:33 Can we make it return a promise straight away? Als
chenwilliam 2017/07/12 22:02:58 Adding to @dgozman's comment, the plan is to keep
+ }
+
+ function step2() {
+ function assertNoBoundCommandLineAPI() {
+ ["__commandLineAPI", "__scopeChainForEval"].forEach(function(name) {
+ console.assert(!(name in window), "FAIL: Should be no " + name);
+ });
+ }
+ TestRunner.evaluateInPage(assertNoBoundCommandLineAPI, step3);
+ }
+
+ function step3() {
+ ConsoleTestRunner.dumpConsoleMessages();
+ TestRunner.completeTest();
+ }
+})();

Powered by Google App Engine
This is Rietveld 408576698