mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-12 02:31:41 +00:00
Bug 1260498 - Make test_rel_preconnect work in e10s mode. r=mcmanus
MozReview-Commit-ID: 3PGA2N73foH --HG-- extra : rebase_source : b3837c38a8bf1847d207ebfc2d3ce60ddf826a01
This commit is contained in:
parent
5468e259d5
commit
ccbf76c675
@ -391,6 +391,17 @@ NeckoChild::RecvAppOfflineStatus(const uint32_t& aId, const bool& aOffline)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
NeckoChild::RecvSpeculativeConnectRequest(const nsCString& aNotificationData)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obsService = services::GetObserverService();
|
||||
if (obsService) {
|
||||
obsService->NotifyObservers(nullptr, "speculative-connect-request",
|
||||
NS_ConvertUTF8toUTF16(aNotificationData).get());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -87,6 +87,8 @@ protected:
|
||||
/* Predictor Messsages */
|
||||
virtual bool RecvPredOnPredictPreconnect(const URIParams& aURI) override;
|
||||
virtual bool RecvPredOnPredictDNS(const URIParams& aURI) override;
|
||||
|
||||
virtual bool RecvSpeculativeConnectRequest(const nsCString& aNotificationData) override;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -94,6 +94,7 @@ NeckoParent::NeckoParent()
|
||||
|
||||
NeckoParent::~NeckoParent()
|
||||
{
|
||||
gNeckoParent = nullptr;
|
||||
if (mObserver) {
|
||||
mObserver->RemoveObserver();
|
||||
}
|
||||
|
@ -129,6 +129,8 @@ child:
|
||||
async PredOnPredictPreconnect(URIParams uri);
|
||||
async PredOnPredictDNS(URIParams uri);
|
||||
|
||||
async SpeculativeConnectRequest(nsCString notificationData);
|
||||
|
||||
both:
|
||||
// Actually we need PTCPSocket() for parent. But ipdl disallows us having different
|
||||
// signatures on parent and child. So when constructing the parent side object, we just
|
||||
|
@ -56,8 +56,10 @@
|
||||
#include "nsIOService.h"
|
||||
|
||||
#include "mozilla/net/NeckoChild.h"
|
||||
#include "mozilla/net/NeckoParent.h"
|
||||
#include "mozilla/ipc/URIUtils.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
#if defined(XP_UNIX)
|
||||
#include <sys/utsname.h>
|
||||
@ -2175,6 +2177,9 @@ nsHttpHandler::SpeculativeConnectInternal(nsIURI *aURI,
|
||||
obsService->NotifyObservers(nullptr,
|
||||
"speculative-connect-request",
|
||||
NS_ConvertUTF8toUTF16(spec).get());
|
||||
if (!IsNeckoChild() && gNeckoParent) {
|
||||
Unused << gNeckoParent->SendSpeculativeConnectRequest(spec);
|
||||
}
|
||||
}
|
||||
|
||||
nsISiteSecurityService* sss = gHttpHandler->GetSSService();
|
||||
|
@ -19,7 +19,6 @@ support-files =
|
||||
[test_arraybufferinputstream.html]
|
||||
[test_partially_cached_content.html]
|
||||
[test_rel_preconnect.html]
|
||||
skip-if = e10s
|
||||
[test_uri_scheme.html]
|
||||
[test_user_agent_overrides.html]
|
||||
skip-if = e10s
|
||||
|
@ -11,44 +11,18 @@
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
const Cc = SpecialPowers.Cc, Ci = SpecialPowers.Ci, Cr = SpecialPowers.Cr;
|
||||
var srv;
|
||||
|
||||
function TestServer1(nextTest) {
|
||||
this.listener= Cc["@mozilla.org/network/server-socket;1"]
|
||||
.createInstance(Ci.nsIServerSocket);
|
||||
this.listener.init(-1, true, -1);
|
||||
this.listener.asyncListen(SpecialPowers.wrapCallbackObject(this));
|
||||
this.nextTest = nextTest;
|
||||
}
|
||||
|
||||
TestServer1.prototype = {
|
||||
QueryInterface: function(iid) {
|
||||
iid = SpecialPowers.wrap(iid);
|
||||
if (iid.equals(Ci.nsIServerSocketListener) ||
|
||||
iid.equals(Ci.nsISupports))
|
||||
return this;
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
},
|
||||
onSocketAccepted: function(socket, trans) {
|
||||
try { socket.close(); } catch(e) {}
|
||||
try { trans.close(); } catch(e) {}
|
||||
},
|
||||
onStopListening: function(socket) {}
|
||||
};
|
||||
|
||||
var remainder = 4;
|
||||
var observer;
|
||||
|
||||
function doTest()
|
||||
{
|
||||
srv = new TestServer1();
|
||||
SpecialPowers.setBoolPref("network.http.debug-observations", true);
|
||||
|
||||
observer = SpecialPowers.wrapCallback(function(subject, topic, data) {
|
||||
remainder--;
|
||||
ok(true, "observed remainder = " + remainder);
|
||||
if (!remainder) {
|
||||
srv.listener.close();
|
||||
SpecialPowers.removeObserver(observer, "speculative-connect-request");
|
||||
SpecialPowers.setBoolPref("network.http.debug-observations", false);
|
||||
SimpleTest.finish();
|
||||
@ -60,18 +34,18 @@ function doTest()
|
||||
// and crossOrigin=anonymous
|
||||
var link = document.createElement("link");
|
||||
link.rel = "preconnect";
|
||||
link.href = "//localhost:" + srv.listener.port;
|
||||
link.href = "//localhost:8888";
|
||||
document.head.appendChild(link);
|
||||
link = document.createElement("link");
|
||||
link.rel = "preconnect";
|
||||
link.href = "//localhost:" + srv.listener.port;
|
||||
link.href = "//localhost:8888";
|
||||
link.crossOrigin = "anonymous";
|
||||
document.head.appendChild(link);
|
||||
|
||||
// test the http link response header - the test contains both a
|
||||
// normal and anonymous preconnect link header
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.src = 'rel_preconnect.sjs?//localhost:' + srv.listener.port;
|
||||
iframe.src = 'rel_preconnect.sjs?//localhost:8888';
|
||||
|
||||
document.body.appendChild(iframe);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user