Created attachment 429863 [details] reproducing steps # Reproducible environment - Safari and Webview on iOS 14.5 - Safari 14.1 on Mac 10.15 # Reproducing steps Please see the attached video, too. 1. Access to SiteA located in "https://siteA.com/" 2. In SiteA, run JS code like this immediately: ``` <script type="text/javascript"> location.href="https://siteB.com/" // SiteB </script> ``` This page of SiteA won’t be recorded in the browser’s history since this "location.href" is called without user interactions. https://html.spec.whatwg.org/multipage/history.html#location-object-setter-navigate 3. After arriving at SiteB, click browser's history back button to go back to SiteA 4. I expected to see the page before SiteA, but the issue below occurs # Issue Even though the browser's URL bar shows SiteA's URL, but I can't see SiteA contents because: - The browser shows a blank screen instead (iOS) - Or, the browser keeps and shows previous page's contents of SiteA (Mac) ## Note - When SiteA and SiteB are on a same domain, this issue isn't reproduced. - Sometimes the issue won't occur anymore after accessing SiteA multiple times. In that case, once clear the browser cache, you can reproduce it again. # Reproducible page page: https://redirect-issue.web.app code: https://github.com/cola119/safari-redirect-issue
Thank you for the report! > - Safari and Webview on iOS 14.5 > - Safari 14.1 on Mac 10.15 Could you please confirm if these are the first versions where this happens, and earlier ones worked as expected?
(In reply to Alexey Proskuryakov from comment #1) > Could you please confirm if these are the first versions where this happens, > and earlier ones worked as expected? Thank you for your reply. Regarding iOS, we confirmed that we couldn't reproduce the issue in iOS 14.4 and earlier. Regarding Mac, we don't have many environments, so we could check only on Safari 14.1 in Mac 10.15.
Thank you, this is what we need to know about regression story. I should have asked right away about customer impact. Does this affect specific existing websites and/or apps? How bad is the impact?
<rdar://problem/78623536>
This worked before r269170 which caused the web process to crash when pushing the back button. When that crash was fixed in r270789 it no longer showed the previous page when pushing the back button.
Created attachment 430056 [details] Patch
(In reply to Alexey Proskuryakov from comment #3) Thank you for your confirmation! > I should have asked right away about customer impact. Does this affect specific existing websites and/or apps? How bad is the impact? We offer the platform to our customers and this issue affects to one feature of it. We have a redirector which was made with "location.href" and can pass path/query/fragment from original access. It means: Click the link to SiteA (a redirector) with path/query/fragment -> Site A redirect to Site B (different domain) with the passed path/query/fragment -> Land at Site B with the passed path/query/fragment In the way of redirecting with HTTP status code 301/302, we can't pass fragment to the final destination since server side can't recognize fragment in URL. Therefore we use "location.href" since JS can recognize it.
Created attachment 430266 [details] Patch
Committed r278318 (238354@main): <https://commits.webkit.org/238354@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 430266 [details].