Bug 700361 - View Source line numbers are busted for plain-text documents - test; r=gavin

This commit is contained in:
Geoff Lankow 2012-02-20 14:39:57 +13:00
parent 01ae5b4040
commit e9e7101bcd
3 changed files with 36 additions and 1 deletions

View File

@ -48,6 +48,7 @@ _BROWSER_CHROME_FILES = \
browser_bug699356.js \
browser_bug713810.js \
browser_contextmenu.js \
browser_gotoline.js \
browser_viewsourceprefs.js \
browser_viewsourceprefs_nonhtml.js \
head.js \

View File

@ -0,0 +1,27 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
let content = "line 1\nline 2\nline 3";
let runningPlainText = false;
function test() {
waitForExplicitFinish();
testViewSourceWindow("data:text/html," + encodeURIComponent(content), checkViewSource, function() {
testViewSourceWindow("data:text/plain," + encodeURIComponent(content), checkViewSource, finish);
});
}
function checkViewSource(aWindow) {
is(aWindow.gBrowser.contentDocument.body.textContent, content, "Correct content loaded");
let selection = aWindow.gBrowser.contentWindow.getSelection();
let statusPanel = aWindow.document.getElementById("statusbar-line-col");
is(statusPanel.getAttribute("label"), "", "Correct status bar text");
for (let i = 1; i <= 3; i++) {
aWindow.goToLine(i);
is(selection.toString(), "line " + i, "Correct text selected");
is(statusPanel.getAttribute("label"), "Line " + i + ", Col 1", "Correct status bar text");
}
}

View File

@ -18,12 +18,19 @@ function closeViewSourceWindow(aWindow, aCallback) {
Services.wm.addListener({
onCloseWindow: function() {
Services.wm.removeListener(this);
aCallback();
executeSoon(aCallback);
}
});
aWindow.close();
}
function testViewSourceWindow(aURI, aTestCallback, aCloseCallback) {
openViewSourceWindow(aURI, function(aWindow) {
aTestCallback(aWindow);
closeViewSourceWindow(aWindow, aCloseCallback);
});
}
function openViewPartialSourceWindow(aReference, aCallback) {
let viewSourceWindow = openDialog("chrome://global/content/viewPartialSource.xul",
null, null, null, null, aReference, "selection");