author | Jennifer Fong <jen@ednapiranha.com> |
Mon, 17 Aug 2015 15:27:43 -0700 | |
changeset 258164 | 9e51cc2ce944203b7520ee68367e0016acd024ae |
parent 258163 | d040490413fef93dea873a3aa3e63f8f4e62647e |
child 258165 | 7d66a11d81a45792425ce44e13ac93d65de91c1e |
push id | 63843 |
push user | ryanvm@gmail.com |
push date | Tue, 18 Aug 2015 14:58:06 +0000 |
treeherder | mozilla-inbound@d55e24c983aa [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bgrins |
bugs | 1194314 |
milestone | 43.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/browser/devtools/styleeditor/test/browser_styleeditor_autocomplete.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_autocomplete.js @@ -12,77 +12,96 @@ const {CSSProperties, CSSValues} = getCS // Test cases to test that autocompletion works correctly when enabled. // Format: // [ // key, // { // total: Number of suggestions in the popup (-1 if popup is closed), // current: Index of selected suggestion, -// inserted: 1 to check whether the selected suggestion is inserted into the editor or not, +// inserted: 1 to check whether the selected suggestion is inserted into the +// editor or not, // entered: 1 if the suggestion is inserted and finalized // } // ] let TEST_CASES = [ - ['VK_RIGHT'], - ['VK_RIGHT'], - ['VK_RIGHT'], - ['VK_RIGHT'], - ['Ctrl+Space', {total: 1, current: 0}], - ['VK_LEFT'], - ['VK_RIGHT'], - ['VK_DOWN'], - ['VK_RIGHT'], - ['VK_RIGHT'], - ['VK_RIGHT'], - ['Ctrl+Space', { total: getSuggestionNumberFor("font"), current: 0}], - ['VK_END'], - ['VK_RETURN'], - ['b', {total: getSuggestionNumberFor("b"), current: 0}], - ['a', {total: getSuggestionNumberFor("ba"), current: 0}], - ['VK_DOWN', {total: getSuggestionNumberFor("ba"), current: 0, inserted: 1}], - ['VK_TAB', {total: getSuggestionNumberFor("ba"), current: 1, inserted: 1}], - ['VK_RETURN', {current: 1, inserted: 1, entered: 1}], - ['b', {total: getSuggestionNumberFor("background", "b"), current: 0}], - ['l', {total: getSuggestionNumberFor("background", "bl"), current: 0}], - ['VK_TAB', {total: getSuggestionNumberFor("background", "bl"), current: 0, inserted: 1}], - ['VK_DOWN', {total: getSuggestionNumberFor("background", "bl"), current: 1, inserted: 1}], - ['VK_UP', {total: getSuggestionNumberFor("background", "bl"), current: 0, inserted: 1}], - ['VK_TAB', {total: getSuggestionNumberFor("background", "bl"), current: 1, inserted: 1}], - ['VK_TAB', {total: getSuggestionNumberFor("background", "bl"), current: 2, inserted: 1}], - [';'], - ['VK_RETURN'], - ['c', {total: getSuggestionNumberFor("c"), current: 0}], - ['o', {total: getSuggestionNumberFor("co"), current: 0}], - ['VK_RETURN', {current: 0, inserted: 1}], - ['r', {total: getSuggestionNumberFor("color", "r"), current: 0}], - ['VK_RETURN', {current: 0, inserted: 1}], - [';'], - ['VK_LEFT'], - ['VK_RIGHT'], - ['VK_DOWN'], - ['VK_RETURN'], - ['b', {total: 2, current: 0}], - ['u', {total: 1, current: 0}], - ['VK_RETURN', {current: 0, inserted: 1}], - ['{'], - ['VK_HOME'], - ['VK_DOWN'], - ['VK_DOWN'], - ['VK_RIGHT'], - ['VK_RIGHT'], - ['VK_RIGHT'], - ['VK_RIGHT'], - ['VK_RIGHT'], - ['VK_RIGHT'], - ['VK_RIGHT'], - ['VK_RIGHT'], - ['VK_RIGHT'], - ['VK_RIGHT'], - ['Ctrl+Space', {total: 1, current: 0}], + ["VK_RIGHT"], + ["VK_RIGHT"], + ["VK_RIGHT"], + ["VK_RIGHT"], + ["Ctrl+Space", {total: 1, current: 0}], + ["VK_LEFT"], + ["VK_RIGHT"], + ["VK_DOWN"], + ["VK_RIGHT"], + ["VK_RIGHT"], + ["VK_RIGHT"], + ["Ctrl+Space", { total: getSuggestionNumberFor("font"), current: 0}], + ["VK_END"], + ["VK_RETURN"], + ["b", {total: getSuggestionNumberFor("b"), current: 0}], + ["a", {total: getSuggestionNumberFor("ba"), current: 0}], + ["VK_DOWN", {total: getSuggestionNumberFor("ba"), current: 0, inserted: 1}], + ["VK_TAB", {total: getSuggestionNumberFor("ba"), current: 1, inserted: 1}], + ["VK_RETURN", {current: 1, inserted: 1, entered: 1}], + ["b", {total: getSuggestionNumberFor("background", "b"), current: 0}], + ["l", {total: getSuggestionNumberFor("background", "bl"), current: 0}], + ["VK_TAB", { + total: getSuggestionNumberFor("background", "bl"), + current: 0, inserted: 1 + }], + ["VK_DOWN", { + total: getSuggestionNumberFor("background", "bl"), + current: 1, inserted: 1 + }], + ["VK_UP", { + total: getSuggestionNumberFor("background", "bl"), + current: 0, + inserted: 1 + }], + ["VK_TAB", { + total: getSuggestionNumberFor("background", "bl"), + current: 1, + inserted: 1 + }], + ["VK_TAB", { + total: getSuggestionNumberFor("background", "bl"), + current: 2, + inserted: 1 + }], + [";"], + ["VK_RETURN"], + ["c", {total: getSuggestionNumberFor("c"), current: 0}], + ["o", {total: getSuggestionNumberFor("co"), current: 0}], + ["VK_RETURN", {current: 0, inserted: 1}], + ["r", {total: getSuggestionNumberFor("color", "r"), current: 0}], + ["VK_RETURN", {current: 0, inserted: 1}], + [";"], + ["VK_LEFT"], + ["VK_RIGHT"], + ["VK_DOWN"], + ["VK_RETURN"], + ["b", {total: 2, current: 0}], + ["u", {total: 1, current: 0}], + ["VK_RETURN", {current: 0, inserted: 1}], + ["{"], + ["VK_HOME"], + ["VK_DOWN"], + ["VK_DOWN"], + ["VK_RIGHT"], + ["VK_RIGHT"], + ["VK_RIGHT"], + ["VK_RIGHT"], + ["VK_RIGHT"], + ["VK_RIGHT"], + ["VK_RIGHT"], + ["VK_RIGHT"], + ["VK_RIGHT"], + ["VK_RIGHT"], + ["Ctrl+Space", {total: 1, current: 0}], ]; add_task(function* () { let { panel, ui } = yield openStyleEditorForURL(TESTCASE_URI); let editor = yield ui.editors[0].getSourceEditor(); let sourceEditor = editor.sourceEditor; let popup = sourceEditor.getAutocompletionPopup(); @@ -102,62 +121,58 @@ function testState(index, sourceEditor, } let mods = {}; info("pressing key " + key + " to get result: " + JSON.stringify(TEST_CASES[index]) + " for index " + index); let evt = "after-suggest"; - if (key == 'Ctrl+Space') { + if (key == "Ctrl+Space") { key = " "; mods.ctrlKey = true; - } - else if (key == "VK_RETURN" && entered) { + } else if (key == "VK_RETURN" && entered) { evt = "popup-hidden"; - } - else if (/(left|right|return|home|end)/ig.test(key) || + } else if (/(left|right|return|home|end)/ig.test(key) || (key == "VK_DOWN" && !popup.isOpen)) { evt = "cursorActivity"; - } - else if (key == "VK_TAB" || key == "VK_UP" || key == "VK_DOWN") { + } else if (key == "VK_TAB" || key == "VK_UP" || key == "VK_DOWN") { evt = "suggestion-entered"; } let ready = sourceEditor.once(evt); EventUtils.synthesizeKey(key, mods, panelWindow); return ready; } function checkState(index, sourceEditor, popup) { let deferred = promise.defer(); executeSoon(() => { - let [key, details] = TEST_CASES[index]; + let [, details] = TEST_CASES[index]; details = details || {}; let {total, current, inserted} = details; if (total != undefined) { ok(popup.isOpen, "Popup is open for index " + index); is(total, popup.itemCount, "Correct total suggestions for index " + index); is(current, popup.selectedIndex, "Correct index is selected for index " + index); if (inserted) { - let { preLabel, label, text } = popup.getItemAtIndex(current); + let { text } = popup.getItemAtIndex(current); let { line, ch } = sourceEditor.getCursor(); let lineText = sourceEditor.getText(line); is(lineText.substring(ch - text.length, ch), text, "Current suggestion from the popup is inserted into the editor."); } - } - else { + } else { ok(!popup.isOpen, "Popup is closed for index " + index); if (inserted) { - let { preLabel, label, text } = popup.getItemAtIndex(current); + let { text } = popup.getItemAtIndex(current); let { line, ch } = sourceEditor.getCursor(); let lineText = sourceEditor.getText(line); is(lineText.substring(ch - text.length, ch), text, "Current suggestion from the popup is inserted into the editor."); } } deferred.resolve(); });
--- a/browser/devtools/styleeditor/test/browser_styleeditor_bug_740541_iframes.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_bug_740541_iframes.js @@ -1,38 +1,36 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; // Test that sheets inside iframes are shown in the editor. -add_task(function* () -{ - +add_task(function* () { function makeStylesheet(selector) { return ("data:text/css;charset=UTF-8," + encodeURIComponent(selector + " { }")); } function makeDocument(stylesheets, framedDocuments) { stylesheets = stylesheets || []; framedDocuments = framedDocuments || []; return "data:text/html;charset=UTF-8," + encodeURIComponent( Array.prototype.concat.call( ["<!DOCTYPE html>", "<html>", "<head>", "<title>Bug 740541</title>"], - stylesheets.map(function (sheet) { - return '<link rel="stylesheet" type="text/css" href="'+sheet+'">'; + stylesheets.map(function(sheet) { + return '<link rel="stylesheet" type="text/css" href="' + sheet + '">'; }), ["</head>", "<body>"], - framedDocuments.map(function (doc) { - return '<iframe src="'+doc+'"></iframe>'; + framedDocuments.map(function(doc) { + return '<iframe src="' + doc + '"></iframe>'; }), ["</body>", "</html>"] ).join("\n")); } const DOCUMENT_WITH_INLINE_STYLE = "data:text/html;charset=UTF-8," + encodeURIComponent( @@ -51,17 +49,16 @@ add_task(function* () ].join("\n")); const FOUR = TEST_BASE_HTTP + "four.html"; const SIMPLE = TEST_BASE_HTTP + "simple.css"; const SIMPLE_DOCUMENT = TEST_BASE_HTTP + "simple.html"; - const TESTCASE_URI = makeDocument( [makeStylesheet(".a")], [makeDocument([], [FOUR, DOCUMENT_WITH_INLINE_STYLE]), makeDocument([makeStylesheet(".b"), SIMPLE], [makeDocument([makeStylesheet(".c")],
--- a/browser/devtools/styleeditor/test/browser_styleeditor_bug_851132_middle_click.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_bug_851132_middle_click.js @@ -46,11 +46,11 @@ function* clickOnStyleSheetLink(editor, info("Pressing button " + button + " on style sheet name link."); EventUtils.synthesizeMouseAtCenter(link, { button }, window); } function onTabAdded() { ok(false, "middle mouse click has opened a new tab"); } -registerCleanupFunction(function () { +registerCleanupFunction(function() { gBrowser.tabContainer.removeEventListener("TabOpen", onTabAdded, false); });
--- a/browser/devtools/styleeditor/test/browser_styleeditor_bug_870339.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_bug_870339.js @@ -1,32 +1,33 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; + const SIMPLE = TEST_BASE_HTTP + "simple.css"; const DOCUMENT_WITH_ONE_STYLESHEET = "data:text/html;charset=UTF-8," + encodeURIComponent( ["<!DOCTYPE html>", "<html>", " <head>", " <title>Bug 870339</title>", - ' <link rel="stylesheet" type="text/css" href="'+SIMPLE+'">', + ' <link rel="stylesheet" type="text/css" href="' + SIMPLE + '">', " </head>", " <body>", " </body>", "</html>" ].join("\n")); add_task(function* () { let { ui } = yield openStyleEditorForURL(DOCUMENT_WITH_ONE_STYLESHEET); // Spam the _onNewDocument callback multiple times before the // StyleEditorActor has a chance to respond to the first one. const SPAM_COUNT = 2; - for (let i=0; i<SPAM_COUNT; ++i) { + for (let i = 0; i < SPAM_COUNT; ++i) { ui._onNewDocument(); } // Wait for the StyleEditorActor to respond to each "newDocument" // message. yield new Promise(resolve => { let loadCount = 0; ui.on("stylesheets-reset", function onReset() {
--- a/browser/devtools/styleeditor/test/browser_styleeditor_cmd_edit.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_cmd_edit.js @@ -1,180 +1,195 @@ /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Tests that the edit command works const TEST_URI = "http://example.com/browser/browser/devtools/styleeditor/" + "test/browser_styleeditor_cmd_edit.html"; add_task(function* () { let options = yield helpers.openTab(TEST_URI); yield helpers.openToolbar(options); yield helpers.audit(options, [ { setup: "edit", check: { - input: 'edit', - hints: ' <resource> [line]', - markup: 'VVVV', - status: 'ERROR', + input: "edit", + hints: " <resource> [line]", + markup: "VVVV", + status: "ERROR", args: { - resource: { status: 'INCOMPLETE' }, - line: { status: 'VALID' }, + resource: { status: "INCOMPLETE" }, + line: { status: "VALID" }, } }, }, { setup: "edit i", check: { - input: 'edit i', - hints: 'nline-css [line]', - markup: 'VVVVVI', - status: 'ERROR', + input: "edit i", + hints: "nline-css [line]", + markup: "VVVVVI", + status: "ERROR", args: { - resource: { arg: ' i', status: 'INCOMPLETE' }, - line: { status: 'VALID' }, + resource: { arg: " i", status: "INCOMPLETE" }, + line: { status: "VALID" }, } }, }, { setup: "edit c", check: { - input: 'edit c', - hints: 'ss#style2 [line]', - markup: 'VVVVVI', - status: 'ERROR', + input: "edit c", + hints: "ss#style2 [line]", + markup: "VVVVVI", + status: "ERROR", args: { - resource: { arg: ' c', status: 'INCOMPLETE' }, - line: { status: 'VALID' }, + resource: { arg: " c", status: "INCOMPLETE" }, + line: { status: "VALID" }, } }, }, { setup: "edit http", check: { - input: 'edit http', - hints: '://example.com/browser/browser/devtools/styleeditor/test/resources_inpage1.css [line]', - markup: 'VVVVVIIII', - status: 'ERROR', + input: "edit http", + hints: "://example.com/browser/browser/devtools/styleeditor/test/" + + "resources_inpage1.css [line]", + markup: "VVVVVIIII", + status: "ERROR", args: { resource: { - arg: ' http', - status: 'INCOMPLETE', - message: 'Value required for \'resource\'.' + arg: " http", + status: "INCOMPLETE", + message: "Value required for \'resource\'." }, - line: { status: 'VALID' }, + line: { status: "VALID" }, } }, }, { setup: "edit page1", check: { - input: 'edit page1', - hints: ' [line] -> http://example.com/browser/browser/devtools/styleeditor/test/resources_inpage1.css', - markup: 'VVVVVIIIII', - status: 'ERROR', + input: "edit page1", + hints: " [line] -> http://example.com/browser/browser/devtools/" + + "styleeditor/test/resources_inpage1.css", + markup: "VVVVVIIIII", + status: "ERROR", args: { resource: { - arg: ' page1', - status: 'INCOMPLETE', + arg: " page1", + status: "INCOMPLETE", message: 'Value required for \'resource\'.' }, line: { status: 'VALID' }, } }, }, { setup: "edit page2", check: { - input: 'edit page2', - hints: ' [line] -> http://example.com/browser/browser/devtools/styleeditor/test/resources_inpage2.css', - markup: 'VVVVVIIIII', - status: 'ERROR', + input: "edit page2", + hints: " [line] -> http://example.com/browser/browser/devtools/" + + "styleeditor/test/resources_inpage2.css", + markup: "VVVVVIIIII", + status: "ERROR", args: { resource: { - arg: ' page2', - status: 'INCOMPLETE', - message: 'Value required for \'resource\'.' + arg: " page2", + status: "INCOMPLETE", + message: "Value required for \'resource\'." }, - line: { status: 'VALID' }, + line: { status: "VALID" }, } }, }, { setup: "edit stylez", check: { - input: 'edit stylez', - hints: ' [line]', - markup: 'VVVVVEEEEEE', - status: 'ERROR', + input: "edit stylez", + hints: " [line]", + markup: "VVVVVEEEEEE", + status: "ERROR", args: { - resource: { arg: ' stylez', status: 'ERROR', message: 'Can\'t use \'stylez\'.' }, - line: { status: 'VALID' }, + resource: { + arg: " stylez", + status: "ERROR", message: "Can\'t use \'stylez\'." }, + line: { status: "VALID" }, } }, }, { setup: "edit css#style2", check: { - input: 'edit css#style2', - hints: ' [line]', - markup: 'VVVVVVVVVVVVVVV', - status: 'VALID', + input: "edit css#style2", + hints: " [line]", + markup: "VVVVVVVVVVVVVVV", + status: "VALID", args: { - resource: { arg: ' css#style2', status: 'VALID', message: '' }, - line: { status: 'VALID' }, + resource: { arg: " css#style2", status: "VALID", message: "" }, + line: { status: "VALID" }, } }, }, { setup: "edit css#style2 5", check: { - input: 'edit css#style2 5', - hints: '', - markup: 'VVVVVVVVVVVVVVVVV', - status: 'VALID', + input: "edit css#style2 5", + hints: "", + markup: "VVVVVVVVVVVVVVVVV", + status: "VALID", args: { - resource: { arg: ' css#style2', status: 'VALID', message: '' }, - line: { value: 5, arg: ' 5', status: 'VALID' }, + resource: { arg: " css#style2", status: "VALID", message: "" }, + line: { value: 5, arg: " 5", status: "VALID" }, } }, }, { setup: "edit css#style2 0", check: { - input: 'edit css#style2 0', - hints: '', - markup: 'VVVVVVVVVVVVVVVVE', - status: 'ERROR', + input: "edit css#style2 0", + hints: "", + markup: "VVVVVVVVVVVVVVVVE", + status: "ERROR", args: { - resource: { arg: ' css#style2', status: 'VALID', message: '' }, - line: { arg: ' 0', status: 'ERROR', message: '0 is smaller than minimum allowed: 1.' }, + resource: { arg: " css#style2", status: "VALID", message: "" }, + line: { + arg: " 0", + status: "ERROR", + message: "0 is smaller than minimum allowed: 1." + }, } }, }, { setup: "edit css#style2 -1", check: { - input: 'edit css#style2 -1', - hints: '', - markup: 'VVVVVVVVVVVVVVVVEE', - status: 'ERROR', + input: "edit css#style2 -1", + hints: "", + markup: "VVVVVVVVVVVVVVVVEE", + status: "ERROR", args: { - resource: { arg: ' css#style2', status: 'VALID', message: '' }, - line: { arg: ' -1', status: 'ERROR', message: '-1 is smaller than minimum allowed: 1.' }, + resource: { arg: " css#style2", status: "VALID", message: "" }, + line: { + arg: " -1", + status: "ERROR", + message: "-1 is smaller than minimum allowed: 1." + }, } }, } ]); let toolbox = gDevTools.getToolbox(options.target); - ok(toolbox == null, 'toolbox is closed'); + ok(toolbox == null, "toolbox is closed"); yield helpers.audit(options, [ { setup: "edit css#style2", check: { input: "edit css#style2", }, exec: { output: "" }
--- a/browser/devtools/styleeditor/test/browser_styleeditor_enabled.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_enabled.js @@ -27,17 +27,18 @@ add_task(function* () { is(editor.styleSheet.disabled, true, "first stylesheet is now disabled"); is(summary.classList.contains("disabled"), true, "first stylesheet is now disabled, UI has DISABLED class"); info("Enabling the first stylesheet again."); yield toggleEnabled(editor, enabledToggle, panel.panelWindow); - is(editor.styleSheet.disabled, false, "first stylesheet is now enabled again"); + is(editor.styleSheet.disabled, false, + "first stylesheet is now enabled again"); is(summary.classList.contains("disabled"), false, "first stylesheet is now enabled again, UI does not have DISABLED class"); }); function* toggleEnabled(editor, enabledToggle, panelWindow) { let changed = editor.once("property-change"); info("Waiting for focus.");
--- a/browser/devtools/styleeditor/test/browser_styleeditor_filesave.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_filesave.js @@ -14,17 +14,17 @@ const Ci = Components.interfaces; let tempScope = {}; Components.utils.import("resource://gre/modules/FileUtils.jsm", tempScope); Components.utils.import("resource://gre/modules/NetUtil.jsm", tempScope); let FileUtils = tempScope.FileUtils; let NetUtil = tempScope.NetUtil; add_task(function* () { let htmlFile = yield copy(TESTCASE_URI_HTML, "simple.html"); - let cssFile = yield copy(TESTCASE_URI_CSS, "simple.css"); + yield copy(TESTCASE_URI_CSS, "simple.css"); let uri = Services.io.newFileURI(htmlFile); let filePath = uri.resolve(""); let { ui } = yield openStyleEditorForURL(filePath); let editor = ui.editors[0]; yield editor.getSourceEditor(); @@ -37,73 +37,73 @@ add_task(function* () { is(editor.sourceEditor.isClean(), false, "Editor is dirty."); ok(editor.summary.classList.contains("unsaved"), "Star icon is present in the corresponding summary."); info("Saving the changes."); dirty = editor.sourceEditor.once("dirty-change"); - editor.saveToFile(null, function (file) { + editor.saveToFile(null, function(file) { ok(file, "file should get saved directly when using a file:// URI"); }); yield dirty; is(editor.sourceEditor.isClean(), true, "Editor is clean."); ok(!editor.summary.classList.contains("unsaved"), "Star icon is not present in the corresponding summary."); }); -function copy(aSrcChromeURL, aDestFileName) -{ +function copy(srcChromeURL, destFileName) { let deferred = promise.defer(); - let destFile = FileUtils.getFile("ProfD", [aDestFileName]); - write(read(aSrcChromeURL), destFile, deferred.resolve); + let destFile = FileUtils.getFile("ProfD", [destFileName]); + write(read(srcChromeURL), destFile, deferred.resolve); return deferred.promise; } -function read(aSrcChromeURL) -{ +function read(srcChromeURL) { let scriptableStream = Cc["@mozilla.org/scriptableinputstream;1"] .getService(Ci.nsIScriptableInputStream); - let channel = Services.io.newChannel2(aSrcChromeURL, + let channel = Services.io.newChannel2(srcChromeURL, null, null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal + // aLoadingNode + null, + Services.scriptSecurityManager + .getSystemPrincipal(), + // aTriggeringPrincipal + null, Ci.nsILoadInfo.SEC_NORMAL, Ci.nsIContentPolicy.TYPE_OTHER); let input = channel.open(); scriptableStream.init(input); let data = ""; while (input.available()) { data = data.concat(scriptableStream.read(input.available())); } scriptableStream.close(); input.close(); return data; } -function write(aData, aFile, aCallback) -{ +function write(data, file, callback) { let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"] .createInstance(Ci.nsIScriptableUnicodeConverter); converter.charset = "UTF-8"; - let istream = converter.convertToInputStream(aData); - let ostream = FileUtils.openSafeFileOutputStream(aFile); + let istream = converter.convertToInputStream(data); + let ostream = FileUtils.openSafeFileOutputStream(file); NetUtil.asyncCopy(istream, ostream, function(status) { if (!Components.isSuccessCode(status)) { - info("Coudln't write to " + aFile.path); + info("Couldn't write to " + file.path); return; } - aCallback(aFile); + callback(file); }); }
--- a/browser/devtools/styleeditor/test/browser_styleeditor_highlight-selector.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_highlight-selector.js @@ -1,12 +1,14 @@ /* vim: set ts=2 et sw=2 tw=80: */ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that hovering over a simple selector in the style-editor requests the // highlighting of the corresponding nodes const TEST_URL = "data:text/html;charset=utf8," + "<style>div{color:red}</style><div>highlighter test</div>"; add_task(function*() { let { ui } = yield openStyleEditorForURL(TEST_URL);
--- a/browser/devtools/styleeditor/test/browser_styleeditor_import.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_import.js @@ -25,32 +25,31 @@ add_task(function* () { let editor = yield added; is(editor.savedFile.leafName, FILENAME, "imported stylesheet will be saved directly into the same file"); is(editor.friendlyName, FILENAME, "imported stylesheet has the same name as the filename"); }); -function importSheet(ui, panelWindow) -{ +function importSheet(ui, panelWindow) { // create file to import first let file = FileUtils.getFile("ProfD", [FILENAME]); let ostream = FileUtils.openSafeFileOutputStream(file); let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"] .createInstance(Ci.nsIScriptableUnicodeConverter); converter.charset = "UTF-8"; let istream = converter.convertToInputStream(SOURCE); - NetUtil.asyncCopy(istream, ostream, function (status) { + NetUtil.asyncCopy(istream, ostream, function() { FileUtils.closeSafeFileOutputStream(ostream); // click the import button now that the file to import is ready ui._mockImportFile = file; - waitForFocus(function () { - let document = panelWindow.document + waitForFocus(function() { + let document = panelWindow.document; let importButton = document.querySelector(".style-editor-importButton"); ok(importButton, "import button exists"); EventUtils.synthesizeMouseAtCenter(importButton, {}, panelWindow); }, panelWindow); }); }
--- a/browser/devtools/styleeditor/test/browser_styleeditor_init.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_init.js @@ -28,17 +28,18 @@ add_task(function* () { checkSheet(ui.editors[1], EXPECTED_SHEETS[1]); }); function checkSheet(editor, expected) { is(editor.styleSheet.styleSheetIndex, expected.sheetIndex, "Style sheet has correct index."); let summary = editor.summary; - let name = summary.querySelector(".stylesheet-name > label").getAttribute("value"); + let name = summary.querySelector(".stylesheet-name > label") + .getAttribute("value"); ok(expected.name.test(name), "The name '" + name + "' is correct."); let ruleCount = summary.querySelector(".stylesheet-rule-count").textContent; - is(parseInt(ruleCount), expected.rules, "the rule count is correct"); + is(parseInt(ruleCount, 10), expected.rules, "the rule count is correct"); is(summary.classList.contains("splitview-active"), expected.active, "The active status for this sheet is correct."); }
--- a/browser/devtools/styleeditor/test/browser_styleeditor_inline_friendly_names.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_inline_friendly_names.js @@ -32,60 +32,65 @@ function testIndentifierGeneration(ui) { }; let fakeInlineStyleSheet = { "href": null, "nodeHref": "http://example.com/", "styleSheetIndex": 2 }; - is(ui.getStyleSheetIdentifier(fakeStyleSheetFile), "http://example.com/test.css", + is(ui.getStyleSheetIdentifier(fakeStyleSheetFile), + "http://example.com/test.css", "URI is the identifier of style sheet file."); - is(ui.getStyleSheetIdentifier(fakeInlineStyleSheet), "inline-2-at-http://example.com/", - "Inline style sheets are identified by their page and position at that page."); + is(ui.getStyleSheetIdentifier(fakeInlineStyleSheet), + "inline-2-at-http://example.com/", + "Inline sheets are identified by their page and position in the page."); } function saveFirstInlineStyleSheet(ui) { let deferred = promise.defer(); let editor = ui.editors[0]; let destFile = FileUtils.getFile("ProfD", [SAVE_PATH]); - editor.saveToFile(destFile, function (file) { + editor.saveToFile(destFile, function(file) { ok(file, "File was correctly saved."); deferred.resolve(); }); return deferred.promise; } function testFriendlyNamesAfterSave(ui) { let firstEditor = ui.editors[0]; let secondEditor = ui.editors[1]; - // The friendly name of first sheet should've been remembered, the second should - // not be the same (bug 969900). + // The friendly name of first sheet should've been remembered, the second + // should not be the same (bug 969900). is(firstEditor.friendlyName, SAVE_PATH, "Friendly name is correct for the saved inline style sheet."); isnot(secondEditor.friendlyName, SAVE_PATH, - "Friendly name is for the second inline style sheet is not the same as first."); + "Friendly name for the second inline sheet isn't the same as the first."); return promise.resolve(null); } function reloadPage(ui) { info("Reloading page."); - executeInContent("devtools:test:reload", {}, {}, false /* no response */); + executeInContent("devtools:test:reload", {}, {}, + /* no response */ + false); return ui.once("stylesheets-reset"); } function navigateToAnotherPage(ui) { info("Navigating to another page."); - executeInContent("devtools:test:navigate", { location: SECOND_TEST_PAGE }, {}, false); + executeInContent("devtools:test:navigate", { location: SECOND_TEST_PAGE }, + {}, false); return ui.once("stylesheets-reset"); } function testFriendlyNamesAfterNavigation(ui) { let firstEditor = ui.editors[0]; let secondEditor = ui.editors[1]; // Inline style sheets shouldn't have the name of previously saved file as the
--- a/browser/devtools/styleeditor/test/browser_styleeditor_loading.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_loading.js @@ -4,19 +4,19 @@ "use strict"; // Test that style editor loads correctly. const TESTCASE_URI = TEST_BASE_HTTP + "longload.html"; add_task(function* () { // launch Style Editor right when the tab is created (before load) - // this checks that the Style Editor still launches correctly when it is opened - // *while* the page is still loading. The Style Editor should not signal that - // it is loaded until the accompanying content page is loaded. + // this checks that the Style Editor still launches correctly when it is + // opened *while* the page is still loading. The Style Editor should not + // signal that it is loaded until the accompanying content page is loaded. let tabAdded = addTab(TESTCASE_URI); let target = TargetFactory.forTab(gBrowser.selectedTab); let styleEditorLoaded = gDevTools.showToolbox(target, "styleeditor"); yield Promise.all([tabAdded, styleEditorLoaded]); let toolbox = gDevTools.getToolbox(target); let panel = toolbox.getPanel("styleeditor");
--- a/browser/devtools/styleeditor/test/browser_styleeditor_media_sidebar.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_media_sidebar.js @@ -1,12 +1,14 @@ /* vim: set ts=2 et sw=2 tw=80: */ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // https rather than chrome to improve coverage const TESTCASE_URI = TEST_BASE_HTTPS + "media-rules.html"; const MEDIA_PREF = "devtools.styleeditor.showMediaSidebar"; const RESIZE = 300; const LABELS = ["not all", "all", "(max-width: 400px)", "(max-width: 600px)"]; const LINE_NOS = [1, 7, 19, 25]; const NEW_RULE = "\n@media (max-width: 600px) { div { color: blue; } }"; @@ -63,17 +65,18 @@ function testMediaEditor(editor) { testRule(entries[1], LABELS[1], true, LINE_NOS[1]); testRule(entries[2], LABELS[2], false, LINE_NOS[2]); } function testMediaMatchChanged(editor) { let sidebar = editor.details.querySelector(".stylesheet-sidebar"); let cond = sidebar.querySelectorAll(".media-rule-condition")[2]; - is(cond.textContent, "(max-width: 400px)", "third rule condition text is correct"); + is(cond.textContent, "(max-width: 400px)", + "third rule condition text is correct"); ok(!cond.classList.contains("media-condition-unmatched"), "media rule is now matched after resizing"); } function* testShowHide(UI, editor) { let sidebarChange = listenForMediaChange(UI); Services.prefs.setBoolPref(MEDIA_PREF, false); yield sidebarChange; @@ -123,15 +126,15 @@ function openEditor(editor) { return editor.getSourceEditor(); } function listenForMediaChange(UI) { let deferred = promise.defer(); UI.once("media-list-changed", () => { deferred.resolve(); - }) + }); return deferred.promise; } function getLinkFor(editor) { return editor.summary.querySelector(".stylesheet-name"); }
--- a/browser/devtools/styleeditor/test/browser_styleeditor_media_sidebar_sourcemaps.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_media_sidebar_sourcemaps.js @@ -1,12 +1,14 @@ /* vim: set ts=2 et sw=2 tw=80: */ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // https rather than chrome to improve coverage const TESTCASE_URI = TEST_BASE_HTTPS + "media-rules-sourcemaps.html"; const MAP_PREF = "devtools.styleeditor.source-maps-enabled"; const LABELS = ["screen and (max-width: 320px)", "screen and (min-width: 1200px)"]; const LINE_NOS = [5, 8]; @@ -55,15 +57,15 @@ function openEditor(editor) { return editor.getSourceEditor(); } function listenForMediaChange(UI) { let deferred = promise.defer(); UI.once("media-list-changed", () => { deferred.resolve(); - }) + }); return deferred.promise; } function getLinkFor(editor) { return editor.summary.querySelector(".stylesheet-name"); }
--- a/browser/devtools/styleeditor/test/browser_styleeditor_new.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_new.js @@ -28,30 +28,32 @@ add_task(function*() { function createNew(ui, panelWindow) { info("Creating a new stylesheet now"); let deferred = promise.defer(); ui.once("editor-added", (ev, editor) => { editor.getSourceEditor().then(deferred.resolve); }); - waitForFocus(function () {// create a new style sheet - let newButton = panelWindow.document.querySelector(".style-editor-newButton"); + waitForFocus(function() { + // create a new style sheet + let newButton = panelWindow.document + .querySelector(".style-editor-newButton"); ok(newButton, "'new' button exists"); EventUtils.synthesizeMouseAtCenter(newButton, {}, panelWindow); }, panelWindow); return deferred.promise; } function onPropertyChange(aEditor) { let deferred = promise.defer(); - aEditor.styleSheet.on("property-change", function onProp(property, value) { + aEditor.styleSheet.on("property-change", function onProp(property) { // wait for text to be entered fully let text = aEditor.sourceEditor.getText(); if (property == "ruleCount" && text == TESTCASE_CSS_SOURCE + "}") { aEditor.styleSheet.off("property-change", onProp); deferred.resolve(); } }); @@ -65,28 +67,27 @@ function testInitialState(aEditor) { ok(aEditor.sourceLoaded, "new editor is loaded when attached"); ok(aEditor.isNew, "new editor has isNew flag"); ok(aEditor.sourceEditor.hasFocus(), "new editor has focus"); summary = aEditor.summary; let ruleCount = summary.querySelector(".stylesheet-rule-count").textContent; - is(parseInt(ruleCount), 0, - "new editor initially shows 0 rules"); + is(parseInt(ruleCount, 10), 0, "new editor initially shows 0 rules"); let computedStyle = content.getComputedStyle(content.document.body, null); is(computedStyle.backgroundColor, "rgb(255, 255, 255)", "content's background color is initially white"); } function typeInEditor(aEditor, panelWindow) { let deferred = promise.defer(); - waitForFocus(function () { + waitForFocus(function() { for (let c of TESTCASE_CSS_SOURCE) { EventUtils.synthesizeKey(c, {}, panelWindow); } ok(aEditor.unsaved, "new editor has unsaved flag"); deferred.resolve(); }, panelWindow); @@ -94,15 +95,16 @@ function typeInEditor(aEditor, panelWind } function testUpdated(aEditor, originalHref) { info("Testing the state of the new editor after editing it"); is(aEditor.sourceEditor.getText(), TESTCASE_CSS_SOURCE + "}", "rule bracket has been auto-closed"); - let ruleCount = aEditor.summary.querySelector(".stylesheet-rule-count").textContent; - is(parseInt(ruleCount), 1, + let ruleCount = aEditor.summary.querySelector(".stylesheet-rule-count") + .textContent; + is(parseInt(ruleCount, 10), 1, "new editor shows 1 rule after modification"); is(aEditor.styleSheet.href, originalHref, "style sheet href did not change"); }
--- a/browser/devtools/styleeditor/test/browser_styleeditor_opentab.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_opentab.js @@ -1,48 +1,56 @@ /* vim: set ts=2 et sw=2 tw=80: */ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // A test to check the 'Open Link in new tab' functionality in the // context menu item for stylesheets (bug 992947). const TESTCASE_URI = TEST_BASE_HTTPS + "simple.html"; add_task(function*() { let { ui } = yield openStyleEditorForURL(TESTCASE_URI); yield rightClickStyleSheet(ui, ui.editors[0]); - is(ui._openLinkNewTabItem.getAttribute("disabled"), "false", "The menu item is not disabled"); - is(ui._openLinkNewTabItem.getAttribute("hidden"), "false", "The menu item is not hidden"); + is(ui._openLinkNewTabItem.getAttribute("disabled"), "false", + "The menu item is not disabled"); + is(ui._openLinkNewTabItem.getAttribute("hidden"), "false", + "The menu item is not hidden"); - let url = "https://example.com/browser/browser/devtools/styleeditor/test/simple.css"; + let url = "https://example.com/browser/browser/devtools/styleeditor/test/" + + "simple.css"; is(ui._contextMenuStyleSheet.href, url, "Correct URL for sheet"); let originalOpenUILinkIn = ui._window.openUILinkIn; let tabOpenedDefer = promise.defer(); ui._window.openUILinkIn = newUrl => { // Reset the actual openUILinkIn function before proceeding. ui._window.openUILinkIn = originalOpenUILinkIn; - is (newUrl, url, "The correct tab has been opened"); + is(newUrl, url, "The correct tab has been opened"); tabOpenedDefer.resolve(); }; ui._openLinkNewTabItem.click(); - info (`Waiting for a tab to open - ${url}`); + info(`Waiting for a tab to open - ${url}`); yield tabOpenedDefer.promise; yield rightClickInlineStyleSheet(ui, ui.editors[1]); - is(ui._openLinkNewTabItem.getAttribute("disabled"), "true", "The menu item is disabled"); - is(ui._openLinkNewTabItem.getAttribute("hidden"), "false", "The menu item is not hidden"); + is(ui._openLinkNewTabItem.getAttribute("disabled"), "true", + "The menu item is disabled"); + is(ui._openLinkNewTabItem.getAttribute("hidden"), "false", + "The menu item is not hidden"); yield rightClickNoStyleSheet(ui); - is(ui._openLinkNewTabItem.getAttribute("hidden"), "true", "The menu item is not hidden"); + is(ui._openLinkNewTabItem.getAttribute("hidden"), "true", + "The menu item is not hidden"); }); function onPopupShow(contextMenu) { let defer = promise.defer(); contextMenu.addEventListener("popupshown", function onpopupshown() { contextMenu.removeEventListener("popupshown", onpopupshown); defer.resolve(); });
--- a/browser/devtools/styleeditor/test/browser_styleeditor_pretty.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_pretty.js @@ -3,34 +3,53 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; // Test that minified sheets are automatically prettified but other are left // untouched. const TESTCASE_URI = TEST_BASE_HTTP + "minified.html"; +/* + body { + background:white; + } + div { + font-size:4em; + color:red + } + span { + color:green; + } +*/ const PRETTIFIED_SOURCE = "" + -"body \{\r?\n" + // body{ - "\tbackground\:white;\r?\n" + // background:white; -"\}\r?\n" + // } -"div \{\r?\n" + // div{ - "\tfont\-size\:4em;\r?\n" + // font-size:4em; - "\tcolor\:red\r?\n" + // color:red -"\}\r?\n" + // } -"span \{\r?\n" + // span{ - "\tcolor\:green;\r?\n" // color:green; -"\}\r?\n"; // } +"body \{\r?\n" + + "\tbackground\:white;\r?\n" + +"\}\r?\n" + +"div \{\r?\n" + + "\tfont\-size\:4em;\r?\n" + + "\tcolor\:red\r?\n" + +"\}\r?\n" + +"span \{\r?\n" + + "\tcolor\:green;\r?\n" + +"\}\r?\n"; +/* + body { background: red; } + div { + font-size: 5em; + color: red + } +*/ const ORIGINAL_SOURCE = "" + -"body \{ background\: red; \}\r?\n" + // body { background: red; } -"div \{\r?\n" + // div { - "font\-size\: 5em;\r?\n" + // font-size: 5em; - "color\: red\r?\n" + // color: red -"\}"; // } +"body \{ background\: red; \}\r?\n" + +"div \{\r?\n" + + "font\-size\: 5em;\r?\n" + + "color\: red\r?\n" + +"\}"; add_task(function* () { let { ui } = yield openStyleEditorForURL(TESTCASE_URI); is(ui.editors.length, 2, "Two sheets present."); info("Testing minified style sheet."); let editor = yield ui.editors[0].getSourceEditor();
--- a/browser/devtools/styleeditor/test/browser_styleeditor_private_perwindowpb.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_private_perwindowpb.js @@ -1,19 +1,23 @@ /* 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/. */ +"use strict"; + // This test makes sure that the style editor does not store any // content CSS files in the permanent cache when opened from PB mode. -const TEST_URL = 'http://' + TEST_HOST + '/browser/browser/devtools/styleeditor/test/test_private.html'; -const {LoadContextInfo} = Cu.import("resource://gre/modules/LoadContextInfo.jsm", {}); +const TEST_URL = "http://" + TEST_HOST + "/browser/browser/devtools/" + + "styleeditor/test/test_private.html"; +const {LoadContextInfo} = + Cu.import("resource://gre/modules/LoadContextInfo.jsm", {}); const cache = Cc["@mozilla.org/netwerk/cache-storage-service;1"] - .getService(Ci.nsICacheStorageService); + .getService(Ci.nsICacheStorageService); add_task(function* () { info("Opening a new private window"); let win = OpenBrowserWindow({private: true}); yield waitForDelayedStartupFinished(win); info("Clearing the browser cache"); cache.clear(); @@ -21,53 +25,49 @@ add_task(function* () { let { ui } = yield openStyleEditorForURL(TEST_URL, win); is(ui.editors.length, 1, "The style editor contains one sheet."); let editor = ui.editors[0]; yield editor.getSourceEditor(); yield checkDiskCacheFor(TEST_HOST); win.close(); - }); -function checkDiskCacheFor(host) -{ +function checkDiskCacheFor(host) { let foundPrivateData = false; let deferred = promise.defer(); Visitor.prototype = { - onCacheStorageInfo: function(num, consumption) - { + onCacheStorageInfo: function(num) { info("disk storage contains " + num + " entries"); }, - onCacheEntryInfo: function(uri) - { - var urispec = uri.asciiSpec; + onCacheEntryInfo: function(uri) { + let urispec = uri.asciiSpec; info(urispec); foundPrivateData |= urispec.includes(host); }, - onCacheEntryVisitCompleted: function() - { + onCacheEntryVisitCompleted: function() { is(foundPrivateData, false, "web content present in disk cache"); deferred.resolve(); } }; function Visitor() {} - var storage = cache.diskCacheStorage(LoadContextInfo.default, false); - storage.asyncVisitStorage(new Visitor(), true /* Do walk entries */); + let storage = cache.diskCacheStorage(LoadContextInfo.default, false); + storage.asyncVisitStorage(new Visitor(), + /* Do walk entries */ + true); return deferred.promise; } -function waitForDelayedStartupFinished(aWindow) -{ +function waitForDelayedStartupFinished(win) { let deferred = promise.defer(); - Services.obs.addObserver(function observer(aSubject, aTopic) { - if (aWindow == aSubject) { - Services.obs.removeObserver(observer, aTopic); + Services.obs.addObserver(function observer(subject, topic) { + if (win == subject) { + Services.obs.removeObserver(observer, topic); deferred.resolve(); } }, "browser-delayed-startup-finished", false); return deferred.promise; }
--- a/browser/devtools/styleeditor/test/browser_styleeditor_reload.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_reload.js @@ -15,24 +15,25 @@ add_task(function* () { loadCommonFrameScript(); is(ui.editors.length, 2, "Two sheets present after load."); info("Selecting the second editor"); yield ui.selectStyleSheet(ui.editors[1].styleSheet, LINE_NO, COL_NO); info("Reloading page."); - executeInContent("devtools:test:reload", {}, {}, false /* no response */); + executeInContent("devtools:test:reload", {}, {}, false); info("Waiting for sheets to be loaded after reload."); yield ui.once("stylesheets-reset"); is(ui.editors.length, 2, "Two sheets present after reload."); info("Waiting for source editor to be ready."); yield ui.editors[1].getSourceEditor(); - is(ui.selectedEditor, ui.editors[1], "second editor is selected after reload"); + is(ui.selectedEditor, ui.editors[1], + "second editor is selected after reload"); let {line, ch} = ui.selectedEditor.sourceEditor.getCursor(); is(line, LINE_NO, "correct line selected"); is(ch, COL_NO, "correct column selected"); });
--- a/browser/devtools/styleeditor/test/browser_styleeditor_scroll.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_scroll.js @@ -11,18 +11,18 @@ const SIMPLE = TEST_BASE_HTTP + "simple.css"; const LONG = TEST_BASE_HTTP + "doc_long.css"; const DOCUMENT_WITH_LONG_SHEET = "data:text/html;charset=UTF-8," + encodeURIComponent( ["<!DOCTYPE html>", "<html>", " <head>", " <title>Editor scroll test page</title>", - ' <link rel="stylesheet" type="text/css" href="'+SIMPLE+'">', - ' <link rel="stylesheet" type="text/css" href="'+LONG+'">', + ' <link rel="stylesheet" type="text/css" href="' + SIMPLE + '">', + ' <link rel="stylesheet" type="text/css" href="' + LONG + '">', " </head>", " <body>Editor scroll test page</body>", "</html>" ].join("\n")); const LINE_TO_SELECT = 201; add_task(function* () { let { ui } = yield openStyleEditorForURL(DOCUMENT_WITH_LONG_SHEET);
--- a/browser/devtools/styleeditor/test/browser_styleeditor_selectstylesheet.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_selectstylesheet.js @@ -4,17 +4,17 @@ "use strict"; // Test that StyleEditorUI.selectStyleSheet selects the correct sheet, line and // column. const TESTCASE_URI = TEST_BASE_HTTPS + "simple.html"; const LINE_NO = 5; -const COL_NO = 0; +const COL_NO = 0; add_task(function* () { let { ui } = yield openStyleEditorForURL(TESTCASE_URI); let editor = ui.editors[1]; info("Selecting style sheet #1."); yield ui.selectStyleSheet(editor.styleSheet.href, LINE_NO);
--- a/browser/devtools/styleeditor/test/browser_styleeditor_sourcemap_large.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_sourcemap_large.js @@ -1,27 +1,29 @@ /* vim: set ts=2 et sw=2 tw=80: */ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Covers the case from Bug 1128747, where loading a sourcemapped // file prevents the correct editor from being selected on load, // and causes a second iframe to be appended when the user clicks // editor in the list. const TESTCASE_URI = TEST_BASE_HTTPS + "sourcemaps-large.html"; add_task(function*() { let { ui } = yield openStyleEditorForURL(TESTCASE_URI); yield openEditor(ui.editors[0]); let iframes = ui.selectedEditor.details.querySelectorAll("iframe"); - is (iframes.length, 1, "There is only one editor iframe"); - ok (ui.selectedEditor.summary.classList.contains("splitview-active"), + is(iframes.length, 1, "There is only one editor iframe"); + ok(ui.selectedEditor.summary.classList.contains("splitview-active"), "The editor is selected"); }); function openEditor(editor) { getLinkFor(editor).click(); return editor.getSourceEditor(); }
--- a/browser/devtools/styleeditor/test/browser_styleeditor_sourcemap_watching.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_sourcemap_watching.js @@ -1,12 +1,14 @@ /* vim: set ts=2 et sw=2 tw=80: */ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + Components.utils.import("resource://gre/modules/Task.jsm"); let {Promise: promise} = Cu.import("resource://gre/modules/Promise.jsm", {}); const TESTCASE_URI_HTML = TEST_BASE_HTTP + "sourcemaps-watching.html"; const TESTCASE_URI_CSS = TEST_BASE_HTTP + "sourcemap-css/sourcemaps.css"; const TESTCASE_URI_REG_CSS = TEST_BASE_HTTP + "simple.css"; const TESTCASE_URI_SCSS = TEST_BASE_HTTP + "sourcemap-sass/sourcemaps.scss"; const TESTCASE_URI_MAP = TEST_BASE_HTTP + "sourcemap-css/sourcemaps.css.map"; @@ -20,26 +22,26 @@ const Cc = Components.classes; const Ci = Components.interfaces; let tempScope = {}; Components.utils.import("resource://gre/modules/FileUtils.jsm", tempScope); Components.utils.import("resource://gre/modules/NetUtil.jsm", tempScope); let FileUtils = tempScope.FileUtils; let NetUtil = tempScope.NetUtil; -function test() -{ +function test() { waitForExplicitFinish(); Services.prefs.setBoolPref(TRANSITIONS_PREF, false); Task.spawn(function*() { // copy all our files over so we don't screw them up for other tests let HTMLFile = yield copy(TESTCASE_URI_HTML, ["sourcemaps.html"]); - let CSSFile = yield copy(TESTCASE_URI_CSS, ["sourcemap-css", "sourcemaps.css"]); + let CSSFile = yield copy(TESTCASE_URI_CSS, + ["sourcemap-css", "sourcemaps.css"]); yield copy(TESTCASE_URI_SCSS, ["sourcemap-sass", "sourcemaps.scss"]); yield copy(TESTCASE_URI_MAP, ["sourcemap-css", "sourcemaps.css.map"]); yield copy(TESTCASE_URI_REG_CSS, ["simple.css"]); let uri = Services.io.newFileURI(HTMLFile); let testcaseURI = uri.resolve(""); let { ui } = yield openStyleEditorForURL(testcaseURI); @@ -72,26 +74,26 @@ function test() // process waiting for the CSS file to change. yield editSCSS(editor); // We can't run Sass or another compiler, so we fake it by just // directly changing the CSS file. yield editCSSFile(CSSFile); info("wrote to CSS file"); - }) + }); } function editSCSS(editor) { let deferred = promise.defer(); let pos = {line: 0, ch: 0}; editor.sourceEditor.replaceText(CSS_TEXT, pos, pos); - editor.saveToFile(null, function (file) { + editor.saveToFile(null, function(file) { ok(file, "Scss file should be saved"); deferred.resolve(); }); return deferred.promise; } function editCSSFile(CSSFile) { @@ -117,53 +119,51 @@ function finishUp() { /* Helpers */ function getLinkFor(editor) { return editor.summary.querySelector(".stylesheet-name"); } function getStylesheetNameFor(editor) { return editor.summary.querySelector(".stylesheet-name > label") - .getAttribute("value") + .getAttribute("value"); } -function copy(aSrcChromeURL, aDestFilePath) -{ - let destFile = FileUtils.getFile("ProfD", aDestFilePath); - return write(read(aSrcChromeURL), destFile); +function copy(srcChromeURL, destFilePath) { + let destFile = FileUtils.getFile("ProfD", destFilePath); + return write(read(srcChromeURL), destFile); } -function read(aSrcChromeURL) -{ +function read(srcChromeURL) { let scriptableStream = Cc["@mozilla.org/scriptableinputstream;1"] .getService(Ci.nsIScriptableInputStream); + let principal = Services.scriptSecurityManager.getSystemPrincipal(); - let channel = Services.io.newChannel2(aSrcChromeURL, + let channel = Services.io.newChannel2(srcChromeURL, null, null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal + null, + principal, + null, Ci.nsILoadInfo.SEC_NORMAL, Ci.nsIContentPolicy.TYPE_OTHER); let input = channel.open(); scriptableStream.init(input); let data = ""; while (input.available()) { data = data.concat(scriptableStream.read(input.available())); } scriptableStream.close(); input.close(); return data; } -function write(aData, aFile) -{ +function write(aData, aFile) { let deferred = promise.defer(); let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"] .createInstance(Ci.nsIScriptableUnicodeConverter); converter.charset = "UTF-8"; let istream = converter.convertToInputStream(aData);
--- a/browser/devtools/styleeditor/test/browser_styleeditor_sourcemaps.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_sourcemaps.js @@ -1,17 +1,18 @@ /* vim: set ts=2 et sw=2 tw=80: */ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // https rather than chrome to improve coverage const TESTCASE_URI = TEST_BASE_HTTPS + "sourcemaps.html"; const PREF = "devtools.styleeditor.source-maps-enabled"; - const contents = { "sourcemaps.scss": [ "", "$paulrougetpink: #f06;", "", "div {", " color: $paulrougetpink;", "}", @@ -35,17 +36,20 @@ const contents = { " background-color: #EEE; }", "", "/*# sourceMappingURL=sourcemaps.css.map */" ].join("\n"), "contained.css": [ "#header {", " color: #f06; }", "", - "/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJzYXNzL2NvbnRhaW5lZC5zY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBO0VBQ0UsT0FISyIsInNvdXJjZXNDb250ZW50IjpbIiRwaW5rOiAjZjA2O1xuXG4jaGVhZGVyIHtcbiAgY29sb3I6ICRwaW5rO1xufSJdfQ==*/" + "/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJma" + + "WxlIjoiIiwic291cmNlcyI6WyJzYXNzL2NvbnRhaW5lZC5zY3NzIl0sIm5hbWVzIjpbXSwi" + + "bWFwcGluZ3MiOiJBQUVBO0VBQ0UsT0FISyIsInNvdXJjZXNDb250ZW50IjpbIiRwaW5rOiA" + + "jZjA2O1xuXG4jaGVhZGVyIHtcbiAgY29sb3I6ICRwaW5rO1xufSJdfQ==*/" ].join("\n"), "test-stylus.styl": [ "paulrougetpink = #f06;", "", "div", " color: paulrougetpink", "", "span", @@ -54,19 +58,24 @@ const contents = { ].join("\n"), "test-stylus.css": [ "div {", " color: #f06;", "}", "span {", " background-color: #eee;", "}", - "/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3Qtc3R5bHVzLnN0eWwiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUE7RUFDRSxPQUFPLEtBQVA7O0FBRUY7RUFDRSxrQkFBa0IsS0FBbEIiLCJmaWxlIjoidGVzdC1zdHlsdXMuY3NzIiwic291cmNlc0NvbnRlbnQiOlsicGF1bHJvdWdldHBpbmsgPSAjZjA2O1xuXG5kaXZcbiAgY29sb3I6IHBhdWxyb3VnZXRwaW5rXG5cbnNwYW5cbiAgYmFja2dyb3VuZC1jb2xvcjogI0VFRVxuIl19 */" + "/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb" + + "3VyY2VzIjpbInRlc3Qtc3R5bHVzLnN0eWwiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFB" + + "RUE7RUFDRSxPQUFPLEtBQVA7O0FBRUY7RUFDRSxrQkFBa0IsS0FBbEIiLCJmaWxlIjoidGV" + + "zdC1zdHlsdXMuY3NzIiwic291cmNlc0NvbnRlbnQiOlsicGF1bHJvdWdldHBpbmsgPSAjZj" + + "A2O1xuXG5kaXZcbiAgY29sb3I6IHBhdWxyb3VnZXRwaW5rXG5cbnNwYW5cbiAgYmFja2dyb" + + "3VuZC1jb2xvcjogI0VFRVxuIl19 */" ].join("\n") -} +}; const cssNames = ["sourcemaps.css", "contained.css", "test-stylus.css"]; const origNames = ["sourcemaps.scss", "contained.scss", "test-stylus.styl"]; waitForExplicitFinish(); add_task(function*() { let {ui} = yield openStyleEditorForURL(TESTCASE_URI); @@ -131,10 +140,10 @@ function openEditor(editor) { } function getLinkFor(editor) { return editor.summary.querySelector(".stylesheet-name"); } function getStylesheetNameFor(editor) { return editor.summary.querySelector(".stylesheet-name > label") - .getAttribute("value") + .getAttribute("value"); }
--- a/browser/devtools/styleeditor/test/browser_styleeditor_sv_keynav.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_sv_keynav.js @@ -19,27 +19,25 @@ add_task(function* () { testKeyboardNavigation(ui.editors[0], panel); info("Waiting for editor #2 to be selected due to keyboard navigation."); yield selected; ok(ui.editors[2].sourceEditor.hasFocus(), "Editor #2 has focus."); }); -function getStylesheetNameLinkFor(aEditor) -{ - return aEditor.summary.querySelector(".stylesheet-name"); +function getStylesheetNameLinkFor(editor) { + return editor.summary.querySelector(".stylesheet-name"); } -function testKeyboardNavigation(aEditor, panel) -{ +function testKeyboardNavigation(editor, panel) { let panelWindow = panel.panelWindow; let ui = panel.UI; - waitForFocus(function () { - let summary = aEditor.summary; + waitForFocus(function() { + let summary = editor.summary; EventUtils.synthesizeMouseAtCenter(summary, {}, panelWindow); let item = getStylesheetNameLinkFor(ui.editors[0]); is(panelWindow.document.activeElement, item, "editor 0 item is the active element"); EventUtils.synthesizeKey("VK_DOWN", {}, panelWindow); item = getStylesheetNameLinkFor(ui.editors[1]);
--- a/browser/devtools/styleeditor/test/browser_styleeditor_sv_resize.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_sv_resize.js @@ -1,12 +1,14 @@ /* vim: set ts=2 et sw=2 tw=80: */ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that resizing the source editor container doesn't move the caret. const TESTCASE_URI = TEST_BASE_HTTP + "simple.html"; const {Toolbox} = require("devtools/framework/toolbox"); add_task(function* () { let { toolbox, ui } = yield openStyleEditorForURL(TESTCASE_URI);
--- a/browser/devtools/styleeditor/test/browser_styleeditor_transition_rule.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_transition_rule.js @@ -1,12 +1,14 @@ /* vim: set ts=2 et sw=2 tw=80: */ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + const TESTCASE_URI = TEST_BASE_HTTPS + "simple.html"; const NEW_RULE = "body { background-color: purple; }"; add_task(function*() { let { ui } = yield openStyleEditorForURL(TESTCASE_URI); is(ui.editors.length, 2, "correct number of editors");