changeset 9583:3ccf14ef836f

8139114: WebView crashes on Yahoo login page Reviewed-by: kcr
author ghb
date Wed, 24 Feb 2016 17:32:22 +0530
parents 757febff3b17
children f4c4d2980d68
files modules/web/src/main/native/Source/WebCore/loader/SubresourceLoader.cpp modules/web/src/main/native/Source/WebCore/loader/cache/CachedResourceLoader.cpp
diffstat 2 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/modules/web/src/main/native/Source/WebCore/loader/SubresourceLoader.cpp	Tue Feb 23 19:03:05 2016 -0800
+++ b/modules/web/src/main/native/Source/WebCore/loader/SubresourceLoader.cpp	Wed Feb 24 17:32:22 2016 +0530
@@ -160,10 +160,26 @@
             memoryCache()->revalidationFailed(m_resource);
         }
 
+#if PLATFORM(JAVA)
+        // Current Main frame is in Provisinal state i.e its started network request, but yet to get network response
+        // In Some case, the current document which is about to be replaced (Not Active document loader) will request for
+        // sub-resource mainly javascript files will cause to execute or loaded to the active document loader (which is in provisional state).
+        if ((m_documentLoader->frame() && m_documentLoader->frame()->loader().state() == FrameStateProvisional) &&
+                (m_resource->type() != CachedResource::Type::MainResource)) {
+            if (!(m_documentLoader->frame()->loader().documentLoader()->cachedResourceLoader().canRequest(m_resource->type(), newRequest.url(), options()))) {
+                cancel();
+                return;
+            }
+        } else if (!m_documentLoader->cachedResourceLoader().canRequest(m_resource->type(), newRequest.url(), options())) {
+            cancel();
+            return;
+        }
+#else
         if (!m_documentLoader->cachedResourceLoader().canRequest(m_resource->type(), newRequest.url(), options())) {
             cancel();
             return;
         }
+#endif
         if (m_resource->isImage() && m_documentLoader->cachedResourceLoader().shouldDeferImageLoad(newRequest.url())) {
             cancel();
             return;
--- a/modules/web/src/main/native/Source/WebCore/loader/cache/CachedResourceLoader.cpp	Tue Feb 23 19:03:05 2016 -0800
+++ b/modules/web/src/main/native/Source/WebCore/loader/cache/CachedResourceLoader.cpp	Wed Feb 24 17:32:22 2016 +0530
@@ -334,6 +334,13 @@
         break;
 #endif
     case CachedResource::Script:
+#if PLATFORM(JAVA)
+        // m_document holds current active document loader
+        // if the cached resource doesn't belong to active document i.e these resource being requested from a older page
+        // which is about to be replaced by current active document loader
+        if (!m_document)
+            return false;
+#endif
         if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowScriptFromSource(url))
             return false;
 
@@ -348,6 +355,10 @@
         break;
     case CachedResource::SVGDocumentResource:
     case CachedResource::ImageResource:
+#if PLATFORM(JAVA)
+        if (!m_document)
+            return false;
+#endif
         if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowImageFromSource(url))
             return false;
         break;