Bug 737433 - Send the referer for embedded src="" streams for plugins (and make them part of the correct load group while we're at it!), r=josh
authorBenjamin Smedberg <benjamin@smedbergs.us>
Thu, 29 Mar 2012 12:53:31 -0400
changeset 93950 81975c3ca49499e1aedab5db96ef933668b6e3da
parent 93949 c85e435f8041567403c1ef8d3044568cdc901a3e
child 93951 17da1d57097d7b2d5112156c9cf8404d31f1c49b
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjosh
bugs737433
milestone14.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 737433 - Send the referer for embedded src="" streams for plugins (and make them part of the correct load group while we're at it!), r=josh
dom/plugins/base/nsPluginHost.cpp
dom/plugins/test/mochitest/Makefile.in
dom/plugins/test/mochitest/plugin-stream-referer.sjs
dom/plugins/test/mochitest/test_pluginstream_src_referer.html
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -1092,17 +1092,17 @@ nsPluginHost::InstantiateEmbeddedPlugin(
     instanceOwner->CallSetWindow();
 
     // create an initial stream with data
     // don't make the stream if it's a java applet or we don't have SRC or DATA attribute
     // no need to check for "data" as it would have been converted to "src"
     const char *value;
     bool havedata = NS_SUCCEEDED(pti->GetAttribute("SRC", &value));
     if (havedata && !isJava && bCanHandleInternally && !aContent->SrcStreamLoading()) {
-      NewEmbeddedPluginStream(aURL, nsnull, instance.get());
+      NewEmbeddedPluginStream(aURL, aContent, instance.get());
     }
   }
 
   // At this point we consider instantiation to be successful. Do not return an error.
   instanceOwner.forget(aOwner);
 
 #ifdef PLUGIN_LOGGING
   nsCAutoString urlSpec2;
@@ -3327,18 +3327,16 @@ nsresult nsPluginHost::NewEmbeddedPlugin
   return rv;
 }
 
 // Called by InstantiateEmbeddedPlugin()
 nsresult nsPluginHost::NewEmbeddedPluginStream(nsIURI* aURL,
                                                nsObjectLoadingContent *aContent,
                                                nsNPAPIPluginInstance* aInstance)
 {
-  NS_ASSERTION(!aContent || !aInstance, "Don't pass both content and an instance to NewEmbeddedPluginStream!");
-
   nsCOMPtr<nsIStreamListener> listener;
   nsresult rv = NewEmbeddedPluginStreamListener(aURL, aContent, aInstance,
                                                 getter_AddRefs(listener));
   if (NS_SUCCEEDED(rv)) {
     nsCOMPtr<nsIDocument> doc;
     nsCOMPtr<nsILoadGroup> loadGroup;
     if (aContent) {
       nsCOMPtr<nsIContent> aIContent = do_QueryInterface(static_cast<nsIImageLoadingContent*>(aContent));
--- a/dom/plugins/test/mochitest/Makefile.in
+++ b/dom/plugins/test/mochitest/Makefile.in
@@ -105,16 +105,17 @@ include $(topsrcdir)/config/rules.mk
   test_NPPVpluginWantsAllNetworkStreams.html \
   test_npruntime_npnsetexception.html \
   test_NPNVdocumentOrigin.html \
   test_instance_re-parent.html \
   test_instance_unparent1.html \
   test_instance_unparent2.html \
   test_instance_unparent3.html \
   test_pluginstream_referer.html \
+  test_pluginstream_src_referer.html \
   plugin-stream-referer.sjs \
   test_src_url_change.html \
   $(NULL)
 
 #  test_plugin_scroll_painting.html \ bug 596491
 
 ifeq ($(OS_ARCH),WINNT)
 _MOCHITEST_FILES += \
--- a/dom/plugins/test/mochitest/plugin-stream-referer.sjs
+++ b/dom/plugins/test/mochitest/plugin-stream-referer.sjs
@@ -1,10 +1,12 @@
 function handleRequest(request, response)
 {
   response.setHeader('Content-Type', 'text/plain', false);
+  response.setHeader('Cache-Control', 'no-cache', false);
+  response.setHeader('Content-Type', 'application/x-test', false);
   if (request.hasHeader('Referer')) {
     response.write('Referer found: ' + request.getHeader('Referer'));
   }
   else {
     response.write('No Referer found');
   }
 }
new file mode 100644
--- /dev/null
+++ b/dom/plugins/test/mochitest/test_pluginstream_src_referer.html
@@ -0,0 +1,28 @@
+<head>
+  <title>Do plugin stream src requests send the Referer header correctly?</title>
+  <script type="application/javascript"
+	  src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" 
+        href="/tests/SimpleTest/test.css" />
+
+<body>
+  <p id="display"></p>
+
+  <script class="testbody" type="application/javascript">
+  SimpleTest.waitForExplicitFinish();
+
+  function frameLoaded() {
+    var testframe = document.getElementById('pluginframe');
+    var content = testframe.contentDocument.body.innerHTML;
+    if (!content.length)
+      return;
+
+    is(content, "Referer found: " + window.location);
+    SimpleTest.finish();
+  }
+  </script>
+
+  <iframe name="pluginframe" id="pluginframe" onload="frameLoaded()"></iframe>
+
+  <embed id="plugin" type="application/x-test" src="plugin-stream-referer.sjs" width="200" height="200" frame="pluginframe"></embed>
+