Bug 1254865 - Tests for disableglobalhistory on <xul:browser> elements. r=Felipe
authorMike Conley <mconley@mozilla.com>
Wed, 23 Mar 2016 17:24:29 -0400
changeset 290721 358a4096b0caec9b8f33ca9e387b12888be00b70
parent 290720 f7affb27ef92a63b22e23b4f8703917a0e744cd2
child 290722 f2b8bb605d416b7f396295aec3b5f3703d1272ac
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFelipe
bugs1254865
milestone48.0a1
Bug 1254865 - Tests for disableglobalhistory on <xul:browser> elements. r=Felipe MozReview-Commit-ID: 6WWDdtDVMQm
toolkit/components/places/tests/chrome/browser_disableglobalhistory.xul
toolkit/components/places/tests/chrome/chrome.ini
toolkit/components/places/tests/chrome/test_browser_disableglobalhistory.xul
new file mode 100644
--- /dev/null
+++ b/toolkit/components/places/tests/chrome/browser_disableglobalhistory.xul
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+
+<window title="Test disableglobalhistory attribute on remote browsers"
+  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+  onload="run_test();">
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
+
+  <browser id="inprocess_disabled" src="about:blank" type="content" disableglobalhistory="true" />
+  <browser id="inprocess_enabled" src="about:blank" type="content" />
+
+  <browser id="remote_disabled" src="about:blank" type="content" disableglobalhistory="true" />
+  <browser id="remote_enabled" src="about:blank" type="content" />
+
+  <script type="text/javascript;version=1.7">
+  const {interfaces: Ci, classes: Cc, results: Cr, utils: Cu} = Components;
+
+  Cu.import("resource://testing-common/ContentTask.jsm");
+  ContentTask.setTestScope(window.opener.wrappedJSObject);
+
+  function expectUseGlobalHistory(id, expected) {
+    let browser = document.getElementById(id);
+    return ContentTask.spawn(browser, {id, expected}, function*({id, expected}) {
+      Assert.equal(docShell.useGlobalHistory, expected,
+                   "Got the right useGlobalHistory state in the docShell of " + id);
+    });
+  }
+
+  function run_test() {
+    spawn_task(function*() {
+      yield expectUseGlobalHistory("inprocess_disabled", false);
+      yield expectUseGlobalHistory("inprocess_enabled", true);
+
+      yield expectUseGlobalHistory("remote_disabled", false);
+      yield expectUseGlobalHistory("remote_enabled", true);
+      window.opener.done();
+    });
+  };
+
+  </script>
+</window>
\ No newline at end of file
--- a/toolkit/components/places/tests/chrome/chrome.ini
+++ b/toolkit/components/places/tests/chrome/chrome.ini
@@ -4,8 +4,10 @@ skip-if = buildapp == 'b2g'
 [test_303567.xul]
 [test_341972a.xul]
 [test_341972b.xul]
 [test_342484.xul]
 [test_371798.xul]
 [test_381357.xul]
 [test_favicon_annotations.xul]
 [test_reloadLivemarks.xul]
+[test_browser_disableglobalhistory.xul]
+support-files = browser_disableglobalhistory.xul
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/toolkit/components/places/tests/chrome/test_browser_disableglobalhistory.xul
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
+                 type="text/css"?>
+
+<window title="Test disableglobalhistory attribute on remote browsers"
+  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+  <!-- test results are displayed in the html:body -->
+  <body xmlns="http://www.w3.org/1999/xhtml">
+  </body>
+
+  <script type="text/javascript;version=1.7">
+  SimpleTest.waitForExplicitFinish();
+
+  let w = window.open('browser_disableglobalhistory.xul', '_blank', 'chrome,resizable=yes,width=400,height=600');
+
+  function done() {
+    w.close();
+    SimpleTest.finish();
+  }
+  </script>
+
+</window>
\ No newline at end of file