diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/netmonitor/test/browser_net_throttle.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/netmonitor/test/browser_net_throttle.js')
-rw-r--r-- | devtools/client/netmonitor/test/browser_net_throttle.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/devtools/client/netmonitor/test/browser_net_throttle.js b/devtools/client/netmonitor/test/browser_net_throttle.js new file mode 100644 index 000000000..c1e7723b8 --- /dev/null +++ b/devtools/client/netmonitor/test/browser_net_throttle.js @@ -0,0 +1,57 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Network throttling integration test. + +"use strict"; + +add_task(function* () { + yield throttleTest(true); + yield throttleTest(false); +}); + +function* throttleTest(actuallyThrottle) { + requestLongerTimeout(2); + + let { monitor } = yield initNetMonitor(SIMPLE_URL); + const {ACTIVITY_TYPE, EVENTS, NetMonitorController, NetMonitorView} = monitor.panelWin; + + info("Starting test... (actuallyThrottle = " + actuallyThrottle + ")"); + + // When throttling, must be smaller than the length of the content + // of SIMPLE_URL in bytes. + const size = actuallyThrottle ? 200 : 0; + + const request = { + "NetworkMonitor.throttleData": { + roundTripTimeMean: 0, + roundTripTimeMax: 0, + downloadBPSMean: size, + downloadBPSMax: size, + uploadBPSMean: 10000, + uploadBPSMax: 10000, + }, + }; + let client = monitor._controller.webConsoleClient; + + info("sending throttle request"); + let deferred = promise.defer(); + client.setPreferences(request, response => { + deferred.resolve(response); + }); + yield deferred.promise; + + let eventPromise = monitor.panelWin.once(EVENTS.RECEIVED_EVENT_TIMINGS); + yield NetMonitorController.triggerActivity(ACTIVITY_TYPE.RELOAD.WITH_CACHE_DISABLED); + yield eventPromise; + + let requestItem = NetMonitorView.RequestsMenu.getItemAtIndex(0); + const reportedOneSecond = requestItem.attachment.eventTimings.timings.receive > 1000; + if (actuallyThrottle) { + ok(reportedOneSecond, "download reported as taking more than one second"); + } else { + ok(!reportedOneSecond, "download reported as taking less than one second"); + } + + yield teardown(monitor); +} |