toolkit/components/viewsource/test/browser/browser_gotoline.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/viewsource/test/browser/browser_gotoline.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,27 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 + * http://creativecommons.org/publicdomain/zero/1.0/
     1.6 + */
     1.7 +
     1.8 +let content = "line 1\nline 2\nline 3";
     1.9 +let runningPlainText = false;
    1.10 +
    1.11 +function test() {
    1.12 +  waitForExplicitFinish();
    1.13 +
    1.14 +  testViewSourceWindow("data:text/html," + encodeURIComponent(content), checkViewSource, function() {
    1.15 +    testViewSourceWindow("data:text/plain," + encodeURIComponent(content), checkViewSource, finish);
    1.16 +  });
    1.17 +}
    1.18 +
    1.19 +function checkViewSource(aWindow) {
    1.20 +  is(aWindow.gBrowser.contentDocument.body.textContent, content, "Correct content loaded");
    1.21 +
    1.22 +  let selection = aWindow.gBrowser.contentWindow.getSelection();
    1.23 +  let statusPanel = aWindow.document.getElementById("statusbar-line-col");
    1.24 +  is(statusPanel.getAttribute("label"), "", "Correct status bar text");
    1.25 +  for (let i = 1; i <= 3; i++) {
    1.26 +    aWindow.goToLine(i);
    1.27 +    is(selection.toString(), "line " + i, "Correct text selected");
    1.28 +    is(statusPanel.getAttribute("label"), "Line " + i + ", Col 1", "Correct status bar text");
    1.29 +  }
    1.30 +}

mercurial