зеркало из https://github.com/mozilla/gecko-dev.git
Bug 801982 - Scratchpad doesn't show confirmation dialog after opening a file; r=harth
This commit is contained in:
Родитель
29bff0db7a
Коммит
4585798f8e
|
@ -676,8 +676,6 @@ var Scratchpad = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldOpen) {
|
if (shouldOpen) {
|
||||||
this._skipClosePrompt = true;
|
|
||||||
|
|
||||||
let file;
|
let file;
|
||||||
if (aFile) {
|
if (aFile) {
|
||||||
file = aFile;
|
file = aFile;
|
||||||
|
@ -1313,25 +1311,14 @@ var Scratchpad = {
|
||||||
* there are unsaved changes.
|
* there are unsaved changes.
|
||||||
*
|
*
|
||||||
* @param nsIDOMEvent aEvent
|
* @param nsIDOMEvent aEvent
|
||||||
|
* @param function aCallback
|
||||||
|
* Optional function you want to call when file is saved/closed.
|
||||||
|
* Used mainly for tests.
|
||||||
*/
|
*/
|
||||||
onClose: function SP_onClose(aEvent)
|
onClose: function SP_onClose(aEvent, aCallback)
|
||||||
{
|
{
|
||||||
if (this._skipClosePrompt) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.promptSave(function(aShouldClose, aSaved, aStatus) {
|
|
||||||
let shouldClose = aShouldClose;
|
|
||||||
if (aSaved && !Components.isSuccessCode(aStatus)) {
|
|
||||||
shouldClose = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldClose) {
|
|
||||||
this._skipClosePrompt = true;
|
|
||||||
window.close();
|
|
||||||
}
|
|
||||||
}.bind(this));
|
|
||||||
aEvent.preventDefault();
|
aEvent.preventDefault();
|
||||||
|
this.close(aCallback);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1350,7 +1337,6 @@ var Scratchpad = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldClose) {
|
if (shouldClose) {
|
||||||
this._skipClosePrompt = true;
|
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
if (aCallback) {
|
if (aCallback) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ let NetUtil = tempScope.NetUtil;
|
||||||
let FileUtils = tempScope.FileUtils;
|
let FileUtils = tempScope.FileUtils;
|
||||||
|
|
||||||
// only finish() when correct number of tests are done
|
// only finish() when correct number of tests are done
|
||||||
const expected = 5;
|
const expected = 6;
|
||||||
var count = 0;
|
var count = 0;
|
||||||
function done()
|
function done()
|
||||||
{
|
{
|
||||||
|
@ -69,6 +69,7 @@ function testSavedFile()
|
||||||
function testUnsaved()
|
function testUnsaved()
|
||||||
{
|
{
|
||||||
testUnsavedFileCancel();
|
testUnsavedFileCancel();
|
||||||
|
testCancelAfterLoad();
|
||||||
testUnsavedFileSave();
|
testUnsavedFileSave();
|
||||||
testUnsavedFileDontSave();
|
testUnsavedFileDontSave();
|
||||||
}
|
}
|
||||||
|
@ -89,6 +90,34 @@ function testUnsavedFileCancel()
|
||||||
}, {noFocus: true});
|
}, {noFocus: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test a regression where our confirmation dialog wasn't appearing
|
||||||
|
// after openFile calls. See bug 801982.
|
||||||
|
function testCancelAfterLoad()
|
||||||
|
{
|
||||||
|
openScratchpad(function(win) {
|
||||||
|
win.Scratchpad.setRecentFile(gFile);
|
||||||
|
win.Scratchpad.openFile(0);
|
||||||
|
win.Scratchpad.editor.dirty = true;
|
||||||
|
promptButton = win.BUTTON_POSITION_CANCEL;
|
||||||
|
|
||||||
|
let EventStub = {
|
||||||
|
called: false,
|
||||||
|
preventDefault: function() {
|
||||||
|
EventStub.called = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
win.Scratchpad.onClose(EventStub, function() {
|
||||||
|
ok(!win.closed, "cancelling dialog shouldn't close scratchpad");
|
||||||
|
ok(EventStub.called, "aEvent.preventDefault was called");
|
||||||
|
|
||||||
|
win.Scratchpad.editor.dirty = false;
|
||||||
|
win.close();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}, {noFocus: true});
|
||||||
|
}
|
||||||
|
|
||||||
function testUnsavedFileSave()
|
function testUnsavedFileSave()
|
||||||
{
|
{
|
||||||
openScratchpad(function(win) {
|
openScratchpad(function(win) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче