Skip to content

Commit

Permalink
Backed out 9 changesets (bug 1700623) for causing bc failures in brow…
Browse files Browse the repository at this point in the history
…ser_history_menu.js

CLOSED TREE

Backed out changeset 5eae296ad8b5 (bug 1700623)
Backed out changeset 97c3add3b00a (bug 1700623)
Backed out changeset 7ab483627a27 (bug 1700623)
Backed out changeset a4e673640de5 (bug 1700623)
Backed out changeset 513ea16be430 (bug 1700623)
Backed out changeset 88b4add342df (bug 1700623)
Backed out changeset c13bdee1b526 (bug 1700623)
Backed out changeset 26df421dac02 (bug 1700623)
Backed out changeset 6cd0b7a269e5 (bug 1700623)
  • Loading branch information
Alexandru Michis committed May 21, 2021
1 parent 858677d commit a918aa0
Show file tree
Hide file tree
Showing 39 changed files with 438 additions and 738 deletions.
1 change: 0 additions & 1 deletion browser/components/sessionstore/test/browser_broadcast.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ add_task(async function flush_on_tabclose() {
let browser = tab.linkedBrowser;

await modifySessionStorage(browser, { test: "on-tab-close" });
await TabStateFlusher.flush(browser);
await promiseRemoveTabAndSessionState(tab);

let [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ add_task(async function session_storage() {
await modifySessionStorage(browser, {});
await TabStateFlusher.flush(browser);
({ storage } = JSON.parse(ss.getTabState(tab)));
ok(
storage === null || storage === undefined,
is(
storage,
null,
"sessionStorage data for the entire tab has been cleared correctly"
);

Expand Down Expand Up @@ -204,7 +205,6 @@ add_task(async function purge_domain() {
add_task(async function respect_privacy_level() {
let tab = BrowserTestUtils.addTab(gBrowser, URL + "&secure");
await promiseBrowserLoaded(tab.linkedBrowser);
await TabStateFlusher.flush(tab.linkedBrowser);
await promiseRemoveTabAndSessionState(tab);

let [
Expand All @@ -228,7 +228,6 @@ add_task(async function respect_privacy_level() {

tab = BrowserTestUtils.addTab(gBrowser, URL + "&secure");
await promiseBrowserLoaded(tab.linkedBrowser);
await TabStateFlusher.flush(tab.linkedBrowser);
await promiseRemoveTabAndSessionState(tab);

[
Expand Down
6 changes: 0 additions & 6 deletions caps/OriginAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ class OriginAttributes : public dom::OriginAttributesDictionary {
mGeckoViewSessionContextId == aOther.mGeckoViewSessionContextId;
}

[[nodiscard]] bool EqualsIgnoringPartitionKey(
const OriginAttributes& aOther) const {
return EqualsIgnoringFPD(aOther) &&
mFirstPartyDomain == aOther.mFirstPartyDomain;
}

// Serializes/Deserializes non-default values into the suffix format, i.e.
// |!key1=value1&key2=value2|. If there are no non-default attributes, this
// returns an empty string.
Expand Down
8 changes: 0 additions & 8 deletions docshell/base/BrowsingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3025,14 +3025,6 @@ void BrowsingContext::DidSet(FieldIndex<IDX_CurrentInnerWindowId>) {
prevWindowContext->Canonical()->DidBecomeCurrentWindowGlobal(false);
}
if (mCurrentWindowContext) {
// We set a timer when we set the current inner window. This
// will then flush the session storage to session store to
// make sure that we don't miss to store session storage to
// session store that is a result of navigation. This is due
// to Bug 1700623. We wish to fix this in Bug 1711886, where
// making sure to store everything would make this timer
// unnecessary.
Canonical()->MaybeScheduleSessionStoreUpdate();
mCurrentWindowContext->Canonical()->DidBecomeCurrentWindowGlobal(true);
}
}
Expand Down
122 changes: 1 addition & 121 deletions docshell/base/CanonicalBrowsingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "mozilla/dom/BrowsingContextGroup.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/EventTarget.h"
#include "mozilla/dom/PBackgroundSessionStorageCache.h"
#include "mozilla/dom/PWindowGlobalParent.h"
#include "mozilla/dom/WindowGlobalParent.h"
#include "mozilla/dom/ContentProcessManager.h"
Expand Down Expand Up @@ -43,9 +42,6 @@
#include "nsBrowserStatusFilter.h"
#include "nsIBrowser.h"
#include "nsTHashSet.h"
#include "SessionStoreFunctions.h"
#include "nsIXPConnect.h"
#include "nsImportModule.h"

#ifdef NS_PRINTING
# include "mozilla/embedding/printingui/PrintingParent.h"
Expand Down Expand Up @@ -1026,8 +1022,6 @@ void CanonicalBrowsingContext::CanonicalDiscard() {
if (IsTop()) {
BackgroundSessionStorageManager::RemoveManager(Id());
}

CancelSessionStoreUpdate();
}

void CanonicalBrowsingContext::NotifyStartDelayedAutoplayMedia() {
Expand Down Expand Up @@ -2032,119 +2026,6 @@ void CanonicalBrowsingContext::RestoreState::Resolve() {
mPromise = nullptr;
}

nsresult CanonicalBrowsingContext::WriteSessionStorageToSessionStore(
const nsTArray<SSCacheCopy>& aSesssionStorage, uint32_t aEpoch) {
RefPtr<WindowGlobalParent> windowParent = GetCurrentWindowGlobal();

if (!windowParent) {
return NS_OK;
}

Element* frameElement = windowParent->GetRootOwnerElement();
if (!frameElement) {
return NS_OK;
}

nsCOMPtr<nsISessionStoreFunctions> funcs =
do_ImportModule("resource://gre/modules/SessionStoreFunctions.jsm");
if (!funcs) {
return NS_ERROR_FAILURE;
}

nsCOMPtr<nsIXPConnectWrappedJS> wrapped = do_QueryInterface(funcs);
AutoJSAPI jsapi;
if (!jsapi.Init(wrapped->GetJSObjectGlobal())) {
return NS_ERROR_FAILURE;
}

Record<nsCString, Record<nsString, nsString>> storage;
JS::RootedValue update(jsapi.cx());

if (!aSesssionStorage.IsEmpty()) {
SessionStoreUtils::ConstructSessionStorageValues(this, aSesssionStorage,
storage);
if (!ToJSValue(jsapi.cx(), storage, &update)) {
return NS_ERROR_FAILURE;
}
} else {
update.setNull();
}

return funcs->UpdateSessionStoreForStorage(frameElement, this, aEpoch,
update);
}

void CanonicalBrowsingContext::UpdateSessionStoreSessionStorage(
const std::function<void()>& aDone) {
using DataPromise = BackgroundSessionStorageManager::DataPromise;
BackgroundSessionStorageManager::GetData(
this, StaticPrefs::browser_sessionstore_dom_storage_limit(),
/* aCancelSessionStoreTiemr = */ true)
->Then(GetCurrentSerialEventTarget(), __func__,
[self = RefPtr{this}, aDone, epoch = GetSessionStoreEpoch()](
const DataPromise::ResolveOrRejectValue& valueList) {
if (valueList.IsResolve()) {
self->WriteSessionStorageToSessionStore(
valueList.ResolveValue(), epoch);
}
aDone();
});
}

/* static */
void CanonicalBrowsingContext::UpdateSessionStoreForStorage(
uint64_t aBrowsingContextId) {
RefPtr<CanonicalBrowsingContext> browsingContext = Get(aBrowsingContextId);

if (!browsingContext) {
return;
}

browsingContext->UpdateSessionStoreSessionStorage([]() {});
}

void CanonicalBrowsingContext::MaybeScheduleSessionStoreUpdate() {
if (!IsTop()) {
Top()->MaybeScheduleSessionStoreUpdate();
return;
}

if (IsInBFCache()) {
return;
}

if (mSessionStoreSessionStorageUpdateTimer) {
return;
}

if (StaticPrefs::browser_sessionstore_debug_no_auto_updates()) {
UpdateSessionStoreSessionStorage([]() {});
return;
}

auto result = NS_NewTimerWithFuncCallback(
[](nsITimer*, void* aClosure) {
auto* context = static_cast<CanonicalBrowsingContext*>(aClosure);
context->UpdateSessionStoreSessionStorage([]() {});
},
this, StaticPrefs::browser_sessionstore_interval(),
nsITimer::TYPE_ONE_SHOT,
"CanonicalBrowsingContext::MaybeScheduleSessionStoreUpdate");

if (result.isErr()) {
return;
}

mSessionStoreSessionStorageUpdateTimer = result.unwrap();
}

void CanonicalBrowsingContext::CancelSessionStoreUpdate() {
if (mSessionStoreSessionStorageUpdateTimer) {
mSessionStoreSessionStorageUpdateTimer->Cancel();
mSessionStoreSessionStorageUpdateTimer = nullptr;
}
}

void CanonicalBrowsingContext::SetContainerFeaturePolicy(
FeaturePolicy* aContainerFeaturePolicy) {
mContainerFeaturePolicy = aContainerFeaturePolicy;
Expand Down Expand Up @@ -2350,8 +2231,7 @@ bool CanonicalBrowsingContext::AllowedInBFCache(

NS_IMPL_CYCLE_COLLECTION_INHERITED(CanonicalBrowsingContext, BrowsingContext,
mSessionHistory, mContainerFeaturePolicy,
mCurrentBrowserParent,
mSessionStoreSessionStorageUpdateTimer)
mCurrentBrowserParent)

NS_IMPL_ADDREF_INHERITED(CanonicalBrowsingContext, BrowsingContext)
NS_IMPL_RELEASE_INHERITED(CanonicalBrowsingContext, BrowsingContext)
Expand Down
15 changes: 0 additions & 15 deletions docshell/base/CanonicalBrowsingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class nsSHistory;
class nsBrowserStatusFilter;
class nsSecureBrowserUI;
class CallerWillNotifyHistoryIndexAndLengthChanges;
class nsITimer;

namespace mozilla {
enum class CallState;
Expand All @@ -48,7 +47,6 @@ struct LoadURIOptions;
class MediaController;
struct LoadingSessionHistoryInfo;
class SessionHistoryEntry;
class SSCacheCopy;
class WindowGlobalParent;

// RemotenessChangeOptions is passed through the methods to store the state
Expand Down Expand Up @@ -294,13 +292,6 @@ class CanonicalBrowsingContext final : public BrowsingContext {
void RequestRestoreTabContent(WindowGlobalParent* aWindow);
already_AddRefed<Promise> GetRestorePromise();

nsresult WriteSessionStorageToSessionStore(
const nsTArray<SSCacheCopy>& aSesssionStorage, uint32_t aEpoch);

void UpdateSessionStoreSessionStorage(const std::function<void()>& aDone);

static void UpdateSessionStoreForStorage(uint64_t aBrowsingContextId);

// Called when a BrowserParent for this BrowsingContext has been fully
// destroyed (i.e. `ActorDestroy` was called).
void BrowserParentDestroyed(BrowserParent* aBrowserParent,
Expand Down Expand Up @@ -414,10 +405,6 @@ class CanonicalBrowsingContext final : public BrowsingContext {
// has become unloaded for one reason or another.
void ShowSubframeCrashedUI(BrowserBridgeParent* aBridge);

void MaybeScheduleSessionStoreUpdate();

void CancelSessionStoreUpdate();

// XXX(farre): Store a ContentParent pointer here rather than mProcessId?
// Indicates which process owns the docshell.
uint64_t mProcessId;
Expand Down Expand Up @@ -471,8 +458,6 @@ class CanonicalBrowsingContext final : public BrowsingContext {
// If this is a top level context, this is true if our browser ID is marked as
// active in the process priority manager.
bool mPriorityActive = false;

nsCOMPtr<nsITimer> mSessionStoreSessionStorageUpdateTimer;
};

} // namespace dom
Expand Down
54 changes: 31 additions & 23 deletions dom/base/nsFrameLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,6 @@
#include "mozilla/dom/BrowserBridgeHost.h"
#include "mozilla/dom/BrowsingContextGroup.h"

#include "mozilla/dom/SessionStorageManager.h"
#include "mozilla/ipc/BackgroundChild.h"
#include "mozilla/ipc/PBackgroundChild.h"
#include "mozilla/dom/PBackgroundSessionStorageCache.h"
#include "mozilla/ipc/BackgroundUtils.h"

#include "mozilla/dom/HTMLBodyElement.h"

#include "mozilla/ContentPrincipal.h"
Expand All @@ -140,7 +134,6 @@ using namespace mozilla;
using namespace mozilla::hal;
using namespace mozilla::dom;
using namespace mozilla::dom::ipc;
using namespace mozilla::ipc;
using namespace mozilla::layers;
using namespace mozilla::layout;
typedef ScrollableLayerGuid::ViewID ViewID;
Expand Down Expand Up @@ -3196,28 +3189,42 @@ already_AddRefed<Promise> nsFrameLoader::RequestTabStateFlush(
if (mSessionStoreListener) {
context->FlushSessionStore();
mSessionStoreListener->ForceFlushFromParent(false);
context->Canonical()->UpdateSessionStoreSessionStorage(
[promise]() { promise->MaybeResolveWithUndefined(); });

// No async ipc call is involved in parent only case
promise->MaybeResolveWithUndefined();
return promise.forget();
}

// XXX(farre): We hack around not having fully implemented session
// store session storage collection in the parent. What we need to
// do is to make sure that we always flush the toplevel context
// first. And also to wait for that flush to resolve. This will be
// fixed by moving session storage collection to the parent, which
// will happen in Bug 1700623.
RefPtr<ContentParent> contentParent =
context->Canonical()->GetContentParent();
using FlushPromise = ContentParent::FlushTabStatePromise;
nsTArray<RefPtr<FlushPromise>> flushPromises;
context->Group()->EachParent([&](ContentParent* aParent) {
if (aParent->CanSend()) {
flushPromises.AppendElement(aParent->SendFlushTabState(context));
}
});
contentParent->SendFlushTabState(context)->Then(
GetCurrentSerialEventTarget(), __func__,
[promise, context,
contentParent](const FlushPromise::ResolveOrRejectValue&) {
nsTArray<RefPtr<FlushPromise>> flushPromises;
context->Group()->EachOtherParent(
contentParent, [&](ContentParent* aParent) {
if (aParent->CanSend()) {
flushPromises.AppendElement(
aParent->SendFlushTabState(context));
}
});

RefPtr<FlushPromise::AllPromiseType> flushPromise =
FlushPromise::All(GetCurrentSerialEventTarget(), flushPromises);

context->Canonical()->UpdateSessionStoreSessionStorage([flushPromise,
promise]() {
flushPromise->Then(GetCurrentSerialEventTarget(), __func__,
[promise]() { promise->MaybeResolveWithUndefined(); });
});
FlushPromise::All(GetCurrentSerialEventTarget(), flushPromises)
->Then(
GetCurrentSerialEventTarget(), __func__,
[promise](
const FlushPromise::AllPromiseType::ResolveOrRejectValue&) {
promise->MaybeResolveWithUndefined();
});
});

return promise.forget();
}
Expand All @@ -3234,6 +3241,7 @@ void nsFrameLoader::RequestTabStateFlush() {
// No async ipc call is involved in parent only case
return;
}

context->Group()->EachParent([&](ContentParent* aParent) {
if (aParent->CanSend()) {
aParent->SendFlushTabState(
Expand Down
8 changes: 0 additions & 8 deletions dom/base/nsGlobalWindowInner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7570,14 +7570,6 @@ void nsGlobalWindowInner::StorageAccessPermissionGranted() {
// Reset the active storage principal
if (mDoc) {
mDoc->ClearActiveStoragePrincipal();
if (mWindowGlobalChild) {
// XXX(farre): This is a bit backwards, but clearing the storage
// principal might make us end up with a new effective storage
// principal on the child side than on the parent side, which
// means that we need to sync it. See bug 1705359.
mWindowGlobalChild->SetDocumentPrincipal(
mDoc->NodePrincipal(), mDoc->EffectiveStoragePrincipal());
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion dom/base/test/file_messagemanager_unload.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html>
<body>
<iframe id="frame" src="empty.html"></iframe>
<iframe id="frame" src="about:robots"></iframe>
</body>
</html>
Loading

0 comments on commit a918aa0

Please sign in to comment.