Bug 1135764 - Make sure XSLT transform results have a document timeline so things like transitions will work. r=smaug, a=lmandel
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 03 Mar 2015 07:12:00 -0500
changeset 250241 5f1674957fe4
parent 250240 ea414ee32231
child 250242 610aae9b5e36
push id4524
push userryanvm@gmail.com
push date2015-03-04 18:49 +0000
treeherdermozilla-beta@666a1aafecfd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, lmandel
bugs1135764
milestone37.0
Bug 1135764 - Make sure XSLT transform results have a document timeline so things like transitions will work. r=smaug, a=lmandel
dom/xslt/tests/mochitest/file_bug1135764.xml
dom/xslt/tests/mochitest/file_bug1135764.xsl
dom/xslt/tests/mochitest/mochitest.ini
dom/xslt/tests/mochitest/test_bug1135764.html
layout/base/nsDocumentViewer.cpp
new file mode 100644
--- /dev/null
+++ b/dom/xslt/tests/mochitest/file_bug1135764.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="file_bug1135764.xsl"?>
+<root/>
new file mode 100644
--- /dev/null
+++ b/dom/xslt/tests/mochitest/file_bug1135764.xsl
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:output method="html"
+            indent="yes"
+            version="5.0"
+            doctype-system="about:legacy-compat"/>
+
+<xsl:template match="/">
+<html>
+<head>
+</head>
+  <body>
+    Some text
+  </body>
+</html>
+</xsl:template>
+
+</xsl:stylesheet>
--- a/dom/xslt/tests/mochitest/mochitest.ini
+++ b/dom/xslt/tests/mochitest/mochitest.ini
@@ -9,10 +9,12 @@
 [test_bug511487.html]
 [test_bug551412.html]
 [test_bug551654.html]
 [test_bug566629.html]
 [test_bug566629.xhtml]
 [test_bug603159.html]
 [test_bug616774.html]
 [test_bug667315.html]
+[test_bug1135764.html]
+support-files = file_bug1135764.xml file_bug1135764.xsl
 [test_exslt_regex.html]
 [test_parameter.html]
new file mode 100644
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_bug1135764.html
@@ -0,0 +1,45 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1135764
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 1135764</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript">
+
+  /** Test for Bug 1135764 **/
+  SimpleTest.waitForExplicitFinish();
+  var counter = 0;
+  var startTimelineValue;
+
+  function waitATick() {
+    ++counter;
+    if (counter == 1) {
+      frames[0].requestAnimationFrame(waitATick);
+      return;
+    }
+    ok(frames[0].document.timeline.currentTime !== startTimelineValue,
+       "The timeline in an XSLT-transformed document should still advance");
+    SimpleTest.finish();
+  }
+  addLoadEvent(function() {
+    startTimelineValue = frames[0].document.timeline.currentTime;
+    frames[0].requestAnimationFrame(waitATick);
+  })
+  </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1135764">Mozilla Bug 1135764</a>
+<p id="display">
+  <iframe src="file_bug1135764.xml"></iframe>
+</p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -1780,16 +1780,23 @@ nsDocumentViewer::SetDocumentInternal(ns
                                         bool aForceReuseInnerWindow)
 {
   MOZ_ASSERT(aDocument);
 
   // Set new container
   aDocument->SetContainer(mContainer);
 
   if (mDocument != aDocument) {
+    if (aForceReuseInnerWindow) {
+      // Transfer the navigation timing information to the new document, since
+      // we're keeping the same inner and hence should really have the same
+      // timing information.
+      aDocument->SetNavigationTiming(mDocument->GetNavigationTiming());
+    }
+
     if (mDocument->IsStaticDocument()) {
       mDocument->SetScriptGlobalObject(nullptr);
       mDocument->Destroy();
     }
 
     // Clear the list of old child docshells. Child docshells for the new
     // document will be constructed as frames are created.
     if (!aDocument->IsStaticDocument()) {