зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1343603 - Part 2 - Test that clearing history clears the cached session store data, too. r=ahunt
MozReview-Commit-ID: 3YhHnmnkgCS --HG-- extra : rebase_source : ce9cdf0df97d7bf6be116037f690a3a44c97346e
This commit is contained in:
Родитель
ff6a093d9d
Коммит
2669dd3183
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Article title</title>
|
||||
<title>Article title - mobile</title>
|
||||
<meta name="description" content="This is the article description." />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
|
|
|
@ -40,6 +40,7 @@ skip-if = true # Bug 1241478
|
|||
[test_restricted_profiles.html]
|
||||
[test_select_disabled.html]
|
||||
[test_selectoraddtab.html]
|
||||
[test_session_clear_history.html]
|
||||
[test_session_form_data.html]
|
||||
[test_session_parentid.html]
|
||||
[test_session_scroll_position.html]
|
||||
|
|
|
@ -0,0 +1,151 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1343603
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1343603</title>
|
||||
<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>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="head.js"></script>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 1343603 **/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Messaging.jsm");
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
|
||||
// The chrome window
|
||||
let chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
let BrowserApp = chromeWin.BrowserApp;
|
||||
|
||||
// Track the tabs where the tests are happening
|
||||
let tabBlank;
|
||||
let tabTest;
|
||||
|
||||
function cleanupTabs() {
|
||||
if (tabBlank) {
|
||||
BrowserApp.closeTab(tabBlank);
|
||||
tabBlank = null;
|
||||
}
|
||||
|
||||
if (tabTest) {
|
||||
BrowserApp.closeTab(tabTest);
|
||||
tabTest = null;
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTest.registerCleanupFunction(function() {
|
||||
cleanupTabs();
|
||||
});
|
||||
|
||||
|
||||
const url1 = "http://example.org/chrome/mobile/android/tests/browser/chrome/basic_article_mobile.html";
|
||||
const url2 = "http://example.org/chrome/mobile/android/tests/browser/chrome/basic_article.html";
|
||||
const url3 = "data:text/html;charset=utf-8,It%20was%20a%20dark%20and%20stormy%20night.";
|
||||
|
||||
add_task(function* test_sessionStoreClearTabHistory() {
|
||||
// Add a new tab with some content
|
||||
tabTest = BrowserApp.addTab(url1 , { selected: true, parentId: BrowserApp.selectedTab.id });
|
||||
yield promiseBrowserEvent(tabTest.browser, "DOMTitleChanged");
|
||||
|
||||
// Navigate to create some history
|
||||
tabTest.browser.loadURI(url2);
|
||||
yield promiseBrowserEvent(tabTest.browser, "DOMTitleChanged");
|
||||
tabTest.browser.loadURI(url3);
|
||||
yield promiseBrowserEvent(tabTest.browser, "DOMTitleChanged");
|
||||
is(tabTest.browser.canGoBack, true, "can go back");
|
||||
tabTest.browser.goBack();
|
||||
yield promiseBrowserEvent(tabTest.browser, "DOMTitleChanged");
|
||||
|
||||
// Check that the session store has recorded this history
|
||||
let data = tabTest.browser.__SS_data;
|
||||
is(data.entries.length, 3, "the session store has captured 3 history entries");
|
||||
is(data.index, 2, "history index is correct");
|
||||
is(data.entries[0].url, url1, "URL of first history entry is correct");
|
||||
|
||||
// Clear browsing history
|
||||
let sanitize = { history:true };
|
||||
let notification = promiseNotification("sessionstore-state-purge-complete");
|
||||
|
||||
BrowserApp.sanitize(sanitize);
|
||||
yield notification;
|
||||
|
||||
// Only the current session history entry should remain
|
||||
data = tabTest.browser.__SS_data;
|
||||
is(data.entries.length, 1, "the session store has cleared all previous entries");
|
||||
is(data.index, 1, "history index is correct");
|
||||
is(data.entries[0].url, url2, "URL of first history entry is correct after data clearing");
|
||||
|
||||
cleanupTabs();
|
||||
});
|
||||
|
||||
add_task(function* test_sessionStoreClearZombieTabHistory() {
|
||||
// Add a new tab with some content
|
||||
tabTest = BrowserApp.addTab(url1 , { selected: true, parentId: BrowserApp.selectedTab.id });
|
||||
yield promiseBrowserEvent(tabTest.browser, "DOMTitleChanged");
|
||||
|
||||
// Navigate to create some history
|
||||
tabTest.browser.loadURI(url2);
|
||||
yield promiseBrowserEvent(tabTest.browser, "DOMTitleChanged");
|
||||
tabTest.browser.loadURI(url3);
|
||||
yield promiseBrowserEvent(tabTest.browser, "DOMTitleChanged");
|
||||
is(tabTest.browser.canGoBack, true, "can go back");
|
||||
tabTest.browser.goBack();
|
||||
yield promiseBrowserEvent(tabTest.browser, "DOMTitleChanged");
|
||||
|
||||
// Check that the session store has recorded this history
|
||||
let data = tabTest.browser.__SS_data;
|
||||
is(data.entries.length, 3, "the session store has captured 3 history entries");
|
||||
is(data.index, 2, "history index is correct");
|
||||
is(data.entries[0].url, url1, "URL of first history entry is correct");
|
||||
|
||||
// Open a new tab and zombify the original one
|
||||
tabBlank = BrowserApp.addTab("about:blank", { selected: true, parentId: BrowserApp.selectedTab.id });
|
||||
yield promiseTabEvent(BrowserApp.deck, "TabSelect");
|
||||
is(BrowserApp.selectedTab, tabBlank, "Test tab is in background.");
|
||||
|
||||
// Zombify the backgrounded test tab
|
||||
tabTest.zombify();
|
||||
|
||||
// Check that the test tab is actually zombified
|
||||
ok(tabTest.browser.__SS_restore, "Test tab is set for delay loading.");
|
||||
is(tabTest.browser.currentURI.spec, "about:blank", "Test tab is zombified.");
|
||||
|
||||
// Clear browsing history
|
||||
let sanitize = { history:true };
|
||||
let notification = promiseNotification("sessionstore-state-purge-complete");
|
||||
|
||||
BrowserApp.sanitize(sanitize);
|
||||
yield notification;
|
||||
|
||||
// Only the current session history entry should remain
|
||||
data = tabTest.browser.__SS_data;
|
||||
is(data.entries.length, 1, "the session store has cleared all previous entries");
|
||||
is(data.index, 1, "history index is correct");
|
||||
is(data.entries[0].url, url2, "URL of first history entry is correct after data clearing");
|
||||
|
||||
cleanupTabs();
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1343603">Mozilla Bug 1343603</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче