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

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..6c420166cbff3d16e0773b5eb55dcc432111ed73
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/devtools-js/console/command-line-api.js
@@ -0,0 +1,57 @@
+// 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');
+ await TestRunner.loadHTML(`
+ <p id='foo'>
+ Tests that command line api works.
+ </p><p id='bar'></p>
+ `);
+
+ 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)`
+ ];
+
+ ElementsTestRunner.selectNodeWithId('foo', step1);
+
+ function step1(node) {
+ var expression = expressions.shift();
+ if (!expression) {
+ step2();
+ return;
+ }
+ Common.console.log('');
+ ConsoleTestRunner.evaluateInConsole(expression, step1);
+ }
+
+ 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