Bug 1406038 - Rename and enable browser_webconsole_bug_1050691_click_function_to_source.js in new console frontend; r=bgrins.
The test differs a bit from the old one since we are now testing that there is
a button to jump to definition.
MozReview-Commit-ID: DnC5uJ3pAea
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
@@ -15,18 +15,16 @@ support-files =
test_bug_770099_violation.html
test_bug_770099_violation.html^headers^
test_console_csp_ignore_reflected_xss_message.html
test_console_csp_ignore_reflected_xss_message.html^headers^
test_hpkp-invalid-headers.sjs
test_hsts-invalid-headers.sjs
test-autocomplete-in-stackframe.html
test-batching.html
- test-bug_1050691_click_function_to_source.html
- test-bug_1050691_click_function_to_source.js
test-bug_923281_console_log_filter.html
test-bug_923281_test1.js
test-bug_923281_test2.js
test-bug_939783_console_trace_duplicates.html
test-bug-585956-console-trace.html
test-bug-593003-iframe-wrong-hud-iframe.html
test-bug-593003-iframe-wrong-hud.html
test-bug-595934-canvas-css.html
@@ -83,16 +81,18 @@ support-files =
test-cd-iframe-child.html
test-cd-iframe-parent.html
test-console-api-iframe.html
test-cspro.html
test-cspro.html^headers^
test-iframe-child.html
test-iframe-parent.html
test-certificate-messages.html
+ test-click-function-to-source.html
+ test-click-function-to-source.js
test-closure-optimized-out.html
test-closures.html
test-console-api-stackframe.html
test-console-clear.html
test-console-column.html
test-console-count-external-file.js
test-console-count.html
test-console-extras.html
@@ -235,17 +235,16 @@ subsuite = clipboard
tags = mcb
[browser_webconsole_batching.js]
[browser_webconsole_block_mixedcontent_securityerrors.js]
tags = mcb
[browser_webconsole_cached_messages.js]
[browser_webconsole_cd_iframe.js]
[browser_webconsole_certificate_messages.js]
[browser_webconsole_click_function_to_source.js]
-skip-if = true # Bug 1406038
[browser_webconsole_clickable_urls.js]
[browser_webconsole_close_unfocused_window.js]
[browser_webconsole_closing_after_completion.js]
[browser_webconsole_close_sidebar.js]
[browser_webconsole_closure_inspection.js]
skip-if = true # Bug 1405250
[browser_webconsole_console_api_iframe.js]
[browser_webconsole_console_dir.js]
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_click_function_to_source.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_click_function_to_source.js
@@ -3,58 +3,42 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that clicking on a function displays its source in the debugger. See Bug 1050691.
"use strict";
const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
- "test/test-bug_1050691_click_function_to_source.html";
+ "new-console-output/test/mochitest/test-click-function-to-source.html";
// Force the old debugger UI since it's directly used (see Bug 1301705)
-Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
-registerCleanupFunction(function* () {
- Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
-});
+pushPref("devtools.debugger.new-debugger-frontend", false);
-add_task(function* () {
- yield loadTab(TEST_URI);
- let hud = yield openConsole();
-
- // Open the Debugger panel.
- let debuggerPanel = yield openDebugger();
- // And right after come back to the Console panel.
- yield openConsole();
- yield testWithDebuggerOpen(hud, debuggerPanel);
-});
+add_task(async function () {
+ const hud = await openNewTabAndConsole(TEST_URI);
-function* testWithDebuggerOpen(hud, debuggerPanel) {
- let clickable = yield printFunction(hud);
- let panelWin = debuggerPanel.panelWin;
- let onEditorLocationSet = panelWin.once(panelWin.EVENTS.EDITOR_LOCATION_SET);
- synthesizeClick(clickable, hud);
- yield onEditorLocationSet;
- ok(isDebuggerCaretPos(debuggerPanel, 7),
- "Clicking on a function should go to its source in the debugger view");
-}
+ info("Open the Debugger panel.");
+ const {panel} = await openDebugger();
+ let panelWin = panel.panelWin;
-function synthesizeClick(clickable, hud) {
- EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
-}
+ info("And right after come back to the Console panel.")
+ await openConsole();
-var printFunction = Task.async(function* (hud) {
- hud.jsterm.clearOutput();
- ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
+ info("Log a function");
+ const onLoggedFunction = waitForMessage(hud, "function foo")
+ ContentTask.spawn(gBrowser.selectedBrowser, {}, function () {
content.wrappedJSObject.foo();
});
- let [result] = yield waitForMessages({
- webconsole: hud,
- messages: [{
- category: CATEGORY_WEBDEV,
- severity: SEVERITY_LOG,
- }],
- });
- let msg = [...result.matched][0];
- let clickable = msg.querySelector("a");
- ok(clickable, "clickable item for object should exist");
- return clickable;
+ const {node} = await onLoggedFunction;
+ const jumpIcon = node.querySelector(".jump-definition")
+ ok(jumpIcon, "A jump to definition button is rendered, as expected");
+
+ info("Click on the jump to definition button.");
+ let onEditorLocationSet = panelWin.once(panelWin.EVENTS.EDITOR_LOCATION_SET);
+ jumpIcon.click();
+ await onEditorLocationSet;
+
+ const {editor} = panelWin.DebuggerView;
+ const {line, ch} = editor.getCursor();
+ // Source editor starts counting line and column numbers from 0.
+ ok(line === 6 && ch === 0, "Debugger is open at the expected position");
});
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug_1050691_click_function_to_source.html
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-click-function-to-source.html
--- a/devtools/client/webconsole/new-console-output/test/mochitest/test-bug_1050691_click_function_to_source.html
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/test-click-function-to-source.html
@@ -1,11 +1,11 @@
<!DOCTYPE HTML>
<html dir="ltr" xml:lang="en-US" lang="en-US">
<head>
<meta charset="utf-8">
<title>Click on function should point to source</title>
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
- <script type="text/javascript" src="test-bug_1050691_click_function_to_source.js"></script>
+ <script type="text/javascript" src="test-click-function-to-source.js"></script>
</head>
<body></body>
</html>
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug_1050691_click_function_to_source.js
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-click-function-to-source.js