From f2641570d6d3f87a661c2b010953dbf1a5ac0dde Mon Sep 17 00:00:00 2001 From: Girish Sharma Date: Mon, 22 Oct 2012 11:20:08 +0530 Subject: [PATCH 01/14] Bug 800231 - Intermittent browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js | Test timed out, | Found a Tools:StyleEditor after previous test timed out; r=msucan --- ...le_bug_782653_CSS_links_in_Style_Editor.js | 113 ++++++++++-------- 1 file changed, 62 insertions(+), 51 deletions(-) diff --git a/browser/devtools/webconsole/test/browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js b/browser/devtools/webconsole/test/browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js index 54a111d91cf1..0df552d4ac76 100644 --- a/browser/devtools/webconsole/test/browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js +++ b/browser/devtools/webconsole/test/browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js @@ -42,51 +42,52 @@ function testViewSource(hud) { function checkStyleEditorForSheetAndLine(aStyleSheetIndex, aLine, aCallback) { function doCheck(aEditor) { - if (aEditor.styleSheetIndex != aStyleSheetIndex) { - ok(false, "Correct Style Sheet was not selected."); + function checkLineAndCallback() { + info("In checkLineAndCallback()"); + ok(aEditor.sourceEditor != null, "sourceeditor not null"); + ok(aEditor.sourceEditor.getCaretPosition() != null, "position not null"); + ok(aEditor.sourceEditor.getCaretPosition().line != null, "line not null"); + is(aEditor.sourceEditor.getCaretPosition().line, aLine, + "Correct line is selected"); if (aCallback) { - executeSoon(aCallback); + aCallback(); } - return; } - ok(true, "Correct Style Sheet is selected in the editor"); - - // Editor is already loaded, check the current line of caret. - if (aEditor.sourceEditor) { - ok(true, "Editor is already loaded, check the current line of caret"); - executeSoon(function() { - ok(true, "Execute soon occured"); - ok(aEditor.sourceEditor != null, "sourceeditor not null"); - ok(aEditor.sourceEditor.getCaretPosition() != null, "position not null"); - ok(aEditor.sourceEditor.getCaretPosition().line != null, "line not null"); - is(aEditor.sourceEditor.getCaretPosition().line, aLine, - "Correct line is selected"); - if (aCallback) { - aCallback(); - } - }); - return; - } - - ok(true, "Editor is not loaded, waiting for it."); ok(aEditor, "aEditor is defined."); + + // Source-editor is already loaded, check the current line of caret. + if (aEditor.sourceEditor) { + if (aEditor.styleSheetIndex != SEC.selectedStyleSheetIndex) { + ok(false, "Correct Style Sheet was not selected."); + if (aCallback) { + executeSoon(aCallback); + } + return; + } + + info("Correct Style Sheet is selected in the editor"); + info("Editor is already loaded, check the current line of caret"); + executeSoon(checkLineAndCallback); + return; + } + + info("source editor is not loaded, waiting for it."); // Wait for source editor to be loaded. aEditor.addActionListener({ onAttach: function onAttach() { - ok(true, "on attach happened"); + info("on attach happened"); aEditor.removeActionListener(this); - ok(true, "this removed"); + info("this removed"); executeSoon(function() { - ok(true, "execute soon"); - ok(aEditor.sourceEditor != null, "sourceeditor not null"); - ok(aEditor.sourceEditor.getCaretPosition() != null, "position not null"); - ok(aEditor.sourceEditor.getCaretPosition().line != null, "line not null"); - is(aEditor.sourceEditor.getCaretPosition().line, aLine, - "Correct line is selected"); - if (aCallback) { - aCallback(); + if (aEditor.styleSheetIndex != SEC.selectedStyleSheetIndex) { + ok(false, "Correct Style Sheet was not selected."); + if (aCallback) { + aCallback(); + } + return; } + checkLineAndCallback() }); } }); @@ -98,19 +99,27 @@ function checkStyleEditorForSheetAndLine(aStyleSheetIndex, aLine, aCallback) { // Editors are not ready, so wait for them. if (!SEC.editors.length) { + info("Editor is not ready, waiting before doing check."); SEC.addChromeListener({ onEditorAdded: function onEditorAdded(aChrome, aEditor) { + info("Editor loaded now. Removing listener and doing check."); aChrome.removeChromeListener(this); - doCheck(aEditor); + executeSoon(function() { + doCheck(aEditor); + }); } }); } // Execute soon so that selectedStyleSheetIndex has correct value. else { - executeSoon(function() { - let aEditor = SEC.editors[SEC.selectedStyleSheetIndex]; - doCheck(aEditor); - }); + info("Editor is defined, opening the desired editor for now and " + + "checking later if it is correct"); + for (let aEditor of SEC.editors) { + if (aEditor.styleSheetIndex == aStyleSheetIndex) { + doCheck(aEditor); + break; + } + } } } @@ -120,26 +129,28 @@ let observer = { return; } Services.ww.unregisterNotification(observer); - ok(true, "Style Editor window was opened in response to clicking " + - "the location node"); + info("Style Editor window was opened in response to clicking " + + "the location node"); executeSoon(function() { styleEditorWin = window.StyleEditor .StyleEditorManager .getEditorForWindow(content.window); ok(styleEditorWin, "Style Editor Window is defined"); - styleEditorWin.addEventListener("load", function onStyleEditorWinLoad() { - styleEditorWin.removeEventListener("load", onStyleEditorWinLoad); + waitForFocus(function() { + //styleEditorWin.addEventListener("load", function onStyleEditorWinLoad() { + //styleEditorWin.removeEventListener("load", onStyleEditorWinLoad); - checkStyleEditorForSheetAndLine(0, 7, function() { - checkStyleEditorForSheetAndLine(1, 6, function() { - window.StyleEditor.toggle(); - styleEditorWin = null; - finishTest(); + checkStyleEditorForSheetAndLine(0, 7, function() { + checkStyleEditorForSheetAndLine(1, 6, function() { + window.StyleEditor.toggle(); + styleEditorWin = null; + finishTest(); + }); + EventUtils.sendMouseEvent({ type: "click" }, nodes[1]); }); - EventUtils.sendMouseEvent({ type: "click" }, nodes[1]); - }); - }); + //}); + }, styleEditorWin); }); } }; From e4a574e99195d2f2ec2079a7a74fd025cc80e7cd Mon Sep 17 00:00:00 2001 From: Anton Kovalyov Date: Mon, 22 Oct 2012 15:53:23 -0700 Subject: [PATCH 02/14] Bug 794898 - Scratchpad should ask for confirmation before closing; r=harth --- browser/devtools/scratchpad/scratchpad.js | 13 +++--- ...ser_scratchpad_bug_653427_confirm_close.js | 44 +++++++++++++++---- .../browser_scratchpad_bug_669612_unsaved.js | 8 ++-- 3 files changed, 46 insertions(+), 19 deletions(-) diff --git a/browser/devtools/scratchpad/scratchpad.js b/browser/devtools/scratchpad/scratchpad.js index 745f313057b5..36e9b7ad2e1c 100644 --- a/browser/devtools/scratchpad/scratchpad.js +++ b/browser/devtools/scratchpad/scratchpad.js @@ -130,12 +130,13 @@ var Scratchpad = { */ _updateTitle: function SP__updateTitle() { - if (this.filename) { - document.title = (this.editor && this.editor.dirty ? "*" : "") + - this.filename; - } else { - document.title = this._initialWindowTitle; + let title = this.filename || this._initialWindowTitle; + + if (this.editor && this.editor.dirty) { + title = "*" + title; } + + document.title = title; }, /** @@ -1267,7 +1268,7 @@ var Scratchpad = { */ promptSave: function SP_promptSave(aCallback) { - if (this.filename && this.editor.dirty) { + if (this.editor.dirty) { let ps = Services.prompt; let flags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_SAVE + ps.BUTTON_POS_1 * ps.BUTTON_TITLE_CANCEL + diff --git a/browser/devtools/scratchpad/test/browser_scratchpad_bug_653427_confirm_close.js b/browser/devtools/scratchpad/test/browser_scratchpad_bug_653427_confirm_close.js index c8928c9ff260..cbcaf0ddf8b9 100644 --- a/browser/devtools/scratchpad/test/browser_scratchpad_bug_653427_confirm_close.js +++ b/browser/devtools/scratchpad/test/browser_scratchpad_bug_653427_confirm_close.js @@ -9,7 +9,7 @@ let NetUtil = tempScope.NetUtil; let FileUtils = tempScope.FileUtils; // only finish() when correct number of tests are done -const expected = 6; +const expected = 9; var count = 0; function done() { @@ -68,16 +68,42 @@ function testSavedFile() function testUnsaved() { - testUnsavedFileCancel(); + function setFilename(aScratchpad, aFile) { + aScratchpad.setFilename(aFile); + } + + testUnsavedFileCancel(setFilename); + testUnsavedFileSave(setFilename); + testUnsavedFileDontSave(setFilename); testCancelAfterLoad(); - testUnsavedFileSave(); + + function mockSaveFile(aScratchpad) { + let SaveFileStub = function (aCallback) { + /* + * An argument for aCallback must pass Components.isSuccessCode + * + * A version of isSuccessCode in JavaScript: + * function isSuccessCode(returnCode) { + * return (returnCode & 0x80000000) == 0; + * } + */ + aCallback(1); + }; + + aScratchpad.saveFile = SaveFileStub; + } + + // Run these tests again but this time without setting a filename to + // test that Scratchpad always asks for confirmation on dirty editor. + testUnsavedFileCancel(mockSaveFile); + testUnsavedFileSave(mockSaveFile); testUnsavedFileDontSave(); } -function testUnsavedFileCancel() +function testUnsavedFileCancel(aCallback=function () {}) { openScratchpad(function(win) { - win.Scratchpad.setFilename("test.js"); + aCallback(win.Scratchpad, "test.js"); win.Scratchpad.editor.dirty = true; promptButton = win.BUTTON_POSITION_CANCEL; @@ -118,11 +144,11 @@ function testCancelAfterLoad() }, {noFocus: true}); } -function testUnsavedFileSave() +function testUnsavedFileSave(aCallback=function () {}) { openScratchpad(function(win) { win.Scratchpad.importFromFile(gFile, true, function(status, content) { - win.Scratchpad.setFilename(gFile.path); + aCallback(win.Scratchpad, gFile.path); let text = "new text"; win.Scratchpad.setText(text); @@ -140,10 +166,10 @@ function testUnsavedFileSave() }, {noFocus: true}); } -function testUnsavedFileDontSave() +function testUnsavedFileDontSave(aCallback=function () {}) { openScratchpad(function(win) { - win.Scratchpad.setFilename(gFile.path); + aCallback(win.Scratchpad, gFile.path); win.Scratchpad.editor.dirty = true; promptButton = win.BUTTON_POSITION_DONT_SAVE; diff --git a/browser/devtools/scratchpad/test/browser_scratchpad_bug_669612_unsaved.js b/browser/devtools/scratchpad/test/browser_scratchpad_bug_669612_unsaved.js index a5f030b3047e..15d4bb61542e 100644 --- a/browser/devtools/scratchpad/test/browser_scratchpad_bug_669612_unsaved.js +++ b/browser/devtools/scratchpad/test/browser_scratchpad_bug_669612_unsaved.js @@ -1,6 +1,6 @@ /* vim: set ts=2 et sw=2 tw=80: */ /* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ + http://creativecommons.org/publicdomain/zero/1.0/ */ // only finish() when correct number of tests are done const expected = 4; @@ -18,7 +18,7 @@ var ScratchpadManager = Scratchpad.ScratchpadManager; function test() { waitForExplicitFinish(); - + testListeners(); testRestoreNotFromFile(); testRestoreFromFileSaved(); @@ -32,7 +32,7 @@ function testListeners() { openScratchpad(function(aWin, aScratchpad) { aScratchpad.setText("new text"); - ok(!isStar(aWin), "no star if scratchpad isn't from a file"); + ok(isStar(aWin), "show start if scratchpad text changes"); aScratchpad.editor.dirty = false; ok(!isStar(aWin), "no star before changing text"); @@ -68,7 +68,7 @@ function testRestoreNotFromFile() let [win] = ScratchpadManager.restoreSession(session); openScratchpad(function(aWin, aScratchpad) { aScratchpad.setText("new text"); - ok(!isStar(win), "no star if restored scratchpad isn't from a file"); + ok(isStar(win), "show star if restored scratchpad isn't from a file"); win.close(); done(); From 0f97a251dbe4be9ca2c94f58a706e3c781e3b291 Mon Sep 17 00:00:00 2001 From: Ekanan Ketunuti Date: Sun, 21 Oct 2012 18:01:56 +0700 Subject: [PATCH 03/14] Bug 803948 - Fix typos in localization comments for developer tools; r=paul --- .../locales/en-US/chrome/browser/devtools/debugger.dtd | 2 +- .../en-US/chrome/browser/devtools/debugger.properties | 2 +- .../en-US/chrome/browser/devtools/gclicommands.properties | 8 ++++---- .../en-US/chrome/browser/devtools/webconsole.properties | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/browser/locales/en-US/chrome/browser/devtools/debugger.dtd b/browser/locales/en-US/chrome/browser/devtools/debugger.dtd index 4302a1eee341..f10798836473 100644 --- a/browser/locales/en-US/chrome/browser/devtools/debugger.dtd +++ b/browser/locales/en-US/chrome/browser/devtools/debugger.dtd @@ -16,7 +16,7 @@ + - Tools menu entry of Debugger that opens the debugger UI. -->