зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1389564 - Part 2 - Test that restored (background) tabs are correctly written back to disk. r=gbrown
So far, we haven't tested session restoring and saving in combination, which led to bug 1379374 where restored background tabs weren't being written back to disk after upgrading to Firefox 55. MozReview-Commit-ID: 7CUbis7u8fb --HG-- extra : rebase_source : 2429ab8841ff5fb61765e73ac0988fc093be6817 extra : source : 35ec7ccb1b5ef71f875fa492bbcd571a5366602b
This commit is contained in:
Родитель
f521757b43
Коммит
ac81510e8c
|
@ -1046,6 +1046,7 @@ public class Tabs implements BundleEventListener {
|
|||
* Opens a new tab and loads either about:home or, if PREFS_HOMEPAGE_FOR_EVERY_NEW_TAB is set,
|
||||
* the user's homepage.
|
||||
*/
|
||||
@RobocopTarget
|
||||
public Tab addTab() {
|
||||
return loadUrl(getHomepageForNewTab(mAppContext), Tabs.LOADURL_NEW_TAB);
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ skip-if = android_version == "18"
|
|||
[src/org/mozilla/gecko/tests/testSearchSuggestions.java]
|
||||
# disabled on 4.3, bug 1145867
|
||||
skip-if = android_version == "18"
|
||||
[src/org/mozilla/gecko/tests/testSessionFilePreservation.java]
|
||||
[src/org/mozilla/gecko/tests/testSessionOOMSave.java]
|
||||
[src/org/mozilla/gecko/tests/testSessionOOMRestore.java]
|
||||
[src/org/mozilla/gecko/tests/testSettingsPages.java]
|
||||
|
|
|
@ -433,6 +433,13 @@ public abstract class SessionTest extends UITest {
|
|||
}
|
||||
}
|
||||
|
||||
protected void deleteProfileFile(String filename) {
|
||||
File fileToDelete = new File(mProfile, filename);
|
||||
if (!fileToDelete.delete()) {
|
||||
mAsserter.ok(false, "Error deleting " + filename, null);
|
||||
}
|
||||
}
|
||||
|
||||
private String readFile(File target) throws IOException {
|
||||
if (!target.exists()) {
|
||||
return null;
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package org.mozilla.gecko.tests;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import org.mozilla.gecko.Tab;
|
||||
import org.mozilla.gecko.Tabs;
|
||||
import org.mozilla.gecko.tests.helpers.GeckoHelper;
|
||||
|
||||
/**
|
||||
* Tests session OOM save behavior.
|
||||
*
|
||||
* Builds a session on disk, restores it and tests that
|
||||
* it is then written back to disk correctly.
|
||||
*/
|
||||
public class testSessionFilePreservation extends SessionTest {
|
||||
private Session mSession;
|
||||
|
||||
@Override
|
||||
public void setActivityIntent(Intent intent) {
|
||||
mSession = createTestSession(/*selected tab*/ 2);
|
||||
|
||||
injectSessionToRestore(intent, mSession);
|
||||
|
||||
super.setActivityIntent(intent);
|
||||
}
|
||||
|
||||
public void testSessionFilePreservation() {
|
||||
GeckoHelper.blockForReady();
|
||||
|
||||
// We have tests for making sure that
|
||||
// - tabs are correctly restored from a session store file
|
||||
// - opening new tabs generates a correct session store file
|
||||
|
||||
// These tests only use live tabs that are fully loaded. We now also want
|
||||
// to test that zombie tabs that have been unloaded in background are
|
||||
// written correctly as well, especially those zombie tabs that have been
|
||||
// created directly from the session file during session restoring.
|
||||
// Therefore we don't touch any of those tabs here to make sure that we're
|
||||
// not accidentally reloading them.
|
||||
|
||||
// To make sure we're not simply verifying the very same file we've generated
|
||||
// and written ourselves further up, we delete it...
|
||||
deleteProfileFile("sessionstore.js");
|
||||
|
||||
// ... and then trigger some session store activity to make sure
|
||||
// that a fresh session file is written.
|
||||
Tab tab = Tabs.getInstance().addTab();
|
||||
Tabs.getInstance().closeTab(tab);
|
||||
|
||||
// Verify sessionstore.js written by Gecko. The session write is delayed
|
||||
// to batch successive changes, so the file is repeatedly read until it
|
||||
// matches the expected output. Because of the delay, this part of the
|
||||
// test takes ~9 seconds to pass.
|
||||
VerifyJSONCondition verifyJSONCondition = new VerifyJSONCondition(mSession);
|
||||
boolean success = mSolo.waitForCondition(verifyJSONCondition, SESSION_TIMEOUT);
|
||||
if (success) {
|
||||
mAsserter.ok(true, "verified session JSON", null);
|
||||
} else {
|
||||
mAsserter.ok(false, "failed to verify session JSON",
|
||||
Log.getStackTraceString(verifyJSONCondition.getLastException()));
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче