author | Geoff Lankow <geoff@darktrojan.net> |
Mon, 20 Feb 2012 14:39:57 +1300 | |
changeset 88147 | 512d60d499969e06f6c35b2923e7fdb71618d67d |
parent 88146 | 1a6d1d4e8bfca1739ab5c5ab3747449705332b09 |
child 88148 | b5beb0298fa5339bf35ff4ba0d94300cd50e98a3 |
push id | 22173 |
push user | bmo@edmorley.co.uk |
push date | Sat, 03 Mar 2012 13:14:42 +0000 |
treeherder | mozilla-central@ed57abebd328 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | gavin |
bugs | 700361 |
milestone | 13.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/toolkit/components/viewsource/test/browser/Makefile.in +++ b/toolkit/components/viewsource/test/browser/Makefile.in @@ -43,15 +43,16 @@ relativesrcdir = toolkit/components/vie include $(DEPTH)/config/autoconf.mk include $(topsrcdir)/config/rules.mk _BROWSER_CHROME_FILES = \ browser_bug699356.js \ browser_bug713810.js \ browser_contextmenu.js \ + browser_gotoline.js \ browser_viewsourceprefs.js \ browser_viewsourceprefs_nonhtml.js \ head.js \ $(NULL) libs:: $(_BROWSER_CHROME_FILES) $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
new file mode 100644 --- /dev/null +++ b/toolkit/components/viewsource/test/browser/browser_gotoline.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"); + } +}
--- a/toolkit/components/viewsource/test/browser/head.js +++ b/toolkit/components/viewsource/test/browser/head.js @@ -13,22 +13,29 @@ function openViewSourceWindow(aURI, aCal } }, false); } 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"); viewSourceWindow.addEventListener("pageshow", function pageShowHandler(event) { // Wait for the inner window to load, not viewSourceWindow. if (/^view-source:/.test(event.target.location)) { info("View source window opened: " + event.target.location); viewSourceWindow.removeEventListener("pageshow", pageShowHandler, false);