Cache partitioning does not affect iframe MainResources
https://bugs.webkit.org/show_bug.cgi?id=111022

Reviewed by David Kilzer.

Source/WebCore:

Set the partition of a main resource request if in a subframe.

Test: http/tests/cache/partitioned-cache-iframe.html

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadURL):

LayoutTests:

These tests results are for the case in which the cache is not
partitioned, as no shipping ports have cache partitioning enabled

* http/tests/cache/partitioned-cache-iframe-expected.txt: Added.
* http/tests/cache/partitioned-cache-iframe.html: Added.
* http/tests/cache/resources/random-cached-iframe.cgi: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@144694 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp
index 2c6056b..be471d4 100644
--- a/Source/WebCore/loader/FrameLoader.cpp
+++ b/Source/WebCore/loader/FrameLoader.cpp
@@ -1194,6 +1194,10 @@
         RefPtr<SecurityOrigin> referrerOrigin = SecurityOrigin::createFromString(referrer);
         addHTTPOriginIfNeeded(request, referrerOrigin->toString());
     }
+#if ENABLE(CACHE_PARTITIONING)
+    if (m_frame->tree()->top() != m_frame)
+        request.setCachePartition(m_frame->tree()->top()->document()->securityOrigin()->cachePartition());
+#endif
     addExtraFieldsToRequest(request, newLoadType, true);
     if (newLoadType == FrameLoadTypeReload || newLoadType == FrameLoadTypeReloadFromOrigin)
         request.setCachePolicy(ReloadIgnoringCacheData);