mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 700361 - View Source line numbers are busted for plain-text documents - test; r=gavin
This commit is contained in:
parent
01ae5b4040
commit
e9e7101bcd
@ -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 \
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user