diff --git a/browser/devtools/scratchpad/scratchpad.js b/browser/devtools/scratchpad/scratchpad.js index e540b1c0972..da3ed18efae 100644 --- a/browser/devtools/scratchpad/scratchpad.js +++ b/browser/devtools/scratchpad/scratchpad.js @@ -688,18 +688,6 @@ var Scratchpad = { file.initWithPath(filePath); } - if (!file.exists()) { - this.notificationBox.appendNotification( - this.strings.GetStringFromName("fileNoLongerExists.notification"), - "file-no-longer-exists", - null, - this.notificationBox.PRIORITY_WARNING_HIGH, - null); - - this.clearFiles(aIndex, 1); - return; - } - this.setFilename(file.path); this.importFromFile(file, false); this.setRecentFile(file); @@ -841,23 +829,6 @@ var Scratchpad = { } }, - /** - * Clear a range of files from the list. - * - * @param integer aIndex - * Index of file in menu to remove. - * @param integer aLength - * Number of files from the index 'aIndex' to remove. - */ - clearFiles: function SP_clearFile(aIndex, aLength) - { - let filePaths = this.getRecentFiles(); - let branch = Services.prefs. - getBranch("devtools.scratchpad."); - filePaths.splice(aIndex, aLength); - branch.setCharPref("recentFilePaths", JSON.stringify(filePaths)); - }, - /** * Clear all recent files. */ @@ -888,8 +859,11 @@ var Scratchpad = { let filePaths = this.getRecentFiles(); if (maxRecent < filePaths.length) { + let branch = Services.prefs. + getBranch("devtools.scratchpad."); let diff = filePaths.length - maxRecent; - this.clearFiles(0, diff); + filePaths.splice(0, diff); + branch.setCharPref("recentFilePaths", JSON.stringify(filePaths)); } } }, diff --git a/browser/devtools/scratchpad/test/browser_scratchpad_bug_651942_recent_files.js b/browser/devtools/scratchpad/test/browser_scratchpad_bug_651942_recent_files.js index 15a263c1210..776eb0d15f7 100644 --- a/browser/devtools/scratchpad/test/browser_scratchpad_bug_651942_recent_files.js +++ b/browser/devtools/scratchpad/test/browser_scratchpad_bug_651942_recent_files.js @@ -101,7 +101,7 @@ function testHideMenu() let menu = gScratchpadWindow.document.getElementById("sp-open_recent-menu"); ok(menu.hasAttribute("hidden"), "The menu was hidden successfully."); - Services.prefs.setIntPref("devtools.scratchpad.recentFilesMax", 2); + Services.prefs.setIntPref("devtools.scratchpad.recentFilesMax", 1); } // We have set the recentFilesMax-pref to one (1), this enables the feature, @@ -114,7 +114,7 @@ function testChangedMaxRecent() lists.recentFiles04 = gScratchpad.getRecentFiles(); - is(lists.recentFiles04.length, 2, + is(lists.recentFiles04.length, 1, "Two recent files were successfully removed from the 'recent files'-list"); let doc = gScratchpadWindow.document; @@ -123,39 +123,13 @@ function testChangedMaxRecent() let menuitemLabel = popup.children[0].getAttribute("label"); let correctMenuItem = false; if (menuitemLabel === lists.recentFiles03[2] && - menuitemLabel === lists.recentFiles04[1]) { + menuitemLabel === lists.recentFiles04[0]) { correctMenuItem = true; } is(correctMenuItem, true, "Two recent files were successfully removed from the 'Open Recent'-menu"); - // We now remove one file from the harddrive and use the recent-menuitem for - // it to make sure the user is notified that the file no longer exists. - // This is tested in testOpenDeletedFile(). - gFile02.remove(false); - gFile02 = null; - gScratchpad.openFile(1); -} - -// By now we should have two recent files stored in the list but one of the -// files should be missing on the harddrive. -function testOpenDeletedFile() { - let doc = gScratchpadWindow.document; - let popup = doc.getElementById("sp-menu-open_recentPopup"); - - is(gScratchpad.getRecentFiles().length, 1, - "The missing file was successfully removed from the list."); - // The number of recent files stored, plus the separator and the - // clearRecentMenuItems-item. - is(popup.children.length, 3, - "The missing file was successfully removed from the menu."); - ok(gScratchpad.notificationBox.currentNotification, - "The notification was successfully displayed."); - is(gScratchpad.notificationBox.currentNotification.label, - gScratchpad.strings.GetStringFromName("fileNoLongerExists.notification"), - "The notification label is correct."); - gScratchpad.clearRecentFiles(); } @@ -286,10 +260,6 @@ var PreferenceObserver = { break; case 7: this.timesFired = 8; - testOpenDeletedFile(); - break; - case 8: - this.timesFired = 9; testClearedAll(); break; } @@ -307,7 +277,8 @@ function test() registerCleanupFunction(function () { gFile01.remove(false); gFile01 = null; - // gFile02 was removed earlier. + gFile02.remove(false); + gFile02 = null; gFile03.remove(false); gFile03 = null; gFile04.remove(false); diff --git a/browser/locales/en-US/chrome/browser/devtools/scratchpad.properties b/browser/locales/en-US/chrome/browser/devtools/scratchpad.properties index 179f3fbac3e..024c8b7cee4 100644 --- a/browser/locales/en-US/chrome/browser/devtools/scratchpad.properties +++ b/browser/locales/en-US/chrome/browser/devtools/scratchpad.properties @@ -78,7 +78,3 @@ browserContext.notification=This scratchpad executes in the Browser context. # LOCALIZATION NOTE (help.openDocumentationPage): This returns a localized link with # documentation for Scratchpad on MDN. help.openDocumentationPage=https://developer.mozilla.org/en/Tools/Scratchpad - -# LOCALIZATION NOTE (fileExists.notification): This is the message displayed -# over the top of the the editor when a file does not exist. -fileNoLongerExists.notification=This file no longer exists.