Bug 1263790 - Resource timing initiatorType should be "iframe" instead of "subdocument" r=bz
authorValentin Gosu <valentin.gosu@gmail.com>
Wed, 13 Apr 2016 04:56:47 +0200
changeset 330818 f43c0ea2c7c847ca361375164b3a4c58eb714426
parent 330817 b68333205a825f55ce9f4cfae2b7465869993ae0
child 330819 e0f16e09b67330faa40f8dd491e87963e0d2655e
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1263790
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1263790 - Resource timing initiatorType should be "iframe" instead of "subdocument" r=bz
docshell/base/nsDocShell.cpp
dom/tests/mochitest/general/mochitest.ini
dom/tests/mochitest/general/resource_timing_iframe.html
dom/tests/mochitest/general/resource_timing_main_test.html
dom/tests/mochitest/general/test_resource_timing_frameset.html
testing/web-platform/meta/resource-timing/test_resource_timing.html.ini
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -10943,18 +10943,23 @@ nsDocShell::DoURILoad(nsIURI* aURI,
       props->SetPropertyAsBool(NS_LITERAL_STRING("docshell.newWindowTarget"),
                                true);
     }
   }
 
   nsCOMPtr<nsITimedChannel> timedChannel(do_QueryInterface(channel));
   if (timedChannel) {
     timedChannel->SetTimingEnabled(true);
-    if (IsFrame()) {
-      timedChannel->SetInitiatorType(NS_LITERAL_STRING("subdocument"));
+
+    nsCOMPtr<nsPIDOMWindowOuter> win = GetWindow();
+    if (IsFrame() && win) {
+      nsCOMPtr<Element> frameElement = win->GetFrameElementInternal();
+      if (frameElement) {
+        timedChannel->SetInitiatorType(frameElement->LocalName());
+      }
     }
   }
 
   rv = DoChannelLoad(channel, uriLoader, aBypassClassifier);
 
   //
   // If the channel load failed, we failed and nsIWebProgress just ain't
   // gonna happen.
--- a/dom/tests/mochitest/general/mochitest.ini
+++ b/dom/tests/mochitest/general/mochitest.ini
@@ -46,16 +46,17 @@ support-files =
   storagePermissionsUtils.js
   frameSelectEvents.html
   !/image/test/mochitest/big.png
   !/image/test/mochitest/blue.png
   !/image/test/mochitest/clear.png
   !/image/test/mochitest/damon.jpg
   !/image/test/mochitest/over.png
   !/image/test/mochitest/red.png
+  !/dom/base/test/file_empty.html
 
 [test_497898.html]
 skip-if = ((buildapp == 'mulet' || buildapp == 'b2g') && toolkit != 'gonk') || toolkit == 'android' #Bug 931116, b2g desktop specific, initial triage
 [test_bug504220.html]
 [test_bug628069_1.html]
 skip-if = (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage
 [test_bug628069_2.html]
 [test_bug631440.html]
@@ -130,8 +131,9 @@ skip-if = buildapp == 'b2g' # Bug 118442
 [test_storagePermissionsReject.html]
 skip-if = buildapp == 'b2g' # Bug 1184427 - no SSL certs on b2g
 [test_storagePermissionsLimitForeign.html]
 skip-if = buildapp == 'b2g' # Bug 1184427 - no SSL certs on b2g
 [test_selectevents.html]
 skip-if = buildapp == 'b2g' || buildapp == 'mulet' || toolkit == 'android' # Mouse doesn't select in the same way
 # Disabled on Android, see bug 1230232
 [test_WebKitCSSMatrix.html]
+[test_resource_timing_frameset.html]
--- a/dom/tests/mochitest/general/resource_timing_iframe.html
+++ b/dom/tests/mochitest/general/resource_timing_iframe.html
@@ -30,17 +30,17 @@ function doTest() {
   window.parent.ok(!window.performance.getEntriesByName(
     "http://mochi.test:8888/tests/dom/tests/mochitest/general/resource_timing_iframe.html").length,
     "This iframe should NOT contain itself as an entry");
 
   // Check that there are no iframes added as entries
   var resources = window.performance.getEntriesByType("resource");
   for (var i = 0 ; i < resources.length; i++) {
     var entry = resources[i];
-    if (entry.initiatorType === "subdocument") {
+    if (entry.initiatorType === "iframe") {
       ok(false, "unexpected iframe " + entry.name);
     }
   }
 
   window.parent.iframeTestsCompleted();
 }
 </script>
 <body onLoad="doTest()">
--- a/dom/tests/mochitest/general/resource_timing_main_test.html
+++ b/dom/tests/mochitest/general/resource_timing_main_test.html
@@ -183,17 +183,17 @@ function checkEntries(anEntryList) {
 
   // Check that the entries have the expected initiator type. We can't check
   // the order (the order might depend on the platform the tests are running).
   allResources = {
     "http://mochi.test:8888/tests/SimpleTest/test.css" : "link",
     "http://mochi.test:8888/tests/image/test/mochitest/blue.png" : "img",
     "http://mochi.test:8888/tests/image/test/mochitest/red.png" : "object",
     "http://mochi.test:8888/tests/image/test/mochitest/big.png" : "embed",
-    "http://mochi.test:8888/tests/dom/tests/mochitest/general/resource_timing_iframe.html" : "subdocument"};
+    "http://mochi.test:8888/tests/dom/tests/mochitest/general/resource_timing_iframe.html" : "iframe"};
 
   for (resourceName in allResources) {
     // Check that we have a resource with the specific name.
     namedEntries = window.performance.getEntriesByName(resourceName);
     ok (!!namedEntries && (namedEntries.length == 1),
       "An entry with the name '" + resourceName + "' should be available");
 
     // Double check for the entry name.
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/general/test_resource_timing_frameset.html
@@ -0,0 +1,29 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN">
+<html lang="en">
+  <head>
+    <meta charset="utf-8">
+    <title>browser_frametree_sample_frameset.html</title>
+    <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+
+    <script type="text/javascript">
+      SimpleTest.waitForExplicitFinish();
+      window.addEventListener("load", function() {
+      	var frameEntries = performance.getEntriesByName("http://mochi.test:8888/tests/dom/base/test/file_empty.html");
+
+      	is(frameEntries.length, 2, "correct number");
+      	is(frameEntries[0].initiatorType, "frame", "correct type");
+      	SimpleTest.finish();
+      });
+    </script>
+  </head>
+  <frameset id="frames" rows="50%, 50%">
+    <frame src="http://mochi.test:8888/tests/dom/base/test/file_empty.html">
+    <frame src="http://mochi.test:8888/tests/dom/base/test/file_empty.html">
+  </frameset>
+</html>
deleted file mode 100644
--- a/testing/web-platform/meta/resource-timing/test_resource_timing.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[test_resource_timing.html]
-  type: testharness
-  [PerformanceEntry has correct name, initiatorType, startTime, and duration (iframe)]
-    expected: FAIL