Bug 1377851 - Load code mirror frame from external file within devtools. r=pbrosset

This commit is contained in:
Christoph Kerschbaumer 2017-07-05 14:10:07 +02:00
parent 00fb80dbbc
commit 766b8a4ab0
4 changed files with 22 additions and 28 deletions

View File

@ -29,6 +29,7 @@ devtools.jar:
content/sourceeditor/codemirror/codemirror.bundle.js (sourceeditor/codemirror/codemirror.bundle.js)
content/sourceeditor/codemirror/lib/codemirror.css (sourceeditor/codemirror/lib/codemirror.css)
content/sourceeditor/codemirror/mozilla.css (sourceeditor/codemirror/mozilla.css)
content/sourceeditor/codemirror/cmiframe.html (sourceeditor/codemirror/cmiframe.html)
content/sourceeditor/codemirror/old-debugger.css (sourceeditor/codemirror/old-debugger.css)
content/debugger/new/index.html (debugger/new/index.html)
content/debugger/debugger.xul (debugger/debugger.xul)

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html dir='ltr'>
<head>
<style id="cmBaseStyle">
html, body { height: 100%; }
body { margin: 0; overflow: hidden; }
.CodeMirror { width: 100% !important; line-height: 1.25 !important; }
</style>
<link rel='stylesheet' href="chrome://devtools/content/sourceeditor/codemirror/lib/codemirror.css">
<link rel='stylesheet' href="chrome://devtools/content/sourceeditor/codemirror/addon/dialog/dialog.css">
<link rel='stylesheet' href="chrome://devtools/content/sourceeditor/codemirror/mozilla.css">
<link rel='stylesheet' href="chrome://devtools/content/sourceeditor/codemirror/old-debugger.css">
</head>
<body class='theme-body devtools-monospace'></body>
</html>

View File

@ -48,37 +48,14 @@ const {
const { OS } = Services.appinfo;
// CM_STYLES, CM_SCRIPTS and CM_IFRAME represent the HTML,
// JavaScript and CSS that is injected into an iframe in
// order to initialize a CodeMirror instance.
const CM_STYLES = [
"chrome://devtools/content/sourceeditor/codemirror/lib/codemirror.css",
"chrome://devtools/content/sourceeditor/codemirror/addon/dialog/dialog.css",
"chrome://devtools/content/sourceeditor/codemirror/mozilla.css"
];
CM_STYLES.push(
"chrome://devtools/content/sourceeditor/codemirror/old-debugger.css"
);
// CM_SCRIPTS and CM_IFRAME represent the HTML and JavaScript that is
// injected into an iframe in order to initialize a CodeMirror instance.
const CM_SCRIPTS = [
"chrome://devtools/content/sourceeditor/codemirror/codemirror.bundle.js",
];
const CM_IFRAME =
"data:text/html;charset=utf8,<!DOCTYPE html>" +
"<html dir='ltr'>" +
" <head>" +
" <style>" +
" html, body { height: 100%; }" +
" body { margin: 0; overflow: hidden; }" +
" .CodeMirror { width: 100% !important; line-height: 1.25 !important; }" +
" </style>" +
CM_STYLES.map(style => "<link rel='stylesheet' href='" + style + "'>").join("\n") +
" </head>" +
" <body class='theme-body devtools-monospace'></body>" +
"</html>";
const CM_IFRAME = "chrome://devtools/content/sourceeditor/codemirror/cmiframe.html";
const CM_MAPPING = [
"focus",

View File

@ -8,8 +8,9 @@ function test() {
waitForExplicitFinish();
setup((ed, win) => {
// appendTo
let src = win.document.querySelector("iframe").getAttribute("src");
ok(~src.indexOf(".CodeMirror"), "correct iframe is there");
let cmFrame = win.document.querySelector("iframe");
let cmStyle = cmFrame.contentDocument.getElementById("cmBaseStyle");
ok(~cmStyle.innerHTML.indexOf(".CodeMirror"), "correct iframe is there");
// getOption/setOption
ok(ed.getOption("styleActiveLine"), "getOption works");