browser_pageInfo.js
Go to the documentation of this file.
1 function test() {
3 
4  var pageInfo, obs, atTest = 0;
5  var gTestPage = gBrowser.addTab();
6  gBrowser.selectedTab = gTestPage;
7  gTestPage.linkedBrowser.addEventListener("load", handleLoad, true);
8  content.location =
9  "https://example.com/browser/browser/base/content/test/feed_tab.html";
10  gTestPage.focus();
11 
12  var observer = {
13  observe: function(win, topic, data) {
14  if (topic != "page-info-dialog-loaded")
15  return;
16 
17  switch(atTest) {
18  case 0:
19  atTest++;
20  handlePageInfo();
21  break;
22  case 1:
23  atTest++;
24  pageInfo = win;
25  testLockClick();
26  break;
27  case 2:
28  atTest++;
29  obs.removeObserver(observer, "page-info-dialog-loaded");
30  testLockDoubleClick();
31  break;
32  }
33  }
34  }
35 
36  function handleLoad() {
37 
38  pageInfo = BrowserPageInfo();
39  obs = Components.classes["@mozilla.org/observer-service;1"]
40  .getService(Components.interfaces.nsIObserverService);
41  obs.addObserver(observer, "page-info-dialog-loaded", false);
42  }
43 
44  function $(aId) { return pageInfo.document.getElementById(aId) };
45 
46  function handlePageInfo() {
47  var feedTab = $("feedTab");
48  var feedListbox = $("feedListbox");
49 
50  ok(feedListbox, "Feed list is null (feeds tab is broken)");
51 
52  var feedRowsNum = feedListbox.getRowCount();
53 
54  ok(feedRowsNum == 3, "Number of feeds listed: " +
55  feedRowsNum + ", should be 3");
56 
57 
58  for (var i = 0; i < feedRowsNum; i++) {
59  let feedItem = feedListbox.getItemAtIndex(i);
60  ok(feedItem.getAttribute("name") == (i+1),
61  "Name given: " + feedItem.getAttribute("name") + ", should be " + (i+1));
62  }
63 
64  pageInfo.addEventListener("unload", function() {
65  pageInfo.removeEventListener("unload", arguments.callee, false);
66  var lockIcon = document.getElementById("security-button");
67  EventUtils.synthesizeMouse(lockIcon, 0, 0, {clickCount: 1});
68  }, false);
69  pageInfo.close();
70  }
71 
72  function testLockClick() {
73  var deck = $("mainDeck");
74  is(deck.selectedPanel.id, "securityPanel", "The security tab should open when the lock icon is clicked");
75  pageInfo.addEventListener("unload", function() {
76  pageInfo.removeEventListener("unload", arguments.callee, false);
77  var lockIcon = document.getElementById("security-button");
78  EventUtils.synthesizeMouse(lockIcon, 0, 0, {clickCount: 1});
79  EventUtils.synthesizeMouse(lockIcon, 0, 0, {clickCount: 2});
80  }, false);
81  pageInfo.close();
82  }
83 
84  function testLockDoubleClick() {
85  var pageInfoDialogs = Components.classes["@mozilla.org/appshell/window-mediator;1"]
86  .getService(Components.interfaces.nsIWindowMediator)
87  .getEnumerator("Browser:page-info");
88  var i = 0;
89  while(pageInfoDialogs.hasMoreElements()) {
90  i++;
91  pageInfo = pageInfoDialogs.getNext();
92  pageInfo.close();
93  }
94  is(i, 1, "When the lock is clicked twice there should be only one page info dialog");
95  gTestPage.focus();
96  gBrowser.removeCurrentTab();
97  finish();
98  }
99 }
function BrowserPageInfo(doc, initialTab, imageElement)
Definition: browser.js:2128
waitForExplicitFinish()
return!aWindow arguments!aWindow arguments[0]
function test()
observe topic
Definition: FeedWriter.js:1326
observe data
Definition: FeedWriter.js:1329
_getSelectedPageStyle s i
let observer
sbDeviceFirmwareAutoCheckForUpdate prototype observe