browser/base/content/test/general/browser_page_style_menu.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 function test() {
     2   waitForExplicitFinish();
     4   var tab = gBrowser.addTab();
     5   gBrowser.selectedTab = tab;
     6   tab.linkedBrowser.addEventListener("load", function () {
     7     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
     8     checkPageStyleMenu();
     9   }, true);
    10   let rootDir = getRootDirectory(gTestPath);
    11   content.location = rootDir + "page_style_sample.html";
    12 }
    14 function checkPageStyleMenu() {
    15   var menupopup = document.getElementById("pageStyleMenu")
    16                           .getElementsByTagName("menupopup")[0];
    17   gPageStyleMenu.fillPopup(menupopup);
    19   var items = [];
    20   var current = menupopup.getElementsByTagName("menuseparator")[0];
    21   while (current.nextSibling) {
    22     current = current.nextSibling;
    23     items.push(current);
    24   }
    26   var validLinks = 0;
    27   Array.forEach(content.document.getElementsByTagName("link"), function (link) {
    28     var title = link.getAttribute("title");
    29     var rel = link.getAttribute("rel");
    30     var media = link.getAttribute("media");
    31     var idstring = "link " + (title ? title : "without title and") +
    32                    " with rel=\"" + rel + "\"" +
    33                    (media ? " and media=\"" + media + "\"" : "");
    35     var item = items.filter(function (item) item.getAttribute("label") == title);
    36     var found = item.length == 1;
    37     var checked = found && (item[0].getAttribute("checked") == "true");
    39     switch (link.getAttribute("data-state")) {
    40       case "0":
    41         ok(!found, idstring + " does not show up in page style menu");
    42         break;
    43       case "0-todo":
    44         validLinks++;
    45         todo(!found, idstring + " should not show up in page style menu");
    46         ok(!checked, idstring + " is not selected");
    47         break;
    48       case "1":
    49         validLinks++;
    50         ok(found, idstring + " shows up in page style menu");
    51         ok(!checked, idstring + " is not selected");
    52         break;
    53       case "2":
    54         validLinks++;
    55         ok(found, idstring + " shows up in page style menu");
    56         ok(checked, idstring + " is selected");
    57         break;
    58       default:
    59         throw "data-state attribute is missing or has invalid value";
    60     }
    61   });
    63   is(validLinks, items.length, "all valid links found");
    65   gBrowser.removeCurrentTab();
    66   finish();
    67 }

mercurial