michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: var tab = gBrowser.addTab(); michael@0: gBrowser.selectedTab = tab; michael@0: tab.linkedBrowser.addEventListener("load", function () { michael@0: tab.linkedBrowser.removeEventListener("load", arguments.callee, true); michael@0: checkPageStyleMenu(); michael@0: }, true); michael@0: let rootDir = getRootDirectory(gTestPath); michael@0: content.location = rootDir + "page_style_sample.html"; michael@0: } michael@0: michael@0: function checkPageStyleMenu() { michael@0: var menupopup = document.getElementById("pageStyleMenu") michael@0: .getElementsByTagName("menupopup")[0]; michael@0: gPageStyleMenu.fillPopup(menupopup); michael@0: michael@0: var items = []; michael@0: var current = menupopup.getElementsByTagName("menuseparator")[0]; michael@0: while (current.nextSibling) { michael@0: current = current.nextSibling; michael@0: items.push(current); michael@0: } michael@0: michael@0: var validLinks = 0; michael@0: Array.forEach(content.document.getElementsByTagName("link"), function (link) { michael@0: var title = link.getAttribute("title"); michael@0: var rel = link.getAttribute("rel"); michael@0: var media = link.getAttribute("media"); michael@0: var idstring = "link " + (title ? title : "without title and") + michael@0: " with rel=\"" + rel + "\"" + michael@0: (media ? " and media=\"" + media + "\"" : ""); michael@0: michael@0: var item = items.filter(function (item) item.getAttribute("label") == title); michael@0: var found = item.length == 1; michael@0: var checked = found && (item[0].getAttribute("checked") == "true"); michael@0: michael@0: switch (link.getAttribute("data-state")) { michael@0: case "0": michael@0: ok(!found, idstring + " does not show up in page style menu"); michael@0: break; michael@0: case "0-todo": michael@0: validLinks++; michael@0: todo(!found, idstring + " should not show up in page style menu"); michael@0: ok(!checked, idstring + " is not selected"); michael@0: break; michael@0: case "1": michael@0: validLinks++; michael@0: ok(found, idstring + " shows up in page style menu"); michael@0: ok(!checked, idstring + " is not selected"); michael@0: break; michael@0: case "2": michael@0: validLinks++; michael@0: ok(found, idstring + " shows up in page style menu"); michael@0: ok(checked, idstring + " is selected"); michael@0: break; michael@0: default: michael@0: throw "data-state attribute is missing or has invalid value"; michael@0: } michael@0: }); michael@0: michael@0: is(validLinks, items.length, "all valid links found"); michael@0: michael@0: gBrowser.removeCurrentTab(); michael@0: finish(); michael@0: }