Commit 9d9bb676 authored by Steven Englehardt's avatar Steven Englehardt
Browse files

Bug 1294866 - Part 3: Tests to verify contentPrincipal persists during session...

Bug 1294866 - Part 3: Tests to verify contentPrincipal persists during session restore. r=mikedeboer

--HG--
extra : rebase_source : d2697330086c6a56191c4db990642d421e755ca9
parent 84249d0d
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -17,8 +17,9 @@ add_task(function* test() {
  let tab = gBrowser.addTab("about:robots");
  yield promiseBrowserLoaded(tab.linkedBrowser);

  // Check that the tab has an 'image' attribute.
  // Check that the tab has 'image' and 'iconLoadingPrincipal' attributes.
  ok(tab.hasAttribute("image"), "tab.image exists");
  ok(tab.hasAttribute("iconLoadingPrincipal"), "tab.iconLoadingPrincipal exists");

  tab.toggleMuteAudio();
  // Check that the tab has a 'muted' attribute.
@@ -27,8 +28,10 @@ add_task(function* test() {
  // Make sure we do not persist 'image' or 'muted' attributes.
  ss.persistTabAttribute("image");
  ss.persistTabAttribute("muted");
  ss.persistTabAttribute("iconLoadingPrincipal");
  let {attributes} = JSON.parse(ss.getTabState(tab));
  ok(!("image" in attributes), "'image' attribute not saved");
  ok(!("iconLoadingPrincipal" in attributes), "'iconLoadingPrincipal' attribute not saved");
  ok(!("muted" in attributes), "'muted' attribute not saved");
  ok(!("custom" in attributes), "'custom' attribute not saved");

+9 −0
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@

"use strict";

const {classes: Cc, interfaces: Ci} = Components;

/**
 * Make sure that tabs are restored on demand as otherwise the tab will start
 * loading immediately and we can't check its icon and label.
@@ -39,6 +41,13 @@ add_task(function test_label_and_icon() {
  ok(gBrowser.getIcon(tab).startsWith("data:image/png;"), "icon is set");
  is(tab.label, "Gort! Klaatu barada nikto!", "label is set");

  let serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
                    .getService(Ci.nsISerializationHelper);
  let serializedPrincipal = tab.getAttribute("iconLoadingPrincipal");
  let iconLoadingPrincipal = serhelper.deserializeObject(serializedPrincipal)
                                      .QueryInterface(Ci.nsIPrincipal);
  is(iconLoadingPrincipal.origin, "about:robots", "correct loadingPrincipal used");

  // Cleanup.
  yield promiseRemoveTab(tab);
});