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.

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

mercurial