forked from mirrors/gecko-dev
Bug 1677190 - Use shared code for updating the session state on Android when SHIP is enabled. r=geckoview-reviewers,sessionstore-reviewers,farre,owlish
Differential Revision: https://phabricator.services.mozilla.com/D210757
This commit is contained in:
parent
0f44717f92
commit
67a6fa45ec
9 changed files with 6 additions and 163 deletions
|
|
@ -250,11 +250,6 @@ class HistoryDelegateTest : BaseSessionTest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun onHistoryStateChangeSavingState() {
|
@Test fun onHistoryStateChangeSavingState() {
|
||||||
// TODO: Bug 1884334
|
|
||||||
val geckoPrefs = sessionRule.getPrefs(
|
|
||||||
"fission.disableSessionHistoryInParent",
|
|
||||||
)
|
|
||||||
assumeThat(geckoPrefs[0] as Boolean, equalTo(true))
|
|
||||||
// TODO: Bug 1837551
|
// TODO: Bug 1837551
|
||||||
assumeThat(sessionRule.env.isFission, equalTo(false))
|
assumeThat(sessionRule.env.isFission, equalTo(false))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3163,11 +3163,6 @@ class NavigationDelegateTest : BaseSessionTest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun goBackFromHistory() {
|
@Test fun goBackFromHistory() {
|
||||||
// TODO: Bug 1884334
|
|
||||||
val geckoPrefs = sessionRule.getPrefs(
|
|
||||||
"fission.disableSessionHistoryInParent",
|
|
||||||
)
|
|
||||||
assumeThat(geckoPrefs[0] as Boolean, equalTo(true))
|
|
||||||
// TODO: Bug 1837551
|
// TODO: Bug 1837551
|
||||||
assumeThat(sessionRule.env.isFission, equalTo(false))
|
assumeThat(sessionRule.env.isFission, equalTo(false))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -448,11 +448,6 @@ class ProgressDelegateTest : BaseSessionTest() {
|
||||||
@WithDisplay(width = 400, height = 400)
|
@WithDisplay(width = 400, height = 400)
|
||||||
@Test
|
@Test
|
||||||
fun saveAndRestoreStateNewSession() {
|
fun saveAndRestoreStateNewSession() {
|
||||||
// TODO: Bug 1884334
|
|
||||||
val geckoPrefs = sessionRule.getPrefs(
|
|
||||||
"fission.disableSessionHistoryInParent",
|
|
||||||
)
|
|
||||||
assumeThat(geckoPrefs[0] as Boolean, equalTo(true))
|
|
||||||
// TODO: Bug 1837551
|
// TODO: Bug 1837551
|
||||||
assumeThat(sessionRule.env.isFission, equalTo(false))
|
assumeThat(sessionRule.env.isFission, equalTo(false))
|
||||||
val helloUri = createTestUrl(HELLO_HTML_PATH)
|
val helloUri = createTestUrl(HELLO_HTML_PATH)
|
||||||
|
|
@ -579,11 +574,6 @@ class ProgressDelegateTest : BaseSessionTest() {
|
||||||
@NullDelegate(GeckoSession.HistoryDelegate::class)
|
@NullDelegate(GeckoSession.HistoryDelegate::class)
|
||||||
@Test
|
@Test
|
||||||
fun noHistoryDelegateOnSessionStateChange() {
|
fun noHistoryDelegateOnSessionStateChange() {
|
||||||
// TODO: Bug 1884334
|
|
||||||
val geckoPrefs = sessionRule.getPrefs(
|
|
||||||
"fission.disableSessionHistoryInParent",
|
|
||||||
)
|
|
||||||
assumeThat(geckoPrefs[0] as Boolean, equalTo(true))
|
|
||||||
// TODO: Bug 1837551
|
// TODO: Bug 1837551
|
||||||
assumeThat(sessionRule.env.isFission, equalTo(false))
|
assumeThat(sessionRule.env.isFission, equalTo(false))
|
||||||
mainSession.loadTestPath(HELLO_HTML_PATH)
|
mainSession.loadTestPath(HELLO_HTML_PATH)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ package org.mozilla.geckoview.test
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import androidx.test.filters.MediumTest
|
import androidx.test.filters.MediumTest
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.hamcrest.Matchers
|
|
||||||
import org.hamcrest.Matchers.greaterThan
|
import org.hamcrest.Matchers.greaterThan
|
||||||
import org.hamcrest.core.IsEqual.equalTo
|
import org.hamcrest.core.IsEqual.equalTo
|
||||||
import org.hamcrest.core.StringEndsWith.endsWith
|
import org.hamcrest.core.StringEndsWith.endsWith
|
||||||
|
|
@ -2170,11 +2169,6 @@ class WebExtensionTest : BaseSessionTest() {
|
||||||
// - verifies that the messages are received when restoring the tab in a fresh session
|
// - verifies that the messages are received when restoring the tab in a fresh session
|
||||||
@Test
|
@Test
|
||||||
fun testRestoringExtensionPagePreservesMessages() {
|
fun testRestoringExtensionPagePreservesMessages() {
|
||||||
// TODO: Bug 1884334
|
|
||||||
val geckoPrefs = sessionRule.getPrefs(
|
|
||||||
"fission.disableSessionHistoryInParent",
|
|
||||||
)
|
|
||||||
assumeThat(geckoPrefs[0] as Boolean, Matchers.equalTo(true))
|
|
||||||
// TODO: Bug 1837551
|
// TODO: Bug 1837551
|
||||||
assumeThat(sessionRule.env.isFission, equalTo(false))
|
assumeThat(sessionRule.env.isFission, equalTo(false))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1598,36 +1598,6 @@ public class GeckoSession {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@WrapForJNI(calledFrom = "gecko")
|
|
||||||
private void onUpdateSessionStore(final GeckoBundle aBundle) {
|
|
||||||
ThreadUtils.runOnUiThread(
|
|
||||||
() -> {
|
|
||||||
final GeckoSession session = mOwner.get();
|
|
||||||
if (session == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
GeckoBundle scroll = aBundle.getBundle("scroll");
|
|
||||||
if (scroll == null) {
|
|
||||||
scroll = new GeckoBundle();
|
|
||||||
aBundle.putBundle("scroll", scroll);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Here we unfortunately need to do some re-mapping since `zoom` is passed in a separate
|
|
||||||
// bunds and we wish to keep the bundle format.
|
|
||||||
scroll.putBundle("zoom", aBundle.getBundle("zoom"));
|
|
||||||
final SessionState stateCache = session.mStateCache;
|
|
||||||
stateCache.updateSessionState(aBundle);
|
|
||||||
final SessionState state = new SessionState(stateCache);
|
|
||||||
if (!state.isEmpty()) {
|
|
||||||
final ProgressDelegate progressDelegate = session.getProgressDelegate();
|
|
||||||
if (progressDelegate != null) {
|
|
||||||
progressDelegate.onSessionStateChange(session, state);
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Listener implements BundleEventListener {
|
private class Listener implements BundleEventListener {
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,6 @@
|
||||||
#include "nsImportModule.h"
|
#include "nsImportModule.h"
|
||||||
#include "nsIXPConnect.h"
|
#include "nsIXPConnect.h"
|
||||||
|
|
||||||
#ifdef ANDROID
|
|
||||||
# include "mozilla/widget/nsWindow.h"
|
|
||||||
# include "mozilla/jni/GeckoBundleUtils.h"
|
|
||||||
# include "JavaBuiltins.h"
|
|
||||||
#endif /* ANDROID */
|
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
|
|
||||||
|
|
@ -39,75 +33,6 @@ SessionStoreParent::SessionStoreParent(
|
||||||
BrowserSessionStore* aSessionStore)
|
BrowserSessionStore* aSessionStore)
|
||||||
: mBrowsingContext(aBrowsingContext), mSessionStore(aSessionStore) {}
|
: mBrowsingContext(aBrowsingContext), mSessionStore(aSessionStore) {}
|
||||||
|
|
||||||
#ifdef ANDROID
|
|
||||||
static void DoSessionStoreUpdate(CanonicalBrowsingContext* aBrowsingContext,
|
|
||||||
const Maybe<nsCString>& aDocShellCaps,
|
|
||||||
const Maybe<bool>& aPrivatedMode,
|
|
||||||
SessionStoreFormData* aFormData,
|
|
||||||
SessionStoreScrollData* aScroll,
|
|
||||||
const MaybeSessionStoreZoom& aZoom,
|
|
||||||
bool aNeedCollectSHistory, uint32_t aEpoch) {
|
|
||||||
RefPtr<BrowserSessionStore> sessionStore =
|
|
||||||
BrowserSessionStore::GetOrCreate(aBrowsingContext->Top());
|
|
||||||
|
|
||||||
nsCOMPtr<nsIWidget> widget =
|
|
||||||
aBrowsingContext->GetParentProcessWidgetContaining();
|
|
||||||
if (RefPtr<nsWindow> window = nsWindow::From(widget)) {
|
|
||||||
AutoJSAPI jsapi;
|
|
||||||
if (!jsapi.Init(xpc::PrivilegedJunkScope())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
jni::Object::LocalRef formDataBundle(jni::GetGeckoThreadEnv());
|
|
||||||
jni::Object::LocalRef scrollBundle(jni::GetGeckoThreadEnv());
|
|
||||||
|
|
||||||
if (aFormData) {
|
|
||||||
JS::Rooted<JSObject*> object(jsapi.cx());
|
|
||||||
ErrorResult rv;
|
|
||||||
aFormData->ToJSON(jsapi.cx(), &object);
|
|
||||||
|
|
||||||
JS::Rooted<JS::Value> value(jsapi.cx(), JS::ObjectValue(*object));
|
|
||||||
|
|
||||||
if (NS_FAILED(jni::BoxData(jsapi.cx(), value, formDataBundle, true))) {
|
|
||||||
JS_ClearPendingException(jsapi.cx());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aScroll) {
|
|
||||||
JS::Rooted<JSObject*> object(jsapi.cx());
|
|
||||||
ErrorResult rv;
|
|
||||||
aScroll->ToJSON(jsapi.cx(), &object);
|
|
||||||
JS::Rooted<JS::Value> value(jsapi.cx(), JS::ObjectValue(*object));
|
|
||||||
|
|
||||||
if (NS_FAILED(jni::BoxData(jsapi.cx(), value, scrollBundle, true))) {
|
|
||||||
JS_ClearPendingException(jsapi.cx());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GECKOBUNDLE_START(update);
|
|
||||||
GECKOBUNDLE_PUT(update, "formdata", formDataBundle);
|
|
||||||
GECKOBUNDLE_PUT(update, "scroll", scrollBundle);
|
|
||||||
if (aZoom) {
|
|
||||||
GECKOBUNDLE_START(zoomBundle);
|
|
||||||
GECKOBUNDLE_PUT(zoomBundle, "resolution",
|
|
||||||
java::sdk::Double::New(std::get<0>(*aZoom)));
|
|
||||||
GECKOBUNDLE_START(displaySizeBundle);
|
|
||||||
GECKOBUNDLE_PUT(displaySizeBundle, "width",
|
|
||||||
java::sdk::Integer::ValueOf(std::get<1>(*aZoom)));
|
|
||||||
GECKOBUNDLE_PUT(displaySizeBundle, "height",
|
|
||||||
java::sdk::Integer::ValueOf(std::get<2>(*aZoom)));
|
|
||||||
GECKOBUNDLE_FINISH(displaySizeBundle);
|
|
||||||
GECKOBUNDLE_PUT(zoomBundle, "displaySize", displaySizeBundle);
|
|
||||||
GECKOBUNDLE_FINISH(zoomBundle);
|
|
||||||
GECKOBUNDLE_PUT(update, "zoom", zoomBundle);
|
|
||||||
}
|
|
||||||
GECKOBUNDLE_FINISH(update);
|
|
||||||
|
|
||||||
window->OnUpdateSessionStore(update);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
static void DoSessionStoreUpdate(CanonicalBrowsingContext* aBrowsingContext,
|
static void DoSessionStoreUpdate(CanonicalBrowsingContext* aBrowsingContext,
|
||||||
const Maybe<nsCString>& aDocShellCaps,
|
const Maybe<nsCString>& aDocShellCaps,
|
||||||
const Maybe<bool>& aPrivatedMode,
|
const Maybe<bool>& aPrivatedMode,
|
||||||
|
|
@ -174,7 +99,6 @@ static void DoSessionStoreUpdate(CanonicalBrowsingContext* aBrowsingContext,
|
||||||
Unused << sessionStoreFuncs->UpdateSessionStore(
|
Unused << sessionStoreFuncs->UpdateSessionStore(
|
||||||
nullptr, aBrowsingContext, key, aEpoch, aNeedCollectSHistory, update);
|
nullptr, aBrowsingContext, key, aEpoch, aNeedCollectSHistory, update);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void SessionStoreParent::FlushAllSessionStoreChildren(
|
void SessionStoreParent::FlushAllSessionStoreChildren(
|
||||||
const std::function<void()>& aDone) {
|
const std::function<void()>& aDone) {
|
||||||
|
|
|
||||||
|
|
@ -89,13 +89,11 @@ class GeckoViewSupport final
|
||||||
|
|
||||||
auto OnLoadRequest(mozilla::jni::String::Param aUri, int32_t aWindowType,
|
auto OnLoadRequest(mozilla::jni::String::Param aUri, int32_t aWindowType,
|
||||||
int32_t aFlags, mozilla::jni::String::Param aTriggeringUri,
|
int32_t aFlags, mozilla::jni::String::Param aTriggeringUri,
|
||||||
bool aHasUserGesture, bool aIsTopLevel) const
|
bool aHasUserGesture,
|
||||||
-> java::GeckoResult::LocalRef;
|
bool aIsTopLevel) const -> java::GeckoResult::LocalRef;
|
||||||
|
|
||||||
void OnShowDynamicToolbar() const;
|
void OnShowDynamicToolbar() const;
|
||||||
|
|
||||||
void OnUpdateSessionStore(mozilla::jni::Object::Param aBundle);
|
|
||||||
|
|
||||||
void PassExternalResponse(java::WebResponse::Param aResponse);
|
void PassExternalResponse(java::WebResponse::Param aResponse);
|
||||||
|
|
||||||
void AttachMediaSessionController(
|
void AttachMediaSessionController(
|
||||||
|
|
|
||||||
|
|
@ -1894,12 +1894,10 @@ void GeckoViewSupport::AttachAccessibility(
|
||||||
sessionAccessibility);
|
sessionAccessibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto GeckoViewSupport::OnLoadRequest(mozilla::jni::String::Param aUri,
|
auto GeckoViewSupport::OnLoadRequest(
|
||||||
int32_t aWindowType, int32_t aFlags,
|
mozilla::jni::String::Param aUri, int32_t aWindowType, int32_t aFlags,
|
||||||
mozilla::jni::String::Param aTriggeringUri,
|
mozilla::jni::String::Param aTriggeringUri, bool aHasUserGesture,
|
||||||
bool aHasUserGesture,
|
bool aIsTopLevel) const -> java::GeckoResult::LocalRef {
|
||||||
bool aIsTopLevel) const
|
|
||||||
-> java::GeckoResult::LocalRef {
|
|
||||||
GeckoSession::Window::LocalRef window(mGeckoViewWindow);
|
GeckoSession::Window::LocalRef window(mGeckoViewWindow);
|
||||||
if (!window) {
|
if (!window) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -2317,15 +2315,6 @@ RefPtr<MozPromise<bool, bool, false>> nsWindow::OnLoadRequest(
|
||||||
: nullptr;
|
: nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsWindow::OnUpdateSessionStore(mozilla::jni::Object::Param aBundle) {
|
|
||||||
auto geckoViewSupport(mGeckoViewSupport.Access());
|
|
||||||
if (!geckoViewSupport) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
geckoViewSupport->OnUpdateSessionStore(aBundle);
|
|
||||||
}
|
|
||||||
|
|
||||||
float nsWindow::GetDPI() {
|
float nsWindow::GetDPI() {
|
||||||
float dpi = 160.0f;
|
float dpi = 160.0f;
|
||||||
|
|
||||||
|
|
@ -2657,16 +2646,6 @@ void nsWindow::ShowDynamicToolbar() {
|
||||||
acc->OnShowDynamicToolbar();
|
acc->OnShowDynamicToolbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeckoViewSupport::OnUpdateSessionStore(
|
|
||||||
mozilla::jni::Object::Param aBundle) {
|
|
||||||
GeckoSession::Window::LocalRef window(mGeckoViewWindow);
|
|
||||||
if (!window) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
window->OnUpdateSessionStore(aBundle);
|
|
||||||
}
|
|
||||||
|
|
||||||
static EventMessage convertDragEventActionToGeckoEvent(int32_t aAction) {
|
static EventMessage convertDragEventActionToGeckoEvent(int32_t aAction) {
|
||||||
switch (aAction) {
|
switch (aAction) {
|
||||||
case java::sdk::DragEvent::ACTION_DRAG_ENTERED:
|
case java::sdk::DragEvent::ACTION_DRAG_ENTERED:
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,6 @@ class nsWindow final : public nsBaseWidget {
|
||||||
nsIPrincipal* aTriggeringPrincipal, bool aHasUserGesture,
|
nsIPrincipal* aTriggeringPrincipal, bool aHasUserGesture,
|
||||||
bool aIsTopLevel);
|
bool aIsTopLevel);
|
||||||
|
|
||||||
void OnUpdateSessionStore(mozilla::jni::Object::Param aBundle);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Unique ID given to each widget, used to map Surfaces to widgets
|
// Unique ID given to each widget, used to map Surfaces to widgets
|
||||||
// in the CompositorSurfaceManager.
|
// in the CompositorSurfaceManager.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue