Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * Tests if timing intervals are divided againts seconds when appropriate. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => { |
michael@0 | 10 | info("Starting test... "); |
michael@0 | 11 | |
michael@0 | 12 | let { $all, NetMonitorView } = aMonitor.panelWin; |
michael@0 | 13 | let { RequestsMenu } = NetMonitorView; |
michael@0 | 14 | |
michael@0 | 15 | RequestsMenu.lazyUpdate = false; |
michael@0 | 16 | |
michael@0 | 17 | waitForNetworkEvents(aMonitor, 2).then(() => { |
michael@0 | 18 | let millisecondDivs = $all(".requests-menu-timings-division[division-scale=millisecond]"); |
michael@0 | 19 | let secondDivs = $all(".requests-menu-timings-division[division-scale=second]"); |
michael@0 | 20 | let minuteDivs = $all(".requests-menu-timings-division[division-scale=minute]"); |
michael@0 | 21 | |
michael@0 | 22 | info("Number of millisecond divisions: " + millisecondDivs.length); |
michael@0 | 23 | info("Number of second divisions: " + secondDivs.length); |
michael@0 | 24 | info("Number of minute divisions: " + minuteDivs.length); |
michael@0 | 25 | |
michael@0 | 26 | for (let div of millisecondDivs) { |
michael@0 | 27 | info("Millisecond division: " + div.getAttribute("value")); |
michael@0 | 28 | } |
michael@0 | 29 | for (let div of secondDivs) { |
michael@0 | 30 | info("Second division: " + div.getAttribute("value")); |
michael@0 | 31 | } |
michael@0 | 32 | for (let div of minuteDivs) { |
michael@0 | 33 | info("Minute division: " + div.getAttribute("value")); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | is(RequestsMenu.itemCount, 2, |
michael@0 | 37 | "There should be only two requests made."); |
michael@0 | 38 | |
michael@0 | 39 | let firstRequest = RequestsMenu.getItemAtIndex(0); |
michael@0 | 40 | let lastRequest = RequestsMenu.getItemAtIndex(1); |
michael@0 | 41 | |
michael@0 | 42 | info("First request happened at: " + |
michael@0 | 43 | firstRequest.attachment.responseHeaders.headers.find(e => e.name == "Date").value); |
michael@0 | 44 | info("Last request happened at: " + |
michael@0 | 45 | lastRequest.attachment.responseHeaders.headers.find(e => e.name == "Date").value); |
michael@0 | 46 | |
michael@0 | 47 | ok(secondDivs.length, |
michael@0 | 48 | "There should be at least one division on the seconds time scale."); |
michael@0 | 49 | ok(secondDivs[0].getAttribute("value").match(/\d+\.\d{2}\s\w+/), |
michael@0 | 50 | "The division on the seconds time scale looks legit."); |
michael@0 | 51 | |
michael@0 | 52 | teardown(aMonitor).then(finish); |
michael@0 | 53 | }); |
michael@0 | 54 | |
michael@0 | 55 | aDebuggee.get(Math.random(), () => { |
michael@0 | 56 | // Timeout needed for having enough divisions on the time scale. |
michael@0 | 57 | setTimeout(() => { |
michael@0 | 58 | aDebuggee.get(Math.random(), () => { |
michael@0 | 59 | // Done. |
michael@0 | 60 | }); |
michael@0 | 61 | }, 3000); |
michael@0 | 62 | }); |
michael@0 | 63 | }); |
michael@0 | 64 | } |