Don't report resource timing to parent frame for history items
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Dec 2018 23:01:29 +0000 (23:01 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Dec 2018 23:01:29 +0000 (23:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192273
<rdar://problem/45163764>

Reviewed by Youenn Fablet.

Source/WebCore:

We should not report history items to its parent frame as those are less
interested to its parent and might not be the first navigation in the iframes.

This change aligns the behavior when a cached document is not available for the
history item with the available case as we don't report resource timing for any
cached main document.

Test: http/tests/misc/resource-timing-navigation-in-restored-iframe-2.html

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

LayoutTests:

* http/tests/misc/resource-timing-navigation-in-restored-iframe-2-expected.txt: Added.
* http/tests/misc/resource-timing-navigation-in-restored-iframe-2.html: Copied from LayoutTests/http/tests/misc/resource-timing-navigation-in-restored-iframe.html.
* http/tests/misc/resource-timing-navigation-in-restored-iframe.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238877 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/misc/resource-timing-navigation-in-restored-iframe-2-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/misc/resource-timing-navigation-in-restored-iframe-2.html [new file with mode: 0644]
LayoutTests/http/tests/misc/resource-timing-navigation-in-restored-iframe.html
Source/WebCore/ChangeLog
Source/WebCore/loader/FrameLoader.cpp

index 6d4eebd..b9c902b 100644 (file)
@@ -1,3 +1,15 @@
+2018-11-30  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Don't report resource timing to parent frame for history items
+        https://bugs.webkit.org/show_bug.cgi?id=192273
+        <rdar://problem/45163764>
+
+        Reviewed by Youenn Fablet.
+
+        * http/tests/misc/resource-timing-navigation-in-restored-iframe-2-expected.txt: Added.
+        * http/tests/misc/resource-timing-navigation-in-restored-iframe-2.html: Copied from LayoutTests/http/tests/misc/resource-timing-navigation-in-restored-iframe.html.
+        * http/tests/misc/resource-timing-navigation-in-restored-iframe.html:
+
 2018-12-04  Simon Fraser  <simon.fraser@apple.com>
 
         REGRESSION (r238090): position:fixed sidebar on https://www.w3.org/TR/SVG2/coords.html does not stay fixed
diff --git a/LayoutTests/http/tests/misc/resource-timing-navigation-in-restored-iframe-2-expected.txt b/LayoutTests/http/tests/misc/resource-timing-navigation-in-restored-iframe-2-expected.txt
new file mode 100644 (file)
index 0000000..b2bd1cc
--- /dev/null
@@ -0,0 +1,12 @@
+ALERT: Going back.
+Tests that an iframe restored from history does not report resource timing.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS resources.length is 1
+PASS resources[0].name is "http://127.0.0.1:8000/js-test-resources/js-test.js"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/misc/resource-timing-navigation-in-restored-iframe-2.html b/LayoutTests/http/tests/misc/resource-timing-navigation-in-restored-iframe-2.html
new file mode 100644 (file)
index 0000000..af54afc
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<script src="/js-test-resources/js-test.js"></script>
+<script>
+    description('Tests that an iframe restored from history does not report resource timing.');
+    window.jsTestIsAsync = true;
+    if (window.internals)
+        internals.clearMemoryCache();
+
+    function runTest() {
+        if (!sessionStorage.didNav) {
+            sessionStorage.didNav = true;
+            window.addEventListener('message', (event) => {
+                location.href = 'resources/alert-then-back.html';
+            });
+            document.getElementById('target-iframe').contentWindow.postMessage('navigate', '*');
+        } else {
+            delete sessionStorage.didNav;
+
+            resources = performance.getEntriesByType('resource');
+            shouldBe('resources.length', '1');
+            shouldBeEqualToString('resources[0].name', 'http://127.0.0.1:8000/js-test-resources/js-test.js');
+            if (window.testRunner)
+                finishJSTest();
+        }
+    }
+    window.onload = runTest;
+</script>
+<iframe id="target-iframe" src="http://localhost:8080/misc/resources/navigate-on-message.html"></iframe>
index 980a3b6..10fb0f3 100644 (file)
@@ -14,7 +14,7 @@
             delete sessionStorage.didNav;
             window.addEventListener('message', (event) => {
                 resources = performance.getEntriesByType('resource');
-                shouldBe('resources.length', '1');
+                shouldBe('resources.length', '1'); // There is only one report as we don't report resource timing for cached main document.
                 shouldBeEqualToString('resources[0].name', 'http://127.0.0.1:8000/js-test-resources/js-test.js');
                 if (window.testRunner)
                     finishJSTest();
index defcd21..b112c6e 100644 (file)
@@ -1,3 +1,23 @@
+2018-11-30  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Don't report resource timing to parent frame for history items
+        https://bugs.webkit.org/show_bug.cgi?id=192273
+        <rdar://problem/45163764>
+
+        Reviewed by Youenn Fablet.
+
+        We should not report history items to its parent frame as those are less
+        interested to its parent and might not be the first navigation in the iframes.
+
+        This change aligns the behavior when a cached document is not available for the
+        history item with the available case as we don't report resource timing for any
+        cached main document.
+
+        Test: http/tests/misc/resource-timing-navigation-in-restored-iframe-2.html
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::loadDifferentDocumentItem):
+
 2018-12-04  Simon Fraser  <simon.fraser@apple.com>
 
         REGRESSION (r238090): position:fixed sidebar on https://www.w3.org/TR/SVG2/coords.html does not stay fixed
index da0412c..a857e8f 100644 (file)
@@ -3591,6 +3591,9 @@ void FrameLoader::loadSameDocumentItem(HistoryItem& item)
 // methods of FrameLoader.
 void FrameLoader::loadDifferentDocumentItem(HistoryItem& item, FrameLoadType loadType, FormSubmissionCacheLoadPolicy cacheLoadPolicy, ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad)
 {
+    // History items should not be reported to the parent.
+    m_shouldReportResourceTimingToParentFrame = false;
+
     // Remember this item so we can traverse any child items as child frames load
     history().setProvisionalItem(&item);