From 766b8a4ab0a09505ec69ed75c0a635e0245ab275 Mon Sep 17 00:00:00 2001 From: Christoph Kerschbaumer Date: Wed, 5 Jul 2017 14:10:07 +0200 Subject: [PATCH] Bug 1377851 - Load code mirror frame from external file within devtools. r=pbrosset --- devtools/client/jar.mn | 1 + .../sourceeditor/codemirror/cmiframe.html | 15 ++++++++++ devtools/client/sourceeditor/editor.js | 29 ++----------------- .../sourceeditor/test/browser_editor_basic.js | 5 ++-- 4 files changed, 22 insertions(+), 28 deletions(-) create mode 100644 devtools/client/sourceeditor/codemirror/cmiframe.html diff --git a/devtools/client/jar.mn b/devtools/client/jar.mn index cee78efe515d..4f7369242fba 100644 --- a/devtools/client/jar.mn +++ b/devtools/client/jar.mn @@ -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) diff --git a/devtools/client/sourceeditor/codemirror/cmiframe.html b/devtools/client/sourceeditor/codemirror/cmiframe.html new file mode 100644 index 000000000000..c66f8fed0e30 --- /dev/null +++ b/devtools/client/sourceeditor/codemirror/cmiframe.html @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/devtools/client/sourceeditor/editor.js b/devtools/client/sourceeditor/editor.js index 6dbf00ebcfec..af8fb2f0b676 100644 --- a/devtools/client/sourceeditor/editor.js +++ b/devtools/client/sourceeditor/editor.js @@ -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," + - "" + - " " + - " " + - CM_STYLES.map(style => "").join("\n") + - " " + - " " + - ""; +const CM_IFRAME = "chrome://devtools/content/sourceeditor/codemirror/cmiframe.html"; const CM_MAPPING = [ "focus", diff --git a/devtools/client/sourceeditor/test/browser_editor_basic.js b/devtools/client/sourceeditor/test/browser_editor_basic.js index 503b06afeda4..14bfc27fee53 100644 --- a/devtools/client/sourceeditor/test/browser_editor_basic.js +++ b/devtools/client/sourceeditor/test/browser_editor_basic.js @@ -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");