Commit d4821d12 authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios] Stop using the popstate event as speculative WebKit crash workaround.

Moving from the popstate event to a zero second setInterval shortens
session restoration by a few milliseconds, and perhaps works around the
iOS12.2+ crash.

Bug: 959499
Change-Id: Ic67a3cb146a9b3525efb6baa9dafae8e6bbf4ee1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1602873Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarAli Juma <ajuma@chromium.org>
Reviewed-by: default avatarDanyao Wang <danyao@chromium.org>
Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658282}
parent 04f3fcde
......@@ -46,15 +46,6 @@
}
};
/**
* The window.onpopstate event fires when the user navigates to one of the
* history entries created by restoreSession(). This handler forces a reload
* to reidrect to the target URL.
*/
window.onpopstate = function(event) {
location.reload();
}
/**
* Manipulates the current session history to mimic the provided serialized
* history.
......@@ -107,6 +98,12 @@
if (history.length == sessionHistoryObject.urls.length) {
history.go(currentItemOffset);
window.clearInterval(goWhenReady);
// Queue a reload to redirect to the target URL after history.go
// is processed.
setTimeout(() => {
location.reload();
});
}
}, 10);
} catch (e) {
......
......@@ -2559,15 +2559,6 @@ TEST_P(WebStateObserverTest, RestoreSessionOnline) {
/*for_main_frame=*/true))
.WillOnce(Return(true));
// decide policy for restore_session.html?targetUrl=url0 again due to reload
// in onpopstate().
EXPECT_CALL(*decider_,
ShouldAllowRequest(URLMatch(CreateRedirectUrl(url0)), _))
.WillOnce(Return(true));
EXPECT_CALL(*decider_, ShouldAllowResponse(URLMatch(CreateRedirectUrl(url0)),
/*for_main_frame=*/true))
.WillOnce(Return(true));
// Client-side redirect to |url0|.
EXPECT_CALL(*decider_, ShouldAllowRequest(URLMatch(url0), _))
.WillOnce(Return(true));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment