Title: [139513] trunk
Revision
139513
Author
simon...@chromium.org
Date
2013-01-11 15:54:56 -0800 (Fri, 11 Jan 2013)

Log Message

[Resource Timing] XMLHttpRequests should have initiator type 'xmlhttprequest'
https://bugs.webkit.org/show_bug.cgi?id=106409

Reviewed by Nate Chapin.

Source/WebCore:

The initiator is passed through ThreadableLoaderOptions to the CachedResourceRequest. This is
optional, so other users of ThreadableLoader will have the default initiator of 'request'. Note
that synchronous XHRs don't show up in the Resource Timing buffer yet.

Test: http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types.html

* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::loadRequest):
* loader/ThreadableLoader.h:
(ThreadableLoaderOptions):
* loader/cache/CachedResourceRequestInitiators.cpp:
(WebCore::CachedResourceRequestInitiators::CachedResourceRequestInitiators):
* loader/cache/CachedResourceRequestInitiators.h:
(CachedResourceRequestInitiators):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::createRequest):

LayoutTests:

* http/tests/w3c/webperf/resources/all_resource_types.htm:
* http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types-expected.txt:
* http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (139512 => 139513)


--- trunk/LayoutTests/ChangeLog	2013-01-11 23:42:14 UTC (rev 139512)
+++ trunk/LayoutTests/ChangeLog	2013-01-11 23:54:56 UTC (rev 139513)
@@ -1,3 +1,14 @@
+2013-01-11  James Simonsen  <simon...@chromium.org>
+
+        [Resource Timing] XMLHttpRequests should have initiator type 'xmlhttprequest'
+        https://bugs.webkit.org/show_bug.cgi?id=106409
+
+        Reviewed by Nate Chapin.
+
+        * http/tests/w3c/webperf/resources/all_resource_types.htm:
+        * http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types-expected.txt:
+        * http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types.html:
+
 2013-01-11  Stephen Chenney  <schen...@chromium.org>
 
         [Chromium] More test expectations for Skia changes

Modified: trunk/LayoutTests/http/tests/w3c/webperf/resources/all_resource_types.htm (139512 => 139513)


--- trunk/LayoutTests/http/tests/w3c/webperf/resources/all_resource_types.htm	2013-01-11 23:42:14 UTC (rev 139512)
+++ trunk/LayoutTests/http/tests/w3c/webperf/resources/all_resource_types.htm	2013-01-11 23:54:56 UTC (rev 139513)
@@ -14,9 +14,13 @@
         <iframe src="" width="100px" height="100px"></iframe>
         <script src=""
         <script>
-            var xhr = new XMLHttpRequest;
-            xhr.open("GET", "blank_page_yellow.htm", false);
-            xhr.send();
+            var async_xhr = new XMLHttpRequest;
+            async_xhr.open("GET", "generate_resource.php?type=image&id=async_xhr", true);
+            async_xhr._onreadystatechange_ = function() {
+                if (async_xhr.readyState == 4 && async_xhr.status == 200 && parent.hasOwnProperty('on_async_xhr_done'))
+                    parent.on_async_xhr_done();
+            }
+            async_xhr.send();
         </script>
         <style>
             @font-face {

Modified: trunk/LayoutTests/http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types-expected.txt (139512 => 139513)


--- trunk/LayoutTests/http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types-expected.txt	2013-01-11 23:42:14 UTC (rev 139512)
+++ trunk/LayoutTests/http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types-expected.txt	2013-01-11 23:54:56 UTC (rev 139513)
@@ -7,17 +7,18 @@
 PASS /w3c/webperf/resources/Ahem.ttf is expected to have initiatorType css 
 PASS /w3c/webperf/resources/blank_image.png is expected to have initiatorType img 
 PASS /w3c/webperf/resources/blank_page_green.htm is expected to have initiatorType iframe 
-PASS /w3c/webperf/resources/blank_page_yellow.htm is expected to have initiatorType xmlhttprequest 
 PASS /w3c/webperf/resources/empty_script.js is expected to have initiatorType script 
 PASS /w3c/webperf/resources/generate_resource.php?type=css&id=embed is expected to have initiatorType embed 
 PASS /w3c/webperf/resources/generate_resource.php?type=css&id=n1 is expected to have initiatorType css 
 PASS /w3c/webperf/resources/generate_resource.php?type=font&id=n1 is expected to have initiatorType css 
 PASS /w3c/webperf/resources/generate_resource.php?type=image&id=1 is expected to have initiatorType css 
 PASS /w3c/webperf/resources/generate_resource.php?type=image&id=2 is expected to have initiatorType css 
+PASS /w3c/webperf/resources/generate_resource.php?type=image&id=async_xhr is expected to have initiatorType xmlhttprequest 
 PASS /w3c/webperf/resources/generate_resource.php?type=image&id=body is expected to have initiatorType body 
 PASS /w3c/webperf/resources/generate_resource.php?type=image&id=input is expected to have initiatorType input 
 PASS /w3c/webperf/resources/generate_resource.php?type=image&id=n1 is expected to have initiatorType css 
 PASS /w3c/webperf/resources/generate_resource.php?type=image&id=object is expected to have initiatorType object 
 PASS /w3c/webperf/resources/generate_resource.php?type=image&id=poster is expected to have initiatorType video 
+PASS /w3c/webperf/resources/generate_resource.php?type=image&id=sync_xhr is expected to have initiatorType xmlhttprequest 
 PASS /w3c/webperf/resources/nested.css is expected to have initiatorType link 
 

Modified: trunk/LayoutTests/http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types.html (139512 => 139513)


--- trunk/LayoutTests/http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types.html	2013-01-11 23:42:14 UTC (rev 139512)
+++ trunk/LayoutTests/http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types.html	2013-01-11 23:54:56 UTC (rev 139513)
@@ -15,6 +15,7 @@
 var page_loaded = false;
 var ol_font_loaded = false;
 var ul_font_loaded = false;
+var xhr_loaded = false;
 
 function check_finished() {
     if (!ul_font_loaded) {
@@ -23,7 +24,7 @@
     if (!ol_font_loaded) {
         ol_font_loaded = check_font_loaded('ol');
     }
-    if (page_loaded && ol_font_loaded && ul_font_loaded && background_loaded) {
+    if (page_loaded && ol_font_loaded && ul_font_loaded && background_loaded && xhr_loaded) {
         perform_test();
     }
 }
@@ -63,22 +64,22 @@
     var entries = document.getElementById('frameContext').contentWindow.performance.webkitGetEntries();
 
     var expected_entries = {
-        '/w3c/webperf/resources/generate_resource.php?type=image&id=body': 'body',
-        '/w3c/webperf/resources/nested.css': 'link',
+        '/w3c/webperf/resources/Ahem.ttf': 'css',
         '/w3c/webperf/resources/blank_image.png': 'img',
         '/w3c/webperf/resources/blank_page_green.htm': 'iframe',
         '/w3c/webperf/resources/empty_script.js': 'script',
-        '/w3c/webperf/resources/blank_page_yellow.htm': 'xmlhttprequest',
+        '/w3c/webperf/resources/generate_resource.php?type=css&id=embed': 'embed',
+        '/w3c/webperf/resources/generate_resource.php?type=css&id=n1': 'css',
+        '/w3c/webperf/resources/generate_resource.php?type=font&id=n1': 'css',
         '/w3c/webperf/resources/generate_resource.php?type=image&id=1': 'css',
         '/w3c/webperf/resources/generate_resource.php?type=image&id=2': 'css',
-        '/w3c/webperf/resources/Ahem.ttf': 'css',
-        '/w3c/webperf/resources/generate_resource.php?type=css&id=n1': 'css',
-        '/w3c/webperf/resources/generate_resource.php?type=font&id=n1': 'css',
+        '/w3c/webperf/resources/generate_resource.php?type=image&id=async_xhr': 'xmlhttprequest',
+        '/w3c/webperf/resources/generate_resource.php?type=image&id=body': 'body',
+        '/w3c/webperf/resources/generate_resource.php?type=image&id=input': 'input',
         '/w3c/webperf/resources/generate_resource.php?type=image&id=n1': 'css',
-        '/w3c/webperf/resources/generate_resource.php?type=css&id=embed': 'embed',
-        '/w3c/webperf/resources/generate_resource.php?type=image&id=input': 'input',
         '/w3c/webperf/resources/generate_resource.php?type=image&id=object': 'object',
         '/w3c/webperf/resources/generate_resource.php?type=image&id=poster': 'video',
+        '/w3c/webperf/resources/nested.css': 'link',
     };
 
     test_resource_entries(entries, expected_entries);
@@ -86,6 +87,10 @@
 }
 
 window._on_test_body_created_ = check_finished;
+window._on_async_xhr_done_ = function() {
+    xhr_loaded = true;
+    check_finished();
+}
 </script>
 </head>
 <body>

Modified: trunk/Source/WebCore/ChangeLog (139512 => 139513)


--- trunk/Source/WebCore/ChangeLog	2013-01-11 23:42:14 UTC (rev 139512)
+++ trunk/Source/WebCore/ChangeLog	2013-01-11 23:54:56 UTC (rev 139513)
@@ -1,5 +1,29 @@
 2013-01-11  James Simonsen  <simon...@chromium.org>
 
+        [Resource Timing] XMLHttpRequests should have initiator type 'xmlhttprequest'
+        https://bugs.webkit.org/show_bug.cgi?id=106409
+
+        Reviewed by Nate Chapin.
+
+        The initiator is passed through ThreadableLoaderOptions to the CachedResourceRequest. This is
+        optional, so other users of ThreadableLoader will have the default initiator of 'request'. Note
+        that synchronous XHRs don't show up in the Resource Timing buffer yet.
+
+        Test: http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types.html
+
+        * loader/DocumentThreadableLoader.cpp:
+        (WebCore::DocumentThreadableLoader::loadRequest):
+        * loader/ThreadableLoader.h:
+        (ThreadableLoaderOptions):
+        * loader/cache/CachedResourceRequestInitiators.cpp:
+        (WebCore::CachedResourceRequestInitiators::CachedResourceRequestInitiators):
+        * loader/cache/CachedResourceRequestInitiators.h:
+        (CachedResourceRequestInitiators):
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::createRequest):
+
+2013-01-11  James Simonsen  <simon...@chromium.org>
+
         Restore old semantics to webkitRequestAnimationFrame callbacks
         https://bugs.webkit.org/show_bug.cgi?id=106697
 

Modified: trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp (139512 => 139513)


--- trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp	2013-01-11 23:42:14 UTC (rev 139512)
+++ trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp	2013-01-11 23:54:56 UTC (rev 139513)
@@ -375,6 +375,9 @@
         }
 
         CachedResourceRequest newRequest(request, options);
+#if ENABLE(RESOURCE_TIMING)
+        newRequest.setInitiator(m_options.initiator);
+#endif
 #if ENABLE(INSPECTOR)
         if (m_actualRequest) {
             // Because willSendRequest only gets called during redirects, we initialize the identifier and the first willSendRequest here.

Modified: trunk/Source/WebCore/loader/ThreadableLoader.h (139512 => 139513)


--- trunk/Source/WebCore/loader/ThreadableLoader.h	2013-01-11 23:42:14 UTC (rev 139512)
+++ trunk/Source/WebCore/loader/ThreadableLoader.h	2013-01-11 23:54:56 UTC (rev 139513)
@@ -64,6 +64,9 @@
         PreflightPolicy preflightPolicy; // If AccessControl is used, how to determine if a preflight is needed.
         CrossOriginRequestPolicy crossOriginRequestPolicy;
         RefPtr<SecurityOrigin> securityOrigin;
+#if ENABLE(RESOURCE_TIMING)
+        AtomicString initiator;
+#endif
     };
 
     // Useful for doing loader operations from any thread (not threadsafe, 

Modified: trunk/Source/WebCore/loader/cache/CachedResourceRequestInitiators.cpp (139512 => 139513)


--- trunk/Source/WebCore/loader/cache/CachedResourceRequestInitiators.cpp	2013-01-11 23:42:14 UTC (rev 139512)
+++ trunk/Source/WebCore/loader/cache/CachedResourceRequestInitiators.cpp	2013-01-11 23:54:56 UTC (rev 139513)
@@ -31,6 +31,7 @@
 CachedResourceRequestInitiators::CachedResourceRequestInitiators()
     : css("css", AtomicString::ConstructFromLiteral)
     , icon("icon", AtomicString::ConstructFromLiteral)
+    , xmlhttprequest("xmlhttprequest", AtomicString::ConstructFromLiteral)
 {
 }
 

Modified: trunk/Source/WebCore/loader/cache/CachedResourceRequestInitiators.h (139512 => 139513)


--- trunk/Source/WebCore/loader/cache/CachedResourceRequestInitiators.h	2013-01-11 23:42:14 UTC (rev 139512)
+++ trunk/Source/WebCore/loader/cache/CachedResourceRequestInitiators.h	2013-01-11 23:54:56 UTC (rev 139513)
@@ -34,6 +34,7 @@
 struct CachedResourceRequestInitiators {
     const AtomicString css;
     const AtomicString icon;
+    const AtomicString xmlhttprequest;
     WTF_MAKE_NONCOPYABLE(CachedResourceRequestInitiators); WTF_MAKE_FAST_ALLOCATED;
 private:
     CachedResourceRequestInitiators();

Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (139512 => 139513)


--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2013-01-11 23:42:14 UTC (rev 139512)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2013-01-11 23:54:56 UTC (rev 139513)
@@ -64,6 +64,10 @@
 #include <wtf/UnusedParam.h>
 #include <wtf/text/CString.h>
 
+#if ENABLE(RESOURCE_TIMING)
+#include "CachedResourceRequestInitiators.h"
+#endif
+
 #if USE(JSC)
 #include "JSDOMBinding.h"
 #include "JSDOMWindow.h"
@@ -786,6 +790,9 @@
     options.allowCredentials = (m_sameOriginRequest || m_includeCredentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials;
     options.crossOriginRequestPolicy = UseAccessControl;
     options.securityOrigin = securityOrigin();
+#if ENABLE(RESOURCE_TIMING)
+    options.initiator = cachedResourceRequestInitiators().xmlhttprequest;
+#endif
 
 #if ENABLE(XHR_TIMEOUT)
     if (m_timeoutMilliseconds)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to