mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1170190 - Part 3: Add tests for the e10s case too; r=mayhemer
This commit is contained in:
parent
cd895c94f2
commit
ad51310cc1
@ -2903,5 +2903,12 @@ HttpChannelChild::ShouldInterceptURI(nsIURI* aURI,
|
|||||||
return ShouldIntercept(upgradedURI ? upgradedURI.get() : aURI);
|
return ShouldIntercept(upgradedURI ? upgradedURI.get() : aURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mozilla::ipc::IPCResult
|
||||||
|
HttpChannelChild::RecvSetPriority(const uint16_t& aPriority)
|
||||||
|
{
|
||||||
|
mPriority = aPriority;
|
||||||
|
return IPC_OK();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace net
|
} // namespace net
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
@ -155,6 +155,8 @@ protected:
|
|||||||
mozilla::ipc::IPCResult RecvIssueDeprecationWarning(const uint32_t& warning,
|
mozilla::ipc::IPCResult RecvIssueDeprecationWarning(const uint32_t& warning,
|
||||||
const bool& asError) override;
|
const bool& asError) override;
|
||||||
|
|
||||||
|
mozilla::ipc::IPCResult RecvSetPriority(const uint16_t& aPriority) override;
|
||||||
|
|
||||||
bool GetAssociatedContentSecurity(nsIAssociatedContentSecurity** res = nullptr);
|
bool GetAssociatedContentSecurity(nsIAssociatedContentSecurity** res = nullptr);
|
||||||
virtual void DoNotifyListenerCleanup() override;
|
virtual void DoNotifyListenerCleanup() override;
|
||||||
|
|
||||||
|
@ -1827,5 +1827,13 @@ HttpChannelParent::IssueWarning(uint32_t aWarning, bool aAsError)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
HttpChannelParent::DoSendSetPriority(int16_t aValue)
|
||||||
|
{
|
||||||
|
if (!mIPCClosed) {
|
||||||
|
Unused << SendSetPriority(aValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace net
|
} // namespace net
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
@ -99,6 +99,9 @@ public:
|
|||||||
nsresult OpenAlternativeOutputStream(const nsACString & type, nsIOutputStream * *_retval);
|
nsresult OpenAlternativeOutputStream(const nsACString & type, nsIOutputStream * *_retval);
|
||||||
|
|
||||||
void InvokeAsyncOpen(nsresult rv);
|
void InvokeAsyncOpen(nsresult rv);
|
||||||
|
|
||||||
|
// Calls SendSetPriority if mIPCClosed is false.
|
||||||
|
void DoSendSetPriority(int16_t aValue);
|
||||||
protected:
|
protected:
|
||||||
// used to connect redirected-to channel in parent with just created
|
// used to connect redirected-to channel in parent with just created
|
||||||
// ChildChannel. Used during redirects.
|
// ChildChannel. Used during redirects.
|
||||||
|
@ -31,7 +31,6 @@ parent:
|
|||||||
// Note: channels are opened during construction, so no open method here:
|
// Note: channels are opened during construction, so no open method here:
|
||||||
// see PNecko.ipdl
|
// see PNecko.ipdl
|
||||||
|
|
||||||
async SetPriority(uint16_t priority);
|
|
||||||
async SetClassOfService(uint32_t cos);
|
async SetClassOfService(uint32_t cos);
|
||||||
|
|
||||||
async SetCacheTokenCachedCharset(nsCString charset);
|
async SetCacheTokenCachedCharset(nsCString charset);
|
||||||
@ -177,6 +176,8 @@ both:
|
|||||||
// after that. When receiving this message, the child will call
|
// after that. When receiving this message, the child will call
|
||||||
// Send__delete__() and complete the steps required to finish the redirect.
|
// Send__delete__() and complete the steps required to finish the redirect.
|
||||||
async FinishInterceptedRedirect();
|
async FinishInterceptedRedirect();
|
||||||
|
|
||||||
|
async SetPriority(uint16_t priority);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,6 +102,7 @@
|
|||||||
#include "nsMixedContentBlocker.h"
|
#include "nsMixedContentBlocker.h"
|
||||||
#include "HSTSPrimerListener.h"
|
#include "HSTSPrimerListener.h"
|
||||||
#include "CacheStorageService.h"
|
#include "CacheStorageService.h"
|
||||||
|
#include "HttpChannelParent.h"
|
||||||
|
|
||||||
#ifdef MOZ_TASK_TRACER
|
#ifdef MOZ_TASK_TRACER
|
||||||
#include "GeckoTaskTracer.h"
|
#include "GeckoTaskTracer.h"
|
||||||
@ -6170,6 +6171,16 @@ nsHttpChannel::SetPriority(int32_t value)
|
|||||||
mPriority = newValue;
|
mPriority = newValue;
|
||||||
if (mTransaction)
|
if (mTransaction)
|
||||||
gHttpHandler->RescheduleTransaction(mTransaction, mPriority);
|
gHttpHandler->RescheduleTransaction(mTransaction, mPriority);
|
||||||
|
|
||||||
|
// If this channel is the real channel for an e10s channel, notify the
|
||||||
|
// child side about the priority change as well.
|
||||||
|
nsCOMPtr<nsIParentChannel> parentChannel;
|
||||||
|
NS_QueryNotificationCallbacks(this, parentChannel);
|
||||||
|
RefPtr<HttpChannelParent> httpParent = do_QueryObject(parentChannel);
|
||||||
|
if (httpParent) {
|
||||||
|
httpParent->DoSendSetPriority(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,26 @@ Cu.import("resource://testing-common/UrlClassifierTestUtils.jsm");
|
|||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
Cu.import("resource://testing-common/httpd.js");
|
Cu.import("resource://testing-common/httpd.js");
|
||||||
|
|
||||||
do_get_profile();
|
// This test supports both e10s and non-e10s mode. In non-e10s mode, this test
|
||||||
|
// drives itself by creating a profile directory, setting up the URL classifier
|
||||||
|
// test tables and adjusting the prefs which are necessary to do the testing.
|
||||||
|
// In e10s mode however, some of these operations such as creating a profile
|
||||||
|
// directory, setting up the URL classifier test tables and setting prefs
|
||||||
|
// aren't supported in the content process, so we split the test into two
|
||||||
|
// parts, the part testing the normal priority case by setting both prefs to
|
||||||
|
// false (test_trackingProtection_annotateChannels_wrap1.js), and the part
|
||||||
|
// testing the lowest priority case by setting both prefs to true
|
||||||
|
// (test_trackingProtection_annotateChannels_wrap2.js). These wrapper scripts
|
||||||
|
// are also in charge of creating the profile directory and setting up the URL
|
||||||
|
// classifier test tables.
|
||||||
|
//
|
||||||
|
// Below where we need to take different actions based on the process type we're
|
||||||
|
// in, we use runtime.processType to take the correct actions.
|
||||||
|
|
||||||
|
const runtime = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime);
|
||||||
|
if (runtime.processType == runtime.PROCESS_TYPE_DEFAULT) {
|
||||||
|
do_get_profile();
|
||||||
|
}
|
||||||
|
|
||||||
var Ci = Components.interfaces;
|
var Ci = Components.interfaces;
|
||||||
|
|
||||||
@ -31,6 +50,14 @@ var httpServer;
|
|||||||
var normalOrigin, trackingOrigin;
|
var normalOrigin, trackingOrigin;
|
||||||
var testPriorityMap;
|
var testPriorityMap;
|
||||||
var currentTest;
|
var currentTest;
|
||||||
|
// When this test is running in e10s mode, the parent process is in charge of
|
||||||
|
// setting the prefs for us, so here we merely read our prefs, and if they have
|
||||||
|
// been set we skip the normal priority test and only test the lowest priority
|
||||||
|
// case, and if it they have not been set we skip the lowest priority test and
|
||||||
|
// only test the normal priority case.
|
||||||
|
// In non-e10s mode, both of these will remain false and we adjust the prefs
|
||||||
|
// ourselves and test both of the cases in one go.
|
||||||
|
var skipNormalPriority = false, skipLowestPriority = false;
|
||||||
|
|
||||||
function setup_test() {
|
function setup_test() {
|
||||||
httpServer = new HttpServer();
|
httpServer = new HttpServer();
|
||||||
@ -40,6 +67,15 @@ function setup_test() {
|
|||||||
normalOrigin = "http://localhost:" + httpServer.identity.primaryPort;
|
normalOrigin = "http://localhost:" + httpServer.identity.primaryPort;
|
||||||
trackingOrigin = "http://tracking.example.com:" + httpServer.identity.primaryPort;
|
trackingOrigin = "http://tracking.example.com:" + httpServer.identity.primaryPort;
|
||||||
|
|
||||||
|
if (runtime.processType == runtime.PROCESS_TYPE_CONTENT) {
|
||||||
|
if (Services.prefs.getBoolPref("privacy.trackingprotection.annotate_channels") &&
|
||||||
|
Services.prefs.getBoolPref("privacy.trackingprotection.lower_network_priority")) {
|
||||||
|
skipNormalPriority = true;
|
||||||
|
} else {
|
||||||
|
skipLowestPriority = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
runTests();
|
runTests();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,15 +109,25 @@ var tests =[
|
|||||||
|
|
||||||
// Add the test table into tracking protection table.
|
// Add the test table into tracking protection table.
|
||||||
function addTestTrackers() {
|
function addTestTrackers() {
|
||||||
UrlClassifierTestUtils.addTestTrackers().then(() => {
|
if (runtime.processType == runtime.PROCESS_TYPE_DEFAULT) {
|
||||||
|
UrlClassifierTestUtils.addTestTrackers().then(() => {
|
||||||
|
runTests();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
runTests();
|
runTests();
|
||||||
});
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// With the pref off, the priority of channel should be normal.
|
// With the pref off, the priority of channel should be normal.
|
||||||
function setupNormalPriority() {
|
function setupNormalPriority() {
|
||||||
Services.prefs.setBoolPref("privacy.trackingprotection.annotate_channels", false);
|
if (skipNormalPriority) {
|
||||||
Services.prefs.setBoolPref("privacy.trackingprotection.lower_network_priority", false);
|
runTests();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (runtime.processType == runtime.PROCESS_TYPE_DEFAULT) {
|
||||||
|
Services.prefs.setBoolPref("privacy.trackingprotection.annotate_channels", false);
|
||||||
|
Services.prefs.setBoolPref("privacy.trackingprotection.lower_network_priority", false);
|
||||||
|
}
|
||||||
testPriorityMap = [
|
testPriorityMap = [
|
||||||
{
|
{
|
||||||
path: normalOrigin + "/innocent.css",
|
path: normalOrigin + "/innocent.css",
|
||||||
@ -104,14 +150,22 @@ var tests =[
|
|||||||
expectedPriority: Ci.nsISupportsPriority.PRIORITY_NORMAL
|
expectedPriority: Ci.nsISupportsPriority.PRIORITY_NORMAL
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
// We add the doPriorityTest test here so that it only gets injected in the
|
||||||
|
// test list if we're not skipping over this test.
|
||||||
|
tests.unshift(doPriorityTest);
|
||||||
runTests();
|
runTests();
|
||||||
},
|
},
|
||||||
doPriorityTest,
|
|
||||||
|
|
||||||
// With the pref on, the priority of channel should be lowest.
|
// With the pref on, the priority of channel should be lowest.
|
||||||
function setupLowestPriority() {
|
function setupLowestPriority() {
|
||||||
Services.prefs.setBoolPref("privacy.trackingprotection.annotate_channels", true);
|
if (skipLowestPriority) {
|
||||||
Services.prefs.setBoolPref("privacy.trackingprotection.lower_network_priority", true);
|
runTests();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (runtime.processType == runtime.PROCESS_TYPE_DEFAULT) {
|
||||||
|
Services.prefs.setBoolPref("privacy.trackingprotection.annotate_channels", true);
|
||||||
|
Services.prefs.setBoolPref("privacy.trackingprotection.lower_network_priority", true);
|
||||||
|
}
|
||||||
testPriorityMap = [
|
testPriorityMap = [
|
||||||
{
|
{
|
||||||
path: normalOrigin + "/innocent.css",
|
path: normalOrigin + "/innocent.css",
|
||||||
@ -134,13 +188,17 @@ var tests =[
|
|||||||
expectedPriority: Ci.nsISupportsPriority.PRIORITY_LOWEST
|
expectedPriority: Ci.nsISupportsPriority.PRIORITY_LOWEST
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
// We add the doPriorityTest test here so that it only gets injected in the
|
||||||
|
// test list if we're not skipping over this test.
|
||||||
|
tests.unshift(doPriorityTest);
|
||||||
runTests();
|
runTests();
|
||||||
},
|
},
|
||||||
doPriorityTest,
|
|
||||||
|
|
||||||
function cleanUp() {
|
function cleanUp() {
|
||||||
httpServer.stop(do_test_finished);
|
httpServer.stop(do_test_finished);
|
||||||
UrlClassifierTestUtils.cleanupTestTrackers();
|
if (runtime.processType == runtime.PROCESS_TYPE_DEFAULT) {
|
||||||
|
UrlClassifierTestUtils.cleanupTestTrackers();
|
||||||
|
}
|
||||||
runTests();
|
runTests();
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
|
Cu.import("resource://testing-common/UrlClassifierTestUtils.jsm");
|
||||||
|
|
||||||
|
function run_test() {
|
||||||
|
do_get_profile();
|
||||||
|
Services.prefs.setBoolPref("privacy.trackingprotection.annotate_channels", false);
|
||||||
|
Services.prefs.setBoolPref("privacy.trackingprotection.lower_network_priority", false);
|
||||||
|
do_test_pending();
|
||||||
|
UrlClassifierTestUtils.addTestTrackers().then(() => {
|
||||||
|
run_test_in_child("../unit/test_trackingProtection_annotateChannels.js", () => {
|
||||||
|
UrlClassifierTestUtils.cleanupTestTrackers();
|
||||||
|
do_test_finished();
|
||||||
|
});
|
||||||
|
do_test_finished();
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
|
Cu.import("resource://testing-common/UrlClassifierTestUtils.jsm");
|
||||||
|
|
||||||
|
function run_test() {
|
||||||
|
do_get_profile();
|
||||||
|
Services.prefs.setBoolPref("privacy.trackingprotection.annotate_channels", true);
|
||||||
|
Services.prefs.setBoolPref("privacy.trackingprotection.lower_network_priority", true);
|
||||||
|
do_test_pending();
|
||||||
|
UrlClassifierTestUtils.addTestTrackers().then(() => {
|
||||||
|
run_test_in_child("../unit/test_trackingProtection_annotateChannels.js", () => {
|
||||||
|
UrlClassifierTestUtils.cleanupTestTrackers();
|
||||||
|
do_test_finished();
|
||||||
|
});
|
||||||
|
do_test_finished();
|
||||||
|
});
|
||||||
|
}
|
@ -38,6 +38,7 @@ support-files =
|
|||||||
!/netwerk/test/unit/test_resumable_channel.js
|
!/netwerk/test/unit/test_resumable_channel.js
|
||||||
!/netwerk/test/unit/test_simple.js
|
!/netwerk/test/unit/test_simple.js
|
||||||
!/netwerk/test/unit/test_synthesized_response.js
|
!/netwerk/test/unit/test_synthesized_response.js
|
||||||
|
!/netwerk/test/unit/test_trackingProtection_annotateChannels.js
|
||||||
!/netwerk/test/unit/test_xmlhttprequest.js
|
!/netwerk/test/unit/test_xmlhttprequest.js
|
||||||
!/netwerk/test/unit/head_channels.js
|
!/netwerk/test/unit/head_channels.js
|
||||||
!/netwerk/test/unit/head_cache2.js
|
!/netwerk/test/unit/head_cache2.js
|
||||||
@ -97,3 +98,5 @@ skip-if = true
|
|||||||
[test_alt-data_stream_wrap.js]
|
[test_alt-data_stream_wrap.js]
|
||||||
[test_original_sent_received_head_wrap.js]
|
[test_original_sent_received_head_wrap.js]
|
||||||
[test_channel_id.js]
|
[test_channel_id.js]
|
||||||
|
[test_trackingProtection_annotateChannels_wrap1.js]
|
||||||
|
[test_trackingProtection_annotateChannels_wrap2.js]
|
||||||
|
Loading…
Reference in New Issue
Block a user