mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-29 09:52:50 -10:00
We were always opening the debugger when clicking on the location link, which could be wrong since we can have CSS warnings, or logs coming from Scratchpad. So we add the function to open in StyleEditor and Scratchpad, and copy some mochitests that where testing the interaction with those links. MozReview-Commit-ID: 73mQNfy199m
104 lines
3.5 KiB
HTML
104 lines
3.5 KiB
HTML
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
|
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
|
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
Test the rendering of a stack trace
|
|
-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>StackTrace component test</title>
|
|
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
|
</head>
|
|
<body>
|
|
<script src="head.js"></script>
|
|
<script>
|
|
/* import-globals-from head.js */
|
|
"use strict";
|
|
|
|
window.onload = function () {
|
|
let ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");
|
|
let React = browserRequire("devtools/client/shared/vendor/react");
|
|
let StackTrace = React.createFactory(
|
|
browserRequire("devtools/client/shared/components/stack-trace")
|
|
);
|
|
ok(StackTrace, "Got the StackTrace factory");
|
|
|
|
add_task(function* () {
|
|
let stacktrace = [
|
|
{
|
|
filename: "http://myfile.com/mahscripts.js",
|
|
lineNumber: 55,
|
|
columnNumber: 10
|
|
},
|
|
{
|
|
asyncCause: "because",
|
|
functionName: "loadFunc",
|
|
filename: "http://myfile.com/loader.js -> http://myfile.com/loadee.js",
|
|
lineNumber: 10
|
|
}
|
|
];
|
|
|
|
let props = {
|
|
stacktrace,
|
|
onViewSourceInDebugger: () => {},
|
|
onViewSourceInScratchpad: () => {},
|
|
};
|
|
|
|
let trace = ReactDOM.render(StackTrace(props), window.document.body);
|
|
yield forceRender(trace);
|
|
|
|
let traceEl = ReactDOM.findDOMNode(trace);
|
|
ok(traceEl, "Rendered StackTrace has an element");
|
|
|
|
// Get the child nodes and filter out the text-only whitespace ones
|
|
let frameEls = Array.from(traceEl.childNodes)
|
|
.filter(n => n.className && n.className.includes("frame"));
|
|
ok(frameEls, "Rendered StackTrace has frames");
|
|
is(frameEls.length, 3, "StackTrace has 3 frames");
|
|
|
|
// Check the top frame, function name should be anonymous
|
|
checkFrameString({
|
|
el: frameEls[0],
|
|
functionName: "<anonymous>",
|
|
source: "http://myfile.com/mahscripts.js",
|
|
file: "http://myfile.com/mahscripts.js",
|
|
line: 55,
|
|
column: 10,
|
|
shouldLink: true,
|
|
tooltip: "View source in Debugger → http://myfile.com/mahscripts.js:55:10",
|
|
});
|
|
|
|
// Check the async cause node
|
|
is(frameEls[1].className, "frame-link-async-cause",
|
|
"Async cause has the right class");
|
|
is(frameEls[1].textContent, "(Async: because)", "Async cause has the right label");
|
|
|
|
// Check the third frame, the source should be parsed into a valid source URL
|
|
checkFrameString({
|
|
el: frameEls[2],
|
|
functionName: "loadFunc",
|
|
source: "http://myfile.com/loadee.js",
|
|
file: "http://myfile.com/loadee.js",
|
|
line: 10,
|
|
column: null,
|
|
shouldLink: true,
|
|
tooltip: "View source in Debugger → http://myfile.com/loadee.js:10",
|
|
});
|
|
|
|
// Check the tabs and newlines in the stack trace textContent
|
|
let traceText = traceEl.textContent;
|
|
let traceLines = traceText.split("\n");
|
|
ok(traceLines.length > 0, "There are newlines in the stack trace text");
|
|
is(traceLines.pop(), "", "There is a newline at the end of the stack trace text");
|
|
is(traceLines.length, 3, "The stack trace text has 3 lines");
|
|
ok(traceLines.every(l => l[0] == "\t"), "Every stack trace line starts with tab");
|
|
});
|
|
};
|
|
</script>
|
|
</body>
|
|
</html>
|