summaryrefslogtreecommitdiff
path: root/Source/WebCore/loader/FrameLoader.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-08-21 10:57:44 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-08-21 10:57:44 +0200
commit5ef7c8a6a70875d4430752d146bdcb069605d71d (patch)
treef6256640b6c46d7da221435803cae65326817ba2 /Source/WebCore/loader/FrameLoader.cpp
parentdecad929f578d8db641febc8740649ca6c574638 (diff)
downloadqtwebkit-5ef7c8a6a70875d4430752d146bdcb069605d71d.tar.gz
Imported WebKit commit 356d83016b090995d08ad568f2d2c243aa55e831 (http://svn.webkit.org/repository/webkit/trunk@126147)
New snapshot including various build fixes for newer Qt 5
Diffstat (limited to 'Source/WebCore/loader/FrameLoader.cpp')
-rw-r--r--Source/WebCore/loader/FrameLoader.cpp68
1 files changed, 37 insertions, 31 deletions
diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp
index 0dcb3b24f..23e9b6cc9 100644
--- a/Source/WebCore/loader/FrameLoader.cpp
+++ b/Source/WebCore/loader/FrameLoader.cpp
@@ -303,6 +303,8 @@ void FrameLoader::submitForm(PassRefPtr<FormSubmission> submission)
return;
if (protocolIsJavaScript(submission->action())) {
+ if (!m_frame->document()->contentSecurityPolicy()->allowFormAction(KURL(submission->action())))
+ return;
m_isExecutingJavaScriptFormAction = true;
m_frame->script()->executeIfJavaScriptURL(submission->action(), DoNotReplaceDocumentIfJavaScriptURL);
m_isExecutingJavaScriptFormAction = false;
@@ -334,9 +336,9 @@ void FrameLoader::submitForm(PassRefPtr<FormSubmission> submission)
// needed any more now that we reset m_submittedFormURL on each mouse or key down event.
if (m_frame->tree()->isDescendantOf(targetFrame)) {
- if (m_submittedFormURL == submission->action())
+ if (m_submittedFormURL == submission->requestURL())
return;
- m_submittedFormURL = submission->action();
+ m_submittedFormURL = submission->requestURL();
}
submission->data()->generateFiles(m_frame->document());
@@ -357,10 +359,10 @@ void FrameLoader::stopLoading(UnloadEventPolicy unloadEventPolicy)
Node* currentFocusedNode = m_frame->document()->focusedNode();
if (currentFocusedNode)
currentFocusedNode->aboutToUnload();
- if (m_frame->domWindow() && m_pageDismissalEventBeingDispatched == NoDismissal) {
+ if (m_pageDismissalEventBeingDispatched == NoDismissal) {
if (unloadEventPolicy == UnloadEventPolicyUnloadAndPageHide) {
m_pageDismissalEventBeingDispatched = PageHideDismissal;
- m_frame->domWindow()->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, m_frame->document()->inPageCache()), m_frame->document());
+ m_frame->document()->domWindow()->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, m_frame->document()->inPageCache()), m_frame->document());
}
if (!m_frame->document()->inPageCache()) {
RefPtr<Event> unloadEvent(Event::create(eventNames().unloadEvent, false, false));
@@ -373,10 +375,10 @@ void FrameLoader::stopLoading(UnloadEventPolicy unloadEventPolicy)
DocumentLoadTiming* timing = documentLoader->timing();
ASSERT(timing->navigationStart());
timing->markUnloadEventStart();
- m_frame->domWindow()->dispatchEvent(unloadEvent, m_frame->domWindow()->document());
+ m_frame->document()->domWindow()->dispatchEvent(unloadEvent, m_frame->document());
timing->markUnloadEventEnd();
} else
- m_frame->domWindow()->dispatchEvent(unloadEvent, m_frame->domWindow()->document());
+ m_frame->document()->domWindow()->dispatchEvent(unloadEvent, m_frame->document());
}
}
m_pageDismissalEventBeingDispatched = NoDismissal;
@@ -464,10 +466,9 @@ bool FrameLoader::didOpenURL()
// its frame is not in a consistent state for rendering, so avoid setJSStatusBarText
// since it may cause clients to attempt to render the frame.
if (!m_stateMachine.creatingInitialEmptyDocument()) {
- if (DOMWindow* window = m_frame->existingDOMWindow()) {
- window->setStatus(String());
- window->setDefaultStatus(String());
- }
+ DOMWindow* window = m_frame->document()->domWindow();
+ window->setStatus(String());
+ window->setDefaultStatus(String());
}
started();
@@ -499,11 +500,11 @@ void FrameLoader::cancelAndClear()
if (!m_isComplete)
closeURL();
- clear(false);
+ clear(m_frame->document(), false);
m_frame->script()->updatePlatformScriptObjects();
}
-void FrameLoader::clear(bool clearWindowProperties, bool clearScriptObjects, bool clearFrameView)
+void FrameLoader::clear(Document* newDocument, bool clearWindowProperties, bool clearScriptObjects, bool clearFrameView)
{
m_frame->editor()->clear();
@@ -522,8 +523,9 @@ void FrameLoader::clear(bool clearWindowProperties, bool clearScriptObjects, boo
// Do this after detaching the document so that the unload event works.
if (clearWindowProperties) {
- m_frame->clearDOMWindow();
- m_frame->script()->clearWindowShell(m_frame->document()->inPageCache());
+ InspectorInstrumentation::frameWindowDiscarded(m_frame, m_frame->document()->domWindow());
+ m_frame->document()->domWindow()->resetUnlessSuspendedForPageCache();
+ m_frame->script()->clearWindowShell(newDocument->domWindow(), m_frame->document()->inPageCache());
}
m_frame->selection()->clear();
@@ -885,7 +887,7 @@ bool FrameLoader::checkIfDisplayInsecureContent(SecurityOrigin* context, const K
String message = (allowed ? emptyString() : "[blocked] ") + "The page at " +
m_frame->document()->url().string() + " displayed insecure content from " + url.string() + ".\n";
- m_frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, WarningMessageLevel, message);
+ m_frame->document()->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, WarningMessageLevel, message);
if (allowed)
m_client->didDisplayInsecureContent();
@@ -903,7 +905,7 @@ bool FrameLoader::checkIfRunInsecureContent(SecurityOrigin* context, const KURL&
String message = (allowed ? emptyString() : "[blocked] ") + "The page at " +
m_frame->document()->url().string() + " ran insecure content from " + url.string() + ".\n";
- m_frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, WarningMessageLevel, message);
+ m_frame->document()->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, WarningMessageLevel, message);
if (allowed)
m_client->didRunInsecureContent(context, url);
@@ -911,6 +913,14 @@ bool FrameLoader::checkIfRunInsecureContent(SecurityOrigin* context, const KURL&
return allowed;
}
+bool FrameLoader::checkIfFormActionAllowedByCSP(const KURL& url) const
+{
+ if (m_submittedFormURL.isEmpty())
+ return true;
+
+ return m_frame->document()->contentSecurityPolicy()->allowFormAction(url);
+}
+
Frame* FrameLoader::opener()
{
return m_opener;
@@ -924,10 +934,8 @@ void FrameLoader::setOpener(Frame* opener)
opener->loader()->m_openedFrames.add(m_frame);
m_opener = opener;
- if (m_frame->document()) {
+ if (m_frame->document())
m_frame->document()->initSecurityContext();
- m_frame->domWindow()->setSecurityOrigin(m_frame->document()->securityOrigin());
- }
}
// FIXME: This does not belong in FrameLoader!
@@ -1372,7 +1380,7 @@ void FrameLoader::reportLocalLoadFailed(Frame* frame, const String& url)
if (!frame)
return;
- frame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Not allowed to load local resource: " + url);
+ frame->document()->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Not allowed to load local resource: " + url);
}
const ResourceRequest& FrameLoader::initialRequest() const
@@ -1903,10 +1911,9 @@ void FrameLoader::prepareForCachedPageRestore()
// Delete old status bar messages (if it _was_ activated on last URL).
if (m_frame->script()->canExecuteScripts(NotAboutToExecuteScript)) {
- if (DOMWindow* window = m_frame->existingDOMWindow()) {
- window->setStatus(String());
- window->setDefaultStatus(String());
- }
+ DOMWindow* window = m_frame->document()->domWindow();
+ window->setStatus(String());
+ window->setDefaultStatus(String());
}
}
@@ -1924,10 +1931,12 @@ void FrameLoader::open(CachedFrameBase& cachedFrame)
url.setPath("/");
started();
- clear(true, true, cachedFrame.isMainFrame());
-
Document* document = cachedFrame.document();
ASSERT(document);
+ ASSERT(document->domWindow());
+
+ clear(document, true, true, cachedFrame.isMainFrame());
+
document->setInPageCache(false);
m_needsClear = true;
@@ -1947,10 +1956,7 @@ void FrameLoader::open(CachedFrameBase& cachedFrame)
m_frame->setView(view);
m_frame->setDocument(document);
- m_frame->setDOMWindow(cachedFrame.domWindow());
- m_frame->domWindow()->resumeFromPageCache();
- m_frame->domWindow()->setURL(document->url());
- m_frame->domWindow()->setSecurityOrigin(document->securityOrigin());
+ document->domWindow()->resumeFromPageCache();
updateFirstPartyForCookies();
@@ -2694,7 +2700,7 @@ bool FrameLoader::shouldClose()
bool FrameLoader::fireBeforeUnloadEvent(Chrome* chrome)
{
- DOMWindow* domWindow = m_frame->existingDOMWindow();
+ DOMWindow* domWindow = m_frame->document()->domWindow();
if (!domWindow)
return true;