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

--HG--
extra : rebase_source : d2697330086c6a56191c4db990642d421e755ca9
This commit is contained in:
Steven Englehardt 2016-09-13 21:18:38 +08:00
parent 84249d0d06
commit 9d9bb6765e
2 changed files with 13 additions and 1 deletions

View File

@ -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");

View File

@ -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);
});