Bug 485855 - "--browser-chrome Mochitests on Fennec [tabs]" [r=mfinkle]
authorZadkiel <zadkiel.m@gmail.com>
Tue, 01 Sep 2009 16:01:00 -0500
changeset 65497 6cd1112381c50ef7f1034e97c1bef221e53ae8b9
parent 65496 bc3a55d8f9e95223de4af005e0b5181408766fa1
child 65498 1c3a8067aa4b5837f4282640ae87dfd811b61faa
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs485855
Bug 485855 - "--browser-chrome Mochitests on Fennec [tabs]" [r=mfinkle]
mobile/chrome/tests/Makefile.in
mobile/chrome/tests/browser_blank_01.html
mobile/chrome/tests/browser_blank_02.html
mobile/chrome/tests/browser_tabs.js
--- a/mobile/chrome/tests/Makefile.in
+++ b/mobile/chrome/tests/Makefile.in
@@ -41,12 +41,15 @@ srcdir    = @srcdir@
 VPATH     = @srcdir@
 relativesrcdir  = mobile/chrome
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _BROWSER_FILES = \
   browser_mainui.js \
+  browser_tabs.js \
+  browser_blank_01.html \
+  browser_blank_02.html \
   $(NULL)
 
 libs:: $(_BROWSER_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/mobile/chrome/tests/browser_blank_01.html
@@ -0,0 +1,6 @@
+<html>
+<title>Browser Blank Page 01</title>
+<body>
+Browser Blank Page 01
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/mobile/chrome/tests/browser_blank_02.html
@@ -0,0 +1,6 @@
+<html>
+<title>Browser Blank Page 02</title>
+<body>
+Browser Blank Page 02
+</body>
+</html>
new file mode 100755
--- /dev/null
+++ b/mobile/chrome/tests/browser_tabs.js
@@ -0,0 +1,53 @@
+  let iosvc = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
+  let testURL_01 = "chrome://mochikit/content/browser/mobile/chrome/browser_blank_01.html";
+  let testURL_02 = "chrome://mochikit/content/browser/mobile/chrome/browser_blank_02.html";
+  var new_tab_01;
+  var new_tab_02;
+
+  function load_tabs() {
+    var tabs_size_old = window.Browser._tabs.length -1; 
+    var new_tab = window.Browser.getTabAtIndex(1); 
+    var new_tab_URI = window.Browser.selectedTab.browser.currentURI.spec;
+    is(new_tab_URI, testURL_01, "URL Matches newly created Tab");
+
+    //Close new tab 
+    var close_tab = window.Browser.closeTab(new_tab);
+    var tabs_size_new = window.Browser._tabs.length; 	
+    is(tabs_size_new, tabs_size_old, "Tab Closed");
+
+    //Add new tab
+    new_tab_01 = window.Browser.addTab(testURL_01,false);
+
+    //Check tab switch
+    new_tab_01.browser.addEventListener("load", tab_switch_01, true);
+  }
+
+  function tab_switch_01(){
+    window.BrowserUI.selectTab(new_tab_01);
+    is(window.Browser.selectedTab.browser.currentURI.spec, testURL_01, "Tab Switch 01 URL Matches");
+
+    //Add new tab
+    new_tab_02 =  window.Browser.addTab(testURL_02,false);
+    new_tab_02.browser.addEventListener("load", tab_switch_02, true);
+  }
+
+  function tab_switch_02(){
+    window.BrowserUI.selectTab(new_tab_02);
+    is(window.Browser.selectedTab.browser.currentURI.spec, testURL_02, "Tab Switch 02 URL Matches");
+
+    window.BrowserUI.selectTab(new_tab_01);
+    is(window.Browser.selectedTab.browser.currentURI.spec, testURL_01, "Tab Switch 01 URL Matches"); 
+
+    //Close new tab 
+    window.Browser.closeTab(new_tab_01);
+    window.Browser.closeTab(new_tab_02);
+  }
+
+  function test(){ 
+    //Add new tab
+    var new_tab = window.Browser.addTab(testURL_01,true);
+    ok(new_tab, "Tab Opened");	
+
+    //Check currentURI.spec
+    new_tab.browser.addEventListener("load", load_tabs , true);
+  }