⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 233793 in webkit


Ignore:
Timestamp:
Jul 12, 2018, 8:13:19 PM (8 years ago)
Author:
dbates@webkit.org
Message:

JavaScript URL gives incorrect result when frame is navigated
​https://bugs.webkit.org/show_bug.cgi?id=187203
<rdar://problem/41438443>

Reviewed by David Kilzer.

  • loader/SubframeLoader.cpp:

(WebCore::SubframeLoader::requestFrame):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r233789 r233793  
     12018-07-12  Daniel Bates  <dabates@apple.com>
     2
     3        JavaScript URL gives incorrect result when frame is navigated
     4        https://bugs.webkit.org/show_bug.cgi?id=187203
     5        <rdar://problem/41438443>
     6
     7        Reviewed by David Kilzer.
     8
     9        * loader/SubframeLoader.cpp:
     10        (WebCore::SubframeLoader::requestFrame):
     11
    1122018-07-12  Alex Christensen  <achristensen@webkit.org>
    213
  • trunk/Source/WebCore/loader/SubframeLoader.cpp

    r230211 r233793  
    3737#include "DiagnosticLoggingClient.h"
    3838#include "DiagnosticLoggingKeys.h"
     39#include "DocumentLoader.h"
    3940#include "Frame.h"
    4041#include "FrameLoader.h"
    … …  
    8687        url = blankURL();
    8788
     89    bool hasExistingFrame = ownerElement.contentFrame();
    8890    Frame* frame = loadOrRedirectSubframe(ownerElement, url, frameName, lockHistory, lockBackForwardList);
    8991    if (!frame)
    9092        return false;
    9193
    92     if (!scriptURL.isEmpty() && ownerElement.isURLAllowed(scriptURL))
     94    // If we create a new subframe then an empty document is loaded into it synchronously and may
     95    // cause script execution (say, via a DOM load event handler) that can do anything, including
     96    // navigating the subframe. We only want to evaluate scriptURL if the frame has not been navigated.
     97    bool canExecuteScript = hasExistingFrame || (frame->loader().documentLoader() && frame->loader().documentLoader()->originalURL() == blankURL());
     98    if (!scriptURL.isEmpty() && canExecuteScript && ownerElement.isURLAllowed(scriptURL))
    9399        frame->script().executeIfJavaScriptURL(scriptURL);
    94100
Note: See TracChangeset for help on using the changeset viewer.