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