Changeset 67716 in webkit


Ignore:
Timestamp:
Sep 17, 2010 9:36:53 AM (14 years ago)
Author:
inferno@chromium.org
Message:

2010-09-17 Johnny Ding <jnd@chromium.org>

Reviewed by Adam Barth.

Stop history reload navigation to bypass WebKit's popup blocker.
Now history reload can only navigate the page in self frame, no matter
what target frame is defined in <base> and no new window can be created.
https://bugs.webkit.org/show_bug.cgi?id=45369

Test: fast/events/popup-blocked-from-history-reload.html

  • loader/RedirectScheduler.cpp: (WebCore::ScheduledNavigation::ScheduledNavigation): (WebCore::ScheduledNavigation::wasUserGesture): Move the m_wasUserGesture to base class ScheduledNavigation. Then all asynchronous navigation situations can restore the correct gesture state during the real navigation process. (WebCore::ScheduledURLNavigation::ScheduledURLNavigation): (WebCore::ScheduledURLNavigation::fire): (WebCore::ScheduledURLNavigation::referrer): (WebCore::ScheduledHistoryNavigation::ScheduledHistoryNavigation): (WebCore::ScheduledHistoryNavigation::fire): (WebCore::ScheduledFormSubmission::ScheduledFormSubmission): (WebCore::ScheduledFormSubmission::fire): (WebCore::RedirectScheduler::scheduleHistoryNavigation):

2010-09-17 Johnny Ding <jnd@chromium.org>

Reviewed by Adam Barth.

Stop history reload navigation to bypass WebKit's popup blocker.
https://bugs.webkit.org/show_bug.cgi?id=45369

  • fast/events/popup-blocked-from-history-reload-expected.txt: Added.
  • fast/events/popup-blocked-from-history-reload.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r67715 r67716  
     12010-09-17  Johnny Ding  <jnd@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Stop history reload navigation to bypass WebKit's popup blocker.
     6        https://bugs.webkit.org/show_bug.cgi?id=45369
     7
     8        * fast/events/popup-blocked-from-history-reload-expected.txt: Added.
     9        * fast/events/popup-blocked-from-history-reload.html: Added.
     10
    1112010-09-17  Zhenyao Mo  <zmo@google.com>
    212
  • trunk/WebCore/ChangeLog

    r67714 r67716  
     12010-09-17  Johnny Ding  <jnd@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Stop history reload navigation to bypass WebKit's popup blocker.
     6        Now history reload can only navigate the page in self frame, no matter
     7        what target frame is defined in <base> and no new window can be created.
     8        https://bugs.webkit.org/show_bug.cgi?id=45369
     9
     10        Test: fast/events/popup-blocked-from-history-reload.html
     11
     12        * loader/RedirectScheduler.cpp:
     13        (WebCore::ScheduledNavigation::ScheduledNavigation):
     14        (WebCore::ScheduledNavigation::wasUserGesture):
     15        Move the m_wasUserGesture to base class ScheduledNavigation. Then all
     16        asynchronous navigation situations can restore the correct gesture state
     17        during the real navigation process.
     18        (WebCore::ScheduledURLNavigation::ScheduledURLNavigation):
     19        (WebCore::ScheduledURLNavigation::fire):
     20        (WebCore::ScheduledURLNavigation::referrer):
     21        (WebCore::ScheduledHistoryNavigation::ScheduledHistoryNavigation):
     22        (WebCore::ScheduledHistoryNavigation::fire):
     23        (WebCore::ScheduledFormSubmission::ScheduledFormSubmission):
     24        (WebCore::ScheduledFormSubmission::fire):
     25        (WebCore::RedirectScheduler::scheduleHistoryNavigation):
     26
    1272010-09-16  Vangelis Kokkevis  <vangelis@chromium.org>
    228
  • trunk/WebCore/loader/RedirectScheduler.cpp

    r66742 r67716  
    3434
    3535#include "BackForwardList.h"
     36#include "DOMWindow.h"
    3637#include "DocumentLoader.h"
    3738#include "Event.h"
     
    4243#include "FrameLoader.h"
    4344#include "FrameLoaderStateMachine.h"
    44 #include "HistoryItem.h"
    4545#include "HTMLFormElement.h"
    4646#include "HTMLFrameOwnerElement.h"
     47#include "HistoryItem.h"
    4748#include "Page.h"
    4849#include "UserGestureIndicator.h"
     
    5354class ScheduledNavigation : public Noncopyable {
    5455public:
    55     ScheduledNavigation(double delay, bool lockHistory, bool lockBackForwardList, bool wasDuringLoad, bool isLocationChange)
     56    ScheduledNavigation(double delay, bool lockHistory, bool lockBackForwardList, bool wasDuringLoad, bool isLocationChange, bool wasUserGesture)
    5657        : m_delay(delay)
    5758        , m_lockHistory(lockHistory)
     
    5960        , m_wasDuringLoad(wasDuringLoad)
    6061        , m_isLocationChange(isLocationChange)
     62        , m_wasUserGesture(wasUserGesture)
    6163    {
    6264    }
     
    7476    bool wasDuringLoad() const { return m_wasDuringLoad; }
    7577    bool isLocationChange() const { return m_isLocationChange; }
     78    bool wasUserGesture() const { return m_wasUserGesture; }
    7679
    7780private:
     
    8184    bool m_wasDuringLoad;
    8285    bool m_isLocationChange;
     86    bool m_wasUserGesture;
    8387};
    8488
     
    8690public:
    8791    ScheduledURLNavigation(double delay, const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool wasUserGesture, bool duringLoad, bool isLocationChange)
    88         : ScheduledNavigation(delay, lockHistory, lockBackForwardList, duringLoad, isLocationChange)
     92        : ScheduledNavigation(delay, lockHistory, lockBackForwardList, duringLoad, isLocationChange, wasUserGesture)
    8993        , m_url(url)
    9094        , m_referrer(referrer)
    91         , m_wasUserGesture(wasUserGesture)
    9295        , m_haveToldClient(false)
    9396    {
     
    9699    virtual void fire(Frame* frame)
    97100    {
    98         frame->loader()->changeLocation(KURL(ParsedURLString, m_url), m_referrer, lockHistory(), lockBackForwardList(), m_wasUserGesture, false);
     101        frame->loader()->changeLocation(KURL(ParsedURLString, m_url), m_referrer, lockHistory(), lockBackForwardList(), wasUserGesture(), false);
    99102    }
    100103
     
    116119    String url() const { return m_url; }
    117120    String referrer() const { return m_referrer; }
    118     bool wasUserGesture() const { return m_wasUserGesture; }
    119121
    120122private:
    121123    String m_url;
    122124    String m_referrer;
    123     bool m_wasUserGesture;
    124125    bool m_haveToldClient;
    125126};
     
    152153class ScheduledHistoryNavigation : public ScheduledNavigation {
    153154public:
    154     explicit ScheduledHistoryNavigation(int historySteps) : ScheduledNavigation(0, false, false, false, true), m_historySteps(historySteps) { }
     155    explicit ScheduledHistoryNavigation(int historySteps, bool wasUserGesture) : ScheduledNavigation(0, false, false, false, true, wasUserGesture), m_historySteps(historySteps) { }
    155156
    156157    virtual void fire(Frame* frame)
    157158    {
     159        UserGestureIndicator gestureIndicator(wasUserGesture() ? DefinitelyProcessingUserGesture : DefinitelyNotProcessingUserGesture);
     160
    158161        FrameLoader* loader = frame->loader();
    159162        if (!m_historySteps) {
    160163            // Special case for go(0) from a frame -> reload only the frame
    161             loader->urlSelected(loader->url(), "", 0, lockHistory(), lockBackForwardList(), false, SendReferrer);
     164            // To follow Firefox and IE's behavior, history reload can only navigate the self frame.
     165            loader->urlSelected(loader->url(), "_self", 0, lockHistory(), lockBackForwardList(), wasUserGesture(), SendReferrer);
    162166            return;
    163167        }
     
    174178public:
    175179    ScheduledFormSubmission(PassRefPtr<FormSubmission> submission, bool lockBackForwardList, bool duringLoad, bool wasUserGesture)
    176         : ScheduledNavigation(0, submission->lockHistory(), lockBackForwardList, duringLoad, true)
     180        : ScheduledNavigation(0, submission->lockHistory(), lockBackForwardList, duringLoad, true, wasUserGesture)
    177181        , m_submission(submission)
    178182        , m_haveToldClient(false)
    179         , m_wasUserGesture(wasUserGesture)
    180183    {
    181184        ASSERT(m_submission->state());
     
    184187    virtual void fire(Frame* frame)
    185188    {
    186         UserGestureIndicator gestureIndicator(m_wasUserGesture ? DefinitelyProcessingUserGesture : DefinitelyNotProcessingUserGesture);
     189        UserGestureIndicator gestureIndicator(wasUserGesture() ? DefinitelyProcessingUserGesture : DefinitelyNotProcessingUserGesture);
    187190
    188191        // The submitForm function will find a target frame before using the redirection timer.
     
    215218    RefPtr<FormSubmission> m_submission;
    216219    bool m_haveToldClient;
    217     bool m_wasUserGesture;
    218220};
    219221
     
    345347        return;
    346348    }
    347    
     349
    348350    // In all other cases, schedule the history traversal to occur asynchronously.
    349     schedule(adoptPtr(new ScheduledHistoryNavigation(steps)));
     351    schedule(adoptPtr(new ScheduledHistoryNavigation(steps, m_frame->loader()->isProcessingUserGesture())));
    350352}
    351353
Note: See TracChangeset for help on using the changeset viewer.