michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests if timing intervals are divided againts seconds when appropriate. michael@0: */ michael@0: michael@0: function test() { michael@0: initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => { michael@0: info("Starting test... "); michael@0: michael@0: let { $all, NetMonitorView } = aMonitor.panelWin; michael@0: let { RequestsMenu } = NetMonitorView; michael@0: michael@0: RequestsMenu.lazyUpdate = false; michael@0: michael@0: waitForNetworkEvents(aMonitor, 2).then(() => { michael@0: let millisecondDivs = $all(".requests-menu-timings-division[division-scale=millisecond]"); michael@0: let secondDivs = $all(".requests-menu-timings-division[division-scale=second]"); michael@0: let minuteDivs = $all(".requests-menu-timings-division[division-scale=minute]"); michael@0: michael@0: info("Number of millisecond divisions: " + millisecondDivs.length); michael@0: info("Number of second divisions: " + secondDivs.length); michael@0: info("Number of minute divisions: " + minuteDivs.length); michael@0: michael@0: for (let div of millisecondDivs) { michael@0: info("Millisecond division: " + div.getAttribute("value")); michael@0: } michael@0: for (let div of secondDivs) { michael@0: info("Second division: " + div.getAttribute("value")); michael@0: } michael@0: for (let div of minuteDivs) { michael@0: info("Minute division: " + div.getAttribute("value")); michael@0: } michael@0: michael@0: is(RequestsMenu.itemCount, 2, michael@0: "There should be only two requests made."); michael@0: michael@0: let firstRequest = RequestsMenu.getItemAtIndex(0); michael@0: let lastRequest = RequestsMenu.getItemAtIndex(1); michael@0: michael@0: info("First request happened at: " + michael@0: firstRequest.attachment.responseHeaders.headers.find(e => e.name == "Date").value); michael@0: info("Last request happened at: " + michael@0: lastRequest.attachment.responseHeaders.headers.find(e => e.name == "Date").value); michael@0: michael@0: ok(secondDivs.length, michael@0: "There should be at least one division on the seconds time scale."); michael@0: ok(secondDivs[0].getAttribute("value").match(/\d+\.\d{2}\s\w+/), michael@0: "The division on the seconds time scale looks legit."); michael@0: michael@0: teardown(aMonitor).then(finish); michael@0: }); michael@0: michael@0: aDebuggee.get(Math.random(), () => { michael@0: // Timeout needed for having enough divisions on the time scale. michael@0: setTimeout(() => { michael@0: aDebuggee.get(Math.random(), () => { michael@0: // Done. michael@0: }); michael@0: }, 3000); michael@0: }); michael@0: }); michael@0: }