зеркало из https://github.com/mozilla/gecko-dev.git
Merge m-c to fx-team
This commit is contained in:
Коммит
6b52040591
|
@ -105,13 +105,15 @@ function test() {
|
|||
is(elt.textContent, res1[i].value, res1[i].selector + " has the right value.");
|
||||
}
|
||||
|
||||
gBrowser.selectedBrowser.addEventListener("MozAfterPaint", test2, false);
|
||||
|
||||
InspectorUI.selection.style.height = "150px";
|
||||
InspectorUI.selection.style.paddingRight = "50px";
|
||||
|
||||
setTimeout(test2, 200); // Should be enough to get a MozAfterPaint event
|
||||
}
|
||||
|
||||
function test2() {
|
||||
gBrowser.selectedBrowser.removeEventListener("MozAfterPaint", test2, false);
|
||||
|
||||
let viewdoc = view.iframe.contentDocument;
|
||||
|
||||
for (let i = 0; i < res2.length; i++) {
|
||||
|
|
|
@ -697,6 +697,18 @@ 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);
|
||||
|
@ -847,6 +859,31 @@ 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();
|
||||
filePaths.splice(aIndex, aLength);
|
||||
|
||||
// WARNING: Do not use setCharPref here, it doesn't play nicely with
|
||||
// Unicode strings.
|
||||
|
||||
let str = Cc["@mozilla.org/supports-string;1"]
|
||||
.createInstance(Ci.nsISupportsString);
|
||||
str.data = JSON.stringify(filePaths);
|
||||
|
||||
let branch = Services.prefs.getBranch("devtools.scratchpad.");
|
||||
branch.setComplexValue("recentFilePaths",
|
||||
Ci.nsISupportsString, str);
|
||||
},
|
||||
|
||||
/**
|
||||
* Clear all recent files.
|
||||
*/
|
||||
|
@ -878,18 +915,7 @@ var Scratchpad = {
|
|||
let filePaths = this.getRecentFiles();
|
||||
if (maxRecent < filePaths.length) {
|
||||
let diff = filePaths.length - maxRecent;
|
||||
filePaths.splice(0, diff);
|
||||
|
||||
// WARNING: Do not use setCharPref here, it doesn't play nicely with
|
||||
// Unicode strings.
|
||||
|
||||
let str = Cc["@mozilla.org/supports-string;1"]
|
||||
.createInstance(Ci.nsISupportsString);
|
||||
str.data = JSON.stringify(filePaths);
|
||||
|
||||
let branch = Services.prefs.getBranch("devtools.scratchpad.");
|
||||
branch.setComplexValue("recentFilePaths",
|
||||
Ci.nsISupportsString, str);
|
||||
this.clearFiles(0, diff);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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", 1);
|
||||
Services.prefs.setIntPref("devtools.scratchpad.recentFilesMax", 2);
|
||||
}
|
||||
|
||||
// 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, 1,
|
||||
is(lists.recentFiles04.length, 2,
|
||||
"Two recent files were successfully removed from the 'recent files'-list");
|
||||
|
||||
let doc = gScratchpadWindow.document;
|
||||
|
@ -123,13 +123,51 @@ function testChangedMaxRecent()
|
|||
let menuitemLabel = popup.children[0].getAttribute("label");
|
||||
let correctMenuItem = false;
|
||||
if (menuitemLabel === lists.recentFiles03[2] &&
|
||||
menuitemLabel === lists.recentFiles04[0]) {
|
||||
menuitemLabel === lists.recentFiles04[1]) {
|
||||
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().
|
||||
gFile04.remove(false);
|
||||
|
||||
// Make sure the file has been deleted before continuing to avoid
|
||||
// intermittent oranges.
|
||||
waitForFileDeletion();
|
||||
}
|
||||
|
||||
function waitForFileDeletion() {
|
||||
if (gFile04.exists()) {
|
||||
executeSoon(waitForFileDeletion);
|
||||
return;
|
||||
}
|
||||
|
||||
gFile04 = null;
|
||||
gScratchpad.openFile(0);
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
@ -260,6 +298,10 @@ var PreferenceObserver = {
|
|||
break;
|
||||
case 7:
|
||||
this.timesFired = 8;
|
||||
testOpenDeletedFile();
|
||||
break;
|
||||
case 8:
|
||||
this.timesFired = 9;
|
||||
testClearedAll();
|
||||
break;
|
||||
}
|
||||
|
@ -281,8 +323,7 @@ function test()
|
|||
gFile02 = null;
|
||||
gFile03.remove(false);
|
||||
gFile03 = null;
|
||||
gFile04.remove(false);
|
||||
gFile04 = null;
|
||||
// gFile04 was removed earlier.
|
||||
lists.recentFiles01 = null;
|
||||
lists.recentFiles02 = null;
|
||||
lists.recentFiles03 = null;
|
||||
|
|
|
@ -83,3 +83,7 @@ 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.
|
||||
|
|
Загрузка…
Ссылка в новой задаче