mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
3e5987353c
--HG-- rename : browser/devtools/scratchpad/test/browser_scratchpad_bug807924_cannot_convert_to_string.js => browser/devtools/scratchpad/test/browser_scratchpad_cannot_convert_to_string.js rename : browser/devtools/scratchpad/test/browser_scratchpad_bug_646070_chrome_context_pref.js => browser/devtools/scratchpad/test/browser_scratchpad_chrome_context_pref.js rename : browser/devtools/scratchpad/test/browser_scratchpad_bug_653427_confirm_close.js => browser/devtools/scratchpad/test/browser_scratchpad_confirm_close.js rename : browser/devtools/scratchpad/test/browser_scratchpad_bug756681_display_non_error_exceptions.js => browser/devtools/scratchpad/test/browser_scratchpad_display_non_error_exceptions.js rename : browser/devtools/scratchpad/test/browser_scratchpad_bug690552_display_outputs_errors.js => browser/devtools/scratchpad/test/browser_scratchpad_display_outputs_errors.js rename : browser/devtools/scratchpad/test/browser_scratchpad_bug_699130_edit_ui_updates.js => browser/devtools/scratchpad/test/browser_scratchpad_edit_ui_updates.js rename : browser/devtools/scratchpad/test/browser_scratchpad_bug_679467_falsy.js => browser/devtools/scratchpad/test/browser_scratchpad_falsy.js rename : browser/devtools/scratchpad/test/browser_scratchpad_bug714942_goto_line_ui.js => browser/devtools/scratchpad/test/browser_scratchpad_goto_line_ui.js rename : browser/devtools/scratchpad/test/browser_scratchpad_bug_650760_help_key.js => browser/devtools/scratchpad/test/browser_scratchpad_help_key.js rename : browser/devtools/scratchpad/test/browser_scratchpad_bug_644413_modeline.js => browser/devtools/scratchpad/test/browser_scratchpad_modeline.js rename : browser/devtools/scratchpad/test/browser_scratchpad_bug_651942_recent_files.js => browser/devtools/scratchpad/test/browser_scratchpad_recent_files.js rename : browser/devtools/scratchpad/test/browser_scratchpad_bug740948_reload_and_run.js => browser/devtools/scratchpad/test/browser_scratchpad_reload_and_run.js rename : browser/devtools/scratchpad/test/browser_scratchpad_bug684546_reset_undo.js => browser/devtools/scratchpad/test/browser_scratchpad_reset_undo.js rename : browser/devtools/scratchpad/test/browser_scratchpad_bug_751744_revert_to_saved.js => browser/devtools/scratchpad/test/browser_scratchpad_revert_to_saved.js rename : browser/devtools/scratchpad/test/browser_scratchpad_bug_660560_tab.js => browser/devtools/scratchpad/test/browser_scratchpad_tab.js rename : browser/devtools/scratchpad/test/browser_scratchpad_bug_669612_unsaved.js => browser/devtools/scratchpad/test/browser_scratchpad_unsaved.js rename : browser/devtools/scratchpad/test/browser_scratchpad_bug_661762_wrong_window_focus.js => browser/devtools/scratchpad/test/browser_scratchpad_wrong_window_focus.js
122 lines
2.8 KiB
JavaScript
122 lines
2.8 KiB
JavaScript
/* vim: set ts=2 et sw=2 tw=80: */
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
/* Bug 669612 */
|
|
|
|
// only finish() when correct number of tests are done
|
|
const expected = 4;
|
|
var count = 0;
|
|
function done()
|
|
{
|
|
if (++count == expected) {
|
|
finish();
|
|
}
|
|
}
|
|
|
|
var ScratchpadManager = Scratchpad.ScratchpadManager;
|
|
|
|
|
|
function test()
|
|
{
|
|
waitForExplicitFinish();
|
|
|
|
testListeners();
|
|
testRestoreNotFromFile();
|
|
testRestoreFromFileSaved();
|
|
testRestoreFromFileUnsaved();
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
content.location = "data:text/html,<p>test star* UI for unsaved file changes";
|
|
}
|
|
|
|
function testListeners()
|
|
{
|
|
openScratchpad(function(aWin, aScratchpad) {
|
|
aScratchpad.setText("new text");
|
|
ok(isStar(aWin), "show star if scratchpad text changes");
|
|
|
|
aScratchpad.dirty = false;
|
|
ok(!isStar(aWin), "no star before changing text");
|
|
|
|
aScratchpad.setFilename("foo.js");
|
|
aScratchpad.setText("new text2");
|
|
ok(isStar(aWin), "shows star if scratchpad text changes");
|
|
|
|
aScratchpad.dirty = false;
|
|
ok(!isStar(aWin), "no star if scratchpad was just saved");
|
|
|
|
aScratchpad.setText("new text3");
|
|
ok(isStar(aWin), "shows star if scratchpad has more changes");
|
|
|
|
aScratchpad.undo();
|
|
ok(!isStar(aWin), "no star if scratchpad undo to save point");
|
|
|
|
aScratchpad.undo();
|
|
ok(isStar(aWin), "star if scratchpad undo past save point");
|
|
|
|
aWin.close();
|
|
done();
|
|
}, {noFocus: true});
|
|
}
|
|
|
|
function testRestoreNotFromFile()
|
|
{
|
|
let session = [{
|
|
text: "test1",
|
|
executionContext: 1
|
|
}];
|
|
|
|
let [win] = ScratchpadManager.restoreSession(session);
|
|
openScratchpad(function(aWin, aScratchpad) {
|
|
aScratchpad.setText("new text");
|
|
ok(isStar(win), "show star if restored scratchpad isn't from a file");
|
|
|
|
win.close();
|
|
done();
|
|
}, {window: win, noFocus: true});
|
|
}
|
|
|
|
function testRestoreFromFileSaved()
|
|
{
|
|
let session = [{
|
|
filename: "test.js",
|
|
text: "test1",
|
|
executionContext: 1,
|
|
saved: true
|
|
}];
|
|
|
|
let [win] = ScratchpadManager.restoreSession(session);
|
|
openScratchpad(function(aWin, aScratchpad) {
|
|
ok(!isStar(win), "no star before changing text in scratchpad restored from file");
|
|
|
|
aScratchpad.setText("new text");
|
|
ok(isStar(win), "star when text changed from scratchpad restored from file");
|
|
|
|
win.close();
|
|
done();
|
|
}, {window: win, noFocus: true});
|
|
}
|
|
|
|
function testRestoreFromFileUnsaved()
|
|
{
|
|
let session = [{
|
|
filename: "test.js",
|
|
text: "test1",
|
|
executionContext: 1,
|
|
saved: false
|
|
}];
|
|
|
|
let [win] = ScratchpadManager.restoreSession(session);
|
|
openScratchpad(function() {
|
|
ok(isStar(win), "star with scratchpad restored with unsaved text");
|
|
|
|
win.close();
|
|
done();
|
|
}, {window: win, noFocus: true});
|
|
}
|
|
|
|
function isStar(win)
|
|
{
|
|
return win.document.title.match(/^\*[^\*]/);
|
|
}
|