Skip to content

Commit

Permalink
Cherry-pick 259548.773@safari-7615-branch (3d72c32). https://bugs.web…
Browse files Browse the repository at this point in the history
…kit.org/show_bug.cgi?id=257161

    Follow-up to 259548.752@safari-7615-branch to cancel navigations instead of blocking them
    https://bugs.webkit.org/show_bug.cgi?id=257161
    rdar://108794051

    Reviewed by Alex Christensen.

    259548.752@safari-7615-branch added further restrictions to prevent top-frame navigations
    by third-party iframes, in particular using redirects. I had decided to block the redirect
    with a blockedError(). However, it turns out that Safari shows an error page when doing
    so, which results in a bad user experience since the top frame is still being navigated
    (to an error page).

    To address the issue, I am now cancelling the redirect instead and returning a
    cancelledError(). I have verified that Safari doesn't show an error page in this case and
    that the top frame is not getting navigated.

    * Source/WebCore/loader/DocumentLoader.cpp:
    (WebCore::DocumentLoader::willSendRequest):

    Canonical link: https://commits.webkit.org/259548.773@safari-7615-branch
  • Loading branch information
cdumez authored and mcatanzaro committed Jul 28, 2023
1 parent b0f4f94 commit ec83f75
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Source/WebCore/loader/DocumentLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ void DocumentLoader::willSendRequest(ResourceRequest&& newRequest, const Resourc
, "'. The frame attempting navigation of the top-level window is cross-origin or untrusted and the user has never interacted with the frame.");
m_frame->document()->addConsoleMessage(MessageSource::Security, MessageLevel::Error, message);
}
cancelMainResourceLoad(frameLoader()->blockedError(newRequest));
cancelMainResourceLoad(frameLoader()->cancelledError(newRequest));
return completionHandler(WTFMove(newRequest));
}
}
Expand Down

0 comments on commit ec83f75

Please sign in to comment.