diff options
Diffstat (limited to 'browser/devtools/netmonitor/test')
102 files changed, 0 insertions, 9055 deletions
diff --git a/browser/devtools/netmonitor/test/browser.ini b/browser/devtools/netmonitor/test/browser.ini deleted file mode 100644 index 297e87ce9..000000000 --- a/browser/devtools/netmonitor/test/browser.ini +++ /dev/null @@ -1,109 +0,0 @@ -[DEFAULT] -subsuite = devtools -support-files = - head.js - html_content-type-test-page.html - html_content-type-without-cache-test-page.html - html_custom-get-page.html - html_single-get-page.html - html_cyrillic-test-page.html - html_filter-test-page.html - html_infinite-get-page.html - html_json-custom-mime-test-page.html - html_json-long-test-page.html - html_json-malformed-test-page.html - html_json-text-mime-test-page.html - html_jsonp-test-page.html - html_navigate-test-page.html - html_params-test-page.html - html_post-data-test-page.html - html_post-raw-test-page.html - html_post-raw-with-headers-test-page.html - html_simple-test-page.html - html_sorting-test-page.html - html_statistics-test-page.html - html_status-codes-test-page.html - html_copy-as-curl.html - html_curl-utils.html - sjs_content-type-test-server.sjs - sjs_cors-test-server.sjs - sjs_https-redirect-test-server.sjs - sjs_simple-test-server.sjs - sjs_sorting-test-server.sjs - sjs_status-codes-test-server.sjs - test-image.png - -[browser_net_aaa_leaktest.js] -[browser_net_accessibility-01.js] -[browser_net_accessibility-02.js] -[browser_net_autoscroll.js] -[browser_net_charts-01.js] -[browser_net_charts-02.js] -[browser_net_charts-03.js] -skip-if= buildapp == 'mulet' -[browser_net_charts-04.js] -[browser_net_charts-05.js] -[browser_net_charts-06.js] -[browser_net_charts-07.js] -[browser_net_clear.js] -[browser_net_complex-params.js] -[browser_net_content-type.js] -[browser_net_curl-utils.js] -[browser_net_copy_image_as_data_uri.js] -[browser_net_copy_url.js] -[browser_net_copy_as_curl.js] -skip-if = e10s # Bug 1091596 -[browser_net_cyrillic-01.js] -[browser_net_cyrillic-02.js] -[browser_net_details-no-duplicated-content.js] -[browser_net_filter-01.js] -skip-if = e10s # Bug 1091603 -[browser_net_filter-02.js] -[browser_net_filter-03.js] -[browser_net_filter-04.js] -[browser_net_footer-summary.js] -[browser_net_html-preview.js] -[browser_net_icon-preview.js] -[browser_net_image-tooltip.js] -[browser_net_json-long.js] -[browser_net_json-malformed.js] -[browser_net_json_custom_mime.js] -[browser_net_json_text_mime.js] -[browser_net_jsonp.js] -[browser_net_large-response.js] -[browser_net_open_request_in_tab.js] -[browser_net_page-nav.js] -[browser_net_pane-collapse.js] -[browser_net_pane-toggle.js] -[browser_net_post-data-01.js] -[browser_net_post-data-02.js] -[browser_net_post-data-03.js] -[browser_net_prefs-and-l10n.js] -[browser_net_prefs-reload.js] -[browser_net_raw_headers.js] -[browser_net_reload-button.js] -[browser_net_req-resp-bodies.js] -[browser_net_resend.js] -skip-if = e10s # Bug 1091612 -[browser_net_security-details.js] -[browser_net_security-error.js] -[browser_net_security-icon-click.js] -[browser_net_security-redirect.js] -[browser_net_security-state.js] -[browser_net_security-tab-deselect.js] -[browser_net_security-tab-visibility.js] -[browser_net_security-warnings.js] -[browser_net_simple-init.js] -[browser_net_simple-request-data.js] -[browser_net_simple-request-details.js] -[browser_net_simple-request.js] -[browser_net_sort-01.js] -[browser_net_sort-02.js] -[browser_net_sort-03.js] -[browser_net_statistics-01.js] -[browser_net_statistics-02.js] -[browser_net_statistics-03.js] -[browser_net_status-codes.js] -[browser_net_timeline_ticks.js] -[browser_net_timing-division.js] -[browser_net_persistent_logs.js] diff --git a/browser/devtools/netmonitor/test/browser_net_aaa_leaktest.js b/browser/devtools/netmonitor/test/browser_net_aaa_leaktest.js deleted file mode 100644 index a9cd6fea7..000000000 --- a/browser/devtools/netmonitor/test/browser_net_aaa_leaktest.js +++ /dev/null @@ -1,28 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if the network monitor leaks on initialization and sudden destruction. - * You can also use this initialization format as a template for other tests. - */ - -function test() { - initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, NetMonitorView, NetMonitorController } = aMonitor.panelWin; - let { RequestsMenu, NetworkDetails } = NetMonitorView; - - ok(aTab, "Should have a tab available."); - ok(aDebuggee, "Should have a debuggee available."); - ok(aMonitor, "Should have a network monitor pane available."); - - ok(document, "Should have a document available."); - ok(NetMonitorView, "Should have a NetMonitorView object available."); - ok(NetMonitorController, "Should have a NetMonitorController object available."); - ok(RequestsMenu, "Should have a RequestsMenu object available."); - ok(NetworkDetails, "Should have a NetworkDetails object available."); - - teardown(aMonitor).then(finish); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_accessibility-01.js b/browser/devtools/netmonitor/test/browser_net_accessibility-01.js deleted file mode 100644 index 39a210d14..000000000 --- a/browser/devtools/netmonitor/test/browser_net_accessibility-01.js +++ /dev/null @@ -1,83 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if focus modifiers work for the SideMenuWidget. - */ - -function test() { - initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - // It seems that this test may be slow on Ubuntu builds running on ec2. - requestLongerTimeout(2); - - let { NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 2).then(() => { - check(-1, false); - - RequestsMenu.focusLastVisibleItem(); - check(1, true); - RequestsMenu.focusFirstVisibleItem(); - check(0, true); - - RequestsMenu.focusNextItem(); - check(1, true); - RequestsMenu.focusPrevItem(); - check(0, true); - - RequestsMenu.focusItemAtDelta(+1); - check(1, true); - RequestsMenu.focusItemAtDelta(-1); - check(0, true); - - RequestsMenu.focusItemAtDelta(+10); - check(1, true); - RequestsMenu.focusItemAtDelta(-10); - check(0, true); - - aDebuggee.performRequests(18); - return waitForNetworkEvents(aMonitor, 18); - }) - .then(() => { - RequestsMenu.focusLastVisibleItem(); - check(19, true); - RequestsMenu.focusFirstVisibleItem(); - check(0, true); - - RequestsMenu.focusNextItem(); - check(1, true); - RequestsMenu.focusPrevItem(); - check(0, true); - - RequestsMenu.focusItemAtDelta(+10); - check(10, true); - RequestsMenu.focusItemAtDelta(-10); - check(0, true); - - RequestsMenu.focusItemAtDelta(+100); - check(19, true); - RequestsMenu.focusItemAtDelta(-100); - check(0, true); - - teardown(aMonitor).then(finish); - }); - - let count = 0; - - function check(aSelectedIndex, aPaneVisibility) { - info("Performing check " + (count++) + "."); - - is(RequestsMenu.selectedIndex, aSelectedIndex, - "The selected item in the requests menu was incorrect."); - is(NetMonitorView.detailsPaneHidden, !aPaneVisibility, - "The network requests details pane visibility state was incorrect."); - } - - aDebuggee.performRequests(2); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_accessibility-02.js b/browser/devtools/netmonitor/test/browser_net_accessibility-02.js deleted file mode 100644 index 0ec5490a2..000000000 --- a/browser/devtools/netmonitor/test/browser_net_accessibility-02.js +++ /dev/null @@ -1,126 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if keyboard and mouse navigation works in the network requests menu. - */ - -function test() { - initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - // It seems that this test may be slow on Ubuntu builds running on ec2. - requestLongerTimeout(2); - - let { window, $, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 2).then(() => { - check(-1, false); - - EventUtils.sendKey("DOWN", window); - check(0, true); - EventUtils.sendKey("UP", window); - check(0, true); - - EventUtils.sendKey("PAGE_DOWN", window); - check(1, true); - EventUtils.sendKey("PAGE_UP", window); - check(0, true); - - EventUtils.sendKey("END", window); - check(1, true); - EventUtils.sendKey("HOME", window); - check(0, true); - - aDebuggee.performRequests(18); - return waitForNetworkEvents(aMonitor, 18); - }) - .then(() => { - EventUtils.sendKey("DOWN", window); - check(1, true); - EventUtils.sendKey("DOWN", window); - check(2, true); - EventUtils.sendKey("UP", window); - check(1, true); - EventUtils.sendKey("UP", window); - check(0, true); - - EventUtils.sendKey("PAGE_DOWN", window); - check(4, true); - EventUtils.sendKey("PAGE_DOWN", window); - check(8, true); - EventUtils.sendKey("PAGE_UP", window); - check(4, true); - EventUtils.sendKey("PAGE_UP", window); - check(0, true); - - EventUtils.sendKey("HOME", window); - check(0, true); - EventUtils.sendKey("HOME", window); - check(0, true); - EventUtils.sendKey("PAGE_UP", window); - check(0, true); - EventUtils.sendKey("HOME", window); - check(0, true); - - EventUtils.sendKey("END", window); - check(19, true); - EventUtils.sendKey("END", window); - check(19, true); - EventUtils.sendKey("PAGE_DOWN", window); - check(19, true); - EventUtils.sendKey("END", window); - check(19, true); - - EventUtils.sendKey("PAGE_UP", window); - check(15, true); - EventUtils.sendKey("PAGE_UP", window); - check(11, true); - EventUtils.sendKey("UP", window); - check(10, true); - EventUtils.sendKey("UP", window); - check(9, true); - EventUtils.sendKey("PAGE_DOWN", window); - check(13, true); - EventUtils.sendKey("PAGE_DOWN", window); - check(17, true); - EventUtils.sendKey("PAGE_DOWN", window); - check(19, true); - EventUtils.sendKey("PAGE_DOWN", window); - check(19, true); - - EventUtils.sendKey("HOME", window); - check(0, true); - EventUtils.sendKey("DOWN", window); - check(1, true); - EventUtils.sendKey("END", window); - check(19, true); - EventUtils.sendKey("DOWN", window); - check(19, true); - - EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle")); - check(-1, false); - - EventUtils.sendMouseEvent({ type: "mousedown" }, $(".side-menu-widget-item")); - check(0, true); - - teardown(aMonitor).then(finish); - }); - - let count = 0; - - function check(aSelectedIndex, aPaneVisibility) { - info("Performing check " + (count++) + "."); - - is(RequestsMenu.selectedIndex, aSelectedIndex, - "The selected item in the requests menu was incorrect."); - is(NetMonitorView.detailsPaneHidden, !aPaneVisibility, - "The network requests details pane visibility state was incorrect."); - } - - aDebuggee.performRequests(2); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_autoscroll.js b/browser/devtools/netmonitor/test/browser_net_autoscroll.js deleted file mode 100644 index c13e6f458..000000000 --- a/browser/devtools/netmonitor/test/browser_net_autoscroll.js +++ /dev/null @@ -1,97 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/////////////////// -// -// Whitelisting this test. -// As part of bug 1077403, the leaking uncaught rejection should be fixed. -// -thisTestLeaksUncaughtRejectionsAndShouldBeFixed("TypeError: aValue.content is undefined"); - -/** - * Bug 863102 - Automatically scroll down upon new network requests. - */ - -function test() { - requestLongerTimeout(2); - let monitor, debuggee, requestsContainer, scrollTop; - - initNetMonitor(INFINITE_GET_URL).then(([aTab, aDebuggee, aMonitor]) => { - monitor = aMonitor; - debuggee = aDebuggee; - let win = monitor.panelWin; - let topNode = win.document.getElementById("requests-menu-contents"); - requestsContainer = topNode.getElementsByTagName("scrollbox")[0]; - ok(!!requestsContainer, "Container element exists as expected."); - }) - - // (1) Check that the scroll position is maintained at the bottom - // when the requests overflow the vertical size of the container. - .then(() => { - return waitForRequestsToOverflowContainer(monitor, requestsContainer); - }) - .then(() => { - ok(scrolledToBottom(requestsContainer), "Scrolled to bottom on overflow."); - }) - - // (2) Now set the scroll position somewhere in the middle and check - // that additional requests do not change the scroll position. - .then(() => { - let children = requestsContainer.childNodes; - let middleNode = children.item(children.length / 2); - middleNode.scrollIntoView(); - ok(!scrolledToBottom(requestsContainer), "Not scrolled to bottom."); - scrollTop = requestsContainer.scrollTop; // save for comparison later - return waitForNetworkEvents(monitor, 8); - }) - .then(() => { - is(requestsContainer.scrollTop, scrollTop, "Did not scroll."); - }) - - // (3) Now set the scroll position back at the bottom and check that - // additional requests *do* cause the container to scroll down. - .then(() => { - requestsContainer.scrollTop = requestsContainer.scrollHeight; - ok(scrolledToBottom(requestsContainer), "Set scroll position to bottom."); - return waitForNetworkEvents(monitor, 8); - }) - .then(() => { - ok(scrolledToBottom(requestsContainer), "Still scrolled to bottom."); - }) - - // (4) Now select an item in the list and check that additional requests - // do not change the scroll position. - .then(() => { - monitor.panelWin.NetMonitorView.RequestsMenu.selectedIndex = 0; - return waitForNetworkEvents(monitor, 8); - }) - .then(() => { - is(requestsContainer.scrollTop, 0, "Did not scroll."); - }) - - // Done; clean up. - .then(() => { - return teardown(monitor).then(finish); - }) - - // Handle exceptions in the chain of promises. - .then(null, (err) => { - ok(false, err); - finish(); - }); - - function waitForRequestsToOverflowContainer (aMonitor, aContainer) { - return waitForNetworkEvents(aMonitor, 1).then(() => { - if (aContainer.scrollHeight > aContainer.clientHeight) { - // Wait for some more just for good measure. - return waitForNetworkEvents(aMonitor, 8); - } else { - return waitForRequestsToOverflowContainer(aMonitor, aContainer); - } - }); - } - - function scrolledToBottom(aElement) { - return aElement.scrollTop + aElement.clientHeight >= aElement.scrollHeight; - } -} diff --git a/browser/devtools/netmonitor/test/browser_net_charts-01.js b/browser/devtools/netmonitor/test/browser_net_charts-01.js deleted file mode 100644 index 985f4913a..000000000 --- a/browser/devtools/netmonitor/test/browser_net_charts-01.js +++ /dev/null @@ -1,77 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/////////////////// -// -// Whitelisting this test. -// As part of bug 1077403, the leaking uncaught rejection should be fixed. -// -thisTestLeaksUncaughtRejectionsAndShouldBeFixed("TypeError: aValue.content is undefined"); - -/** - * Makes sure Pie Charts have the right internal structure. - */ - -function test() { - initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, Chart } = aMonitor.panelWin; - let container = document.createElement("box"); - - let pie = Chart.Pie(document, { - width: 100, - height: 100, - data: [{ - size: 1, - label: "foo" - }, { - size: 2, - label: "bar" - }, { - size: 3, - label: "baz" - }] - }); - - let node = pie.node; - let slices = node.querySelectorAll(".pie-chart-slice.chart-colored-blob"); - let labels = node.querySelectorAll(".pie-chart-label"); - - ok(node.classList.contains("pie-chart-container") && - node.classList.contains("generic-chart-container"), - "A pie chart container was created successfully."); - - is(slices.length, 3, - "There should be 3 pie chart slices created."); - ok(slices[0].getAttribute("d").match(/\s*M 50,50 L 49\.\d+,97\.\d+ A 47\.5,47\.5 0 0 1 49\.\d+,2\.5\d* Z/), - "The first slice has the correct data."); - ok(slices[1].getAttribute("d").match(/\s*M 50,50 L 91\.\d+,26\.\d+ A 47\.5,47\.5 0 0 1 49\.\d+,97\.\d+ Z/), - "The second slice has the correct data."); - ok(slices[2].getAttribute("d").match(/\s*M 50,50 L 50\.\d+,2\.5\d* A 47\.5,47\.5 0 0 1 91\.\d+,26\.\d+ Z/), - "The third slice has the correct data."); - - ok(slices[0].hasAttribute("largest"), - "The first slice should be the largest one."); - ok(slices[2].hasAttribute("smallest"), - "The third slice should be the smallest one."); - - ok(slices[0].getAttribute("name"), "baz", - "The first slice's name is correct."); - ok(slices[1].getAttribute("name"), "bar", - "The first slice's name is correct."); - ok(slices[2].getAttribute("name"), "foo", - "The first slice's name is correct."); - - is(labels.length, 3, - "There should be 3 pie chart labels created."); - is(labels[0].textContent, "baz", - "The first label's text is correct."); - is(labels[1].textContent, "bar", - "The first label's text is correct."); - is(labels[2].textContent, "foo", - "The first label's text is correct."); - - teardown(aMonitor).then(finish); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_charts-02.js b/browser/devtools/netmonitor/test/browser_net_charts-02.js deleted file mode 100644 index 93d4cdc22..000000000 --- a/browser/devtools/netmonitor/test/browser_net_charts-02.js +++ /dev/null @@ -1,49 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Makes sure Pie Charts have the right internal structure when - * initialized with empty data. - */ - -function test() { - initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, L10N, Chart } = aMonitor.panelWin; - let container = document.createElement("box"); - - let pie = Chart.Pie(document, { - data: null, - width: 100, - height: 100 - }); - - let node = pie.node; - let slices = node.querySelectorAll(".pie-chart-slice.chart-colored-blob"); - let labels = node.querySelectorAll(".pie-chart-label"); - - ok(node.classList.contains("pie-chart-container") && - node.classList.contains("generic-chart-container"), - "A pie chart container was created successfully."); - - is(slices.length, 1, - "There should be 1 pie chart slice created."); - ok(slices[0].getAttribute("d").match(/\s*M 50,50 L 50\.\d+,2\.5\d* A 47\.5,47\.5 0 1 1 49\.\d+,2\.5\d* Z/), - "The first slice has the correct data."); - - ok(slices[0].hasAttribute("largest"), - "The first slice should be the largest one."); - ok(slices[0].hasAttribute("smallest"), - "The first slice should also be the smallest one."); - ok(slices[0].getAttribute("name"), L10N.getStr("pieChart.loading"), - "The first slice's name is correct."); - - is(labels.length, 1, - "There should be 1 pie chart label created."); - is(labels[0].textContent, "Loading", - "The first label's text is correct."); - - teardown(aMonitor).then(finish); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_charts-03.js b/browser/devtools/netmonitor/test/browser_net_charts-03.js deleted file mode 100644 index 2f5ec0a4a..000000000 --- a/browser/devtools/netmonitor/test/browser_net_charts-03.js +++ /dev/null @@ -1,103 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Makes sure Table Charts have the right internal structure. - */ - -function test() { - initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, L10N, Chart } = aMonitor.panelWin; - let container = document.createElement("box"); - - let table = Chart.Table(document, { - title: "Table title", - data: [{ - label1: 1, - label2: 11.1 - }, { - label1: 2, - label2: 12.2 - }, { - label1: 3, - label2: 13.3 - }], - strings: { - label2: (value, index) => value + ["foo", "bar", "baz"][index] - }, - totals: { - label1: value => "Hello " + L10N.numberWithDecimals(value, 2), - label2: value => "World " + L10N.numberWithDecimals(value, 2) - } - }); - - let node = table.node; - let title = node.querySelector(".table-chart-title"); - let grid = node.querySelector(".table-chart-grid"); - let totals = node.querySelector(".table-chart-totals"); - let rows = grid.querySelectorAll(".table-chart-row"); - let sums = node.querySelectorAll(".table-chart-summary-label"); - - ok(node.classList.contains("table-chart-container") && - node.classList.contains("generic-chart-container"), - "A table chart container was created successfully."); - - ok(title, - "A title node was created successfully."); - is(title.getAttribute("value"), "Table title", - "The title node displays the correct text."); - - is(rows.length, 3, - "There should be 3 table chart rows created."); - - ok(rows[0].querySelector(".table-chart-row-box.chart-colored-blob"), - "A colored blob exists for the firt row."); - is(rows[0].querySelectorAll("label")[0].getAttribute("name"), "label1", - "The first column of the first row exists."); - is(rows[0].querySelectorAll("label")[1].getAttribute("name"), "label2", - "The second column of the first row exists."); - is(rows[0].querySelectorAll("label")[0].getAttribute("value"), "1", - "The first column of the first row displays the correct text."); - is(rows[0].querySelectorAll("label")[1].getAttribute("value"), "11.1foo", - "The second column of the first row displays the correct text."); - - ok(rows[1].querySelector(".table-chart-row-box.chart-colored-blob"), - "A colored blob exists for the second row."); - is(rows[1].querySelectorAll("label")[0].getAttribute("name"), "label1", - "The first column of the second row exists."); - is(rows[1].querySelectorAll("label")[1].getAttribute("name"), "label2", - "The second column of the second row exists."); - is(rows[1].querySelectorAll("label")[0].getAttribute("value"), "2", - "The first column of the second row displays the correct text."); - is(rows[1].querySelectorAll("label")[1].getAttribute("value"), "12.2bar", - "The second column of the first row displays the correct text."); - - ok(rows[2].querySelector(".table-chart-row-box.chart-colored-blob"), - "A colored blob exists for the third row."); - is(rows[2].querySelectorAll("label")[0].getAttribute("name"), "label1", - "The first column of the third row exists."); - is(rows[2].querySelectorAll("label")[1].getAttribute("name"), "label2", - "The second column of the third row exists."); - is(rows[2].querySelectorAll("label")[0].getAttribute("value"), "3", - "The first column of the third row displays the correct text."); - is(rows[2].querySelectorAll("label")[1].getAttribute("value"), "13.3baz", - "The second column of the third row displays the correct text."); - - is(sums.length, 2, - "There should be 2 total summaries created."); - - is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("name"), "label1", - "The first sum's type is correct."); - is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("value"), "Hello 6", - "The first sum's value is correct."); - - is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("name"), "label2", - "The second sum's type is correct."); - is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("value"), "World 36.60", - "The second sum's value is correct."); - - teardown(aMonitor).then(finish); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_charts-04.js b/browser/devtools/netmonitor/test/browser_net_charts-04.js deleted file mode 100644 index ee75f11b0..000000000 --- a/browser/devtools/netmonitor/test/browser_net_charts-04.js +++ /dev/null @@ -1,70 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Makes sure Pie Charts have the right internal structure when - * initialized with empty data. - */ - -function test() { - initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, L10N, Chart } = aMonitor.panelWin; - let container = document.createElement("box"); - - let table = Chart.Table(document, { - title: "Table title", - data: null, - totals: { - label1: value => "Hello " + L10N.numberWithDecimals(value, 2), - label2: value => "World " + L10N.numberWithDecimals(value, 2) - } - }); - - let node = table.node; - let title = node.querySelector(".table-chart-title"); - let grid = node.querySelector(".table-chart-grid"); - let totals = node.querySelector(".table-chart-totals"); - let rows = grid.querySelectorAll(".table-chart-row"); - let sums = node.querySelectorAll(".table-chart-summary-label"); - - ok(node.classList.contains("table-chart-container") && - node.classList.contains("generic-chart-container"), - "A table chart container was created successfully."); - - ok(title, - "A title node was created successfully."); - is(title.getAttribute("value"), "Table title", - "The title node displays the correct text."); - - is(rows.length, 1, - "There should be 1 table chart row created."); - - ok(rows[0].querySelector(".table-chart-row-box.chart-colored-blob"), - "A colored blob exists for the firt row."); - is(rows[0].querySelectorAll("label")[0].getAttribute("name"), "size", - "The first column of the first row exists."); - is(rows[0].querySelectorAll("label")[1].getAttribute("name"), "label", - "The second column of the first row exists."); - is(rows[0].querySelectorAll("label")[0].getAttribute("value"), "", - "The first column of the first row displays the correct text."); - is(rows[0].querySelectorAll("label")[1].getAttribute("value"), L10N.getStr("tableChart.loading"), - "The second column of the first row displays the correct text."); - - is(sums.length, 2, - "There should be 2 total summaries created."); - - is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("name"), "label1", - "The first sum's type is correct."); - is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("value"), "Hello 0", - "The first sum's value is correct."); - - is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("name"), "label2", - "The second sum's type is correct."); - is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("value"), "World 0", - "The second sum's value is correct."); - - teardown(aMonitor).then(finish); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_charts-05.js b/browser/devtools/netmonitor/test/browser_net_charts-05.js deleted file mode 100644 index ecbf71e67..000000000 --- a/browser/devtools/netmonitor/test/browser_net_charts-05.js +++ /dev/null @@ -1,63 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Makes sure Pie+Table Charts have the right internal structure. - */ - -function test() { - initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, L10N, Chart } = aMonitor.panelWin; - let container = document.createElement("box"); - - let chart = Chart.PieTable(document, { - title: "Table title", - data: [{ - size: 1, - label: 11.1 - }, { - size: 2, - label: 12.2 - }, { - size: 3, - label: 13.3 - }], - strings: { - label2: (value, index) => value + ["foo", "bar", "baz"][index] - }, - totals: { - size: value => "Hello " + L10N.numberWithDecimals(value, 2), - label: value => "World " + L10N.numberWithDecimals(value, 2) - } - }); - - ok(chart.pie, "The pie chart proxy is accessible."); - ok(chart.table, "The table chart proxy is accessible."); - - let node = chart.node; - let slices = node.querySelectorAll(".pie-chart-slice"); - let rows = node.querySelectorAll(".table-chart-row"); - let sums = node.querySelectorAll(".table-chart-summary-label"); - - ok(node.classList.contains("pie-table-chart-container"), - "A pie+table chart container was created successfully."); - - ok(node.querySelector(".table-chart-title"), - "A title node was created successfully."); - ok(node.querySelector(".pie-chart-container"), - "A pie chart was created successfully."); - ok(node.querySelector(".table-chart-container"), - "A table chart was created successfully."); - - is(rows.length, 3, - "There should be 3 pie chart slices created."); - is(rows.length, 3, - "There should be 3 table chart rows created."); - is(sums.length, 2, - "There should be 2 total summaries created."); - - teardown(aMonitor).then(finish); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_charts-06.js b/browser/devtools/netmonitor/test/browser_net_charts-06.js deleted file mode 100644 index 8e3ffa0ca..000000000 --- a/browser/devtools/netmonitor/test/browser_net_charts-06.js +++ /dev/null @@ -1,44 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Makes sure Pie Charts correctly handle empty source data. - */ - -function test() { - initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, L10N, Chart } = aMonitor.panelWin; - let container = document.createElement("box"); - - let pie = Chart.Pie(document, { - data: [], - width: 100, - height: 100 - }); - - let node = pie.node; - let slices = node.querySelectorAll(".pie-chart-slice.chart-colored-blob"); - let labels = node.querySelectorAll(".pie-chart-label"); - - is(slices.length, 1, - "There should be 1 pie chart slice created."); - ok(slices[0].getAttribute("d").match(/\s*M 50,50 L 50\.\d+,2\.5\d* A 47\.5,47\.5 0 1 1 49\.\d+,2\.5\d* Z/), - "The slice has the correct data."); - - ok(slices[0].hasAttribute("largest"), - "The slice should be the largest one."); - ok(slices[0].hasAttribute("smallest"), - "The slice should also be the smallest one."); - ok(slices[0].getAttribute("name"), L10N.getStr("pieChart.unavailable"), - "The slice's name is correct."); - - is(labels.length, 1, - "There should be 1 pie chart label created."); - is(labels[0].textContent, "Empty", - "The label's text is correct."); - - teardown(aMonitor).then(finish); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_charts-07.js b/browser/devtools/netmonitor/test/browser_net_charts-07.js deleted file mode 100644 index 4c75c2f5d..000000000 --- a/browser/devtools/netmonitor/test/browser_net_charts-07.js +++ /dev/null @@ -1,58 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Makes sure Table Charts correctly handle empty source data. - */ - -function test() { - initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, L10N, Chart } = aMonitor.panelWin; - let container = document.createElement("box"); - - let table = Chart.Table(document, { - data: [], - totals: { - label1: value => "Hello " + L10N.numberWithDecimals(value, 2), - label2: value => "World " + L10N.numberWithDecimals(value, 2) - } - }); - - let node = table.node; - let grid = node.querySelector(".table-chart-grid"); - let totals = node.querySelector(".table-chart-totals"); - let rows = grid.querySelectorAll(".table-chart-row"); - let sums = node.querySelectorAll(".table-chart-summary-label"); - - is(rows.length, 1, - "There should be 1 table chart row created."); - - ok(rows[0].querySelector(".table-chart-row-box.chart-colored-blob"), - "A colored blob exists for the firt row."); - is(rows[0].querySelectorAll("label")[0].getAttribute("name"), "size", - "The first column of the first row exists."); - is(rows[0].querySelectorAll("label")[1].getAttribute("name"), "label", - "The second column of the first row exists."); - is(rows[0].querySelectorAll("label")[0].getAttribute("value"), "", - "The first column of the first row displays the correct text."); - is(rows[0].querySelectorAll("label")[1].getAttribute("value"), L10N.getStr("tableChart.unavailable"), - "The second column of the first row displays the correct text."); - - is(sums.length, 2, - "There should be 2 total summaries created."); - - is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("name"), "label1", - "The first sum's type is correct."); - is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("value"), "Hello 0", - "The first sum's value is correct."); - - is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("name"), "label2", - "The second sum's type is correct."); - is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("value"), "World 0", - "The second sum's value is correct."); - - teardown(aMonitor).then(finish); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_clear.js b/browser/devtools/netmonitor/test/browser_net_clear.js deleted file mode 100644 index a78492cd7..000000000 --- a/browser/devtools/netmonitor/test/browser_net_clear.js +++ /dev/null @@ -1,76 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if the clear button empties the request menu. - */ - -function test() { - initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, $, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - let detailsPane = $("#details-pane"); - let detailsPaneToggleButton = $('#details-pane-toggle'); - let clearButton = $('#requests-menu-clear-button'); - - RequestsMenu.lazyUpdate = false; - - // Make sure we start in a sane state - assertNoRequestState(RequestsMenu, detailsPaneToggleButton); - - // Load one request and assert it shows up in the lis - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.NETWORK_EVENT, () => { - assertSingleRequestState(RequestsMenu, detailsPaneToggleButton); - - // Click clear and make sure the requests are gone - EventUtils.sendMouseEvent({ type: "click" }, clearButton); - assertNoRequestState(RequestsMenu, detailsPaneToggleButton); - - // Load a second request and make sure they still show up - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.NETWORK_EVENT, () => { - assertSingleRequestState(RequestsMenu, detailsPaneToggleButton); - - // Make sure we can now open the details pane - NetMonitorView.toggleDetailsPane({ visible: true, animated: false }); - ok(!detailsPane.hasAttribute("pane-collapsed") && - !detailsPaneToggleButton.hasAttribute("pane-collapsed"), - "The details pane should be visible after clicking the toggle button."); - - // Click clear and make sure the details pane closes - EventUtils.sendMouseEvent({ type: "click" }, clearButton); - assertNoRequestState(RequestsMenu, detailsPaneToggleButton); - ok(detailsPane.hasAttribute("pane-collapsed") && - detailsPaneToggleButton.hasAttribute("pane-collapsed"), - "The details pane should not be visible clicking 'clear'."); - - teardown(aMonitor).then(finish); - }); - - aDebuggee.location.reload(); - }); - - aDebuggee.location.reload(); - }); - - /** - * Asserts the state of the network monitor when one request has loaded - */ - function assertSingleRequestState(RequestsMenu, detailsPaneToggleButton) { - is(RequestsMenu.itemCount, 1, - "The request menu should have one item at this point."); - is(detailsPaneToggleButton.hasAttribute("disabled"), false, - "The pane toggle button should be enabled after a request is made."); - } - - /** - * Asserts the state of the network monitor when no requests have loaded - */ - function assertNoRequestState(RequestsMenu, detailsPaneToggleButton) { - is(RequestsMenu.itemCount, 0, - "The request menu should be empty at this point."); - is(detailsPaneToggleButton.hasAttribute("disabled"), true, - "The pane toggle button should be disabled when the request menu is cleared."); - } -} diff --git a/browser/devtools/netmonitor/test/browser_net_complex-params.js b/browser/devtools/netmonitor/test/browser_net_complex-params.js deleted file mode 100644 index 7db80cae5..000000000 --- a/browser/devtools/netmonitor/test/browser_net_complex-params.js +++ /dev/null @@ -1,146 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests whether complex request params and payload sent via POST are - * displayed correctly. - */ - -function test() { - initNetMonitor(PARAMS_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, L10N, EVENTS, Editor, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu, NetworkDetails } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - NetworkDetails._params.lazyEmpty = false; - - Task.spawn(function () { - yield waitForNetworkEvents(aMonitor, 0, 6); - - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.getElementById("details-pane-toggle")); - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.querySelectorAll("#details-pane tab")[2]); - - yield waitFor(aMonitor.panelWin, EVENTS.REQUEST_POST_PARAMS_DISPLAYED); - yield testParamsTab1('a', '""', '{ "foo": "bar" }', '""'); - - RequestsMenu.selectedIndex = 1; - yield waitFor(aMonitor.panelWin, EVENTS.REQUEST_POST_PARAMS_DISPLAYED); - yield testParamsTab1('a', '"b"', '{ "foo": "bar" }', '""'); - - RequestsMenu.selectedIndex = 2; - yield waitFor(aMonitor.panelWin, EVENTS.REQUEST_POST_PARAMS_DISPLAYED); - yield testParamsTab1('a', '"b"', 'foo', '"bar"'); - - RequestsMenu.selectedIndex = 3; - yield waitFor(aMonitor.panelWin, EVENTS.REQUEST_POST_PARAMS_DISPLAYED); - yield testParamsTab2('a', '""', '{ "foo": "bar" }', "js"); - - RequestsMenu.selectedIndex = 4; - yield waitFor(aMonitor.panelWin, EVENTS.REQUEST_POST_PARAMS_DISPLAYED); - yield testParamsTab2('a', '"b"', '{ "foo": "bar" }', "js"); - - RequestsMenu.selectedIndex = 5; - yield waitFor(aMonitor.panelWin, EVENTS.REQUEST_POST_PARAMS_DISPLAYED); - yield testParamsTab2('a', '"b"', '?foo=bar', "text"); - - yield teardown(aMonitor); - finish(); - }); - - function testParamsTab1( - aQueryStringParamName, aQueryStringParamValue, aFormDataParamName, aFormDataParamValue) - { - let tab = document.querySelectorAll("#details-pane tab")[2]; - let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2]; - - is(tabpanel.querySelectorAll(".variables-view-scope").length, 2, - "The number of param scopes displayed in this tabpanel is incorrect."); - is(tabpanel.querySelectorAll(".variable-or-property").length, 2, - "The number of param values displayed in this tabpanel is incorrect."); - is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0, - "The empty notice should not be displayed in this tabpanel."); - - is(tabpanel.querySelector("#request-params-box") - .hasAttribute("hidden"), false, - "The request params box should not be hidden."); - is(tabpanel.querySelector("#request-post-data-textarea-box") - .hasAttribute("hidden"), true, - "The request post data textarea box should be hidden."); - - let paramsScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; - let formDataScope = tabpanel.querySelectorAll(".variables-view-scope")[1]; - - is(paramsScope.querySelector(".name").getAttribute("value"), - L10N.getStr("paramsQueryString"), - "The params scope doesn't have the correct title."); - is(formDataScope.querySelector(".name").getAttribute("value"), - L10N.getStr("paramsFormData"), - "The form data scope doesn't have the correct title."); - - is(paramsScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"), - aQueryStringParamName, - "The first query string param name was incorrect."); - is(paramsScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"), - aQueryStringParamValue, - "The first query string param value was incorrect."); - - is(formDataScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"), - aFormDataParamName, - "The first form data param name was incorrect."); - is(formDataScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"), - aFormDataParamValue, - "The first form data param value was incorrect."); - } - - function testParamsTab2( - aQueryStringParamName, aQueryStringParamValue, aRequestPayload, aEditorMode) - { - let tab = document.querySelectorAll("#details-pane tab")[2]; - let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2]; - - is(tabpanel.querySelectorAll(".variables-view-scope").length, 2, - "The number of param scopes displayed in this tabpanel is incorrect."); - is(tabpanel.querySelectorAll(".variable-or-property").length, 1, - "The number of param values displayed in this tabpanel is incorrect."); - is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0, - "The empty notice should not be displayed in this tabpanel."); - - is(tabpanel.querySelector("#request-params-box") - .hasAttribute("hidden"), false, - "The request params box should not be hidden."); - is(tabpanel.querySelector("#request-post-data-textarea-box") - .hasAttribute("hidden"), false, - "The request post data textarea box should not be hidden."); - - let paramsScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; - let payloadScope = tabpanel.querySelectorAll(".variables-view-scope")[1]; - - is(paramsScope.querySelector(".name").getAttribute("value"), - L10N.getStr("paramsQueryString"), - "The params scope doesn't have the correct title."); - is(payloadScope.querySelector(".name").getAttribute("value"), - L10N.getStr("paramsPostPayload"), - "The request payload scope doesn't have the correct title."); - - is(paramsScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"), - aQueryStringParamName, - "The first query string param name was incorrect."); - is(paramsScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"), - aQueryStringParamValue, - "The first query string param value was incorrect."); - - return NetMonitorView.editor("#request-post-data-textarea").then((aEditor) => { - is(aEditor.getText(), aRequestPayload, - "The text shown in the source editor is incorrect."); - is(aEditor.getMode(), Editor.modes[aEditorMode], - "The mode active in the source editor is incorrect."); - }); - } - - aDebuggee.performRequests(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_content-type.js b/browser/devtools/netmonitor/test/browser_net_content-type.js deleted file mode 100644 index 6dd94a000..000000000 --- a/browser/devtools/netmonitor/test/browser_net_content-type.js +++ /dev/null @@ -1,233 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if different response content types are handled correctly. - */ - -function test() { - initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, L10N, Editor, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 6).then(() => { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0), - "GET", CONTENT_TYPE_SJS + "?fmt=xml", { - status: 200, - statusText: "OK", - type: "xml", - fullMimeType: "text/xml; charset=utf-8", - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.04), - time: true - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(1), - "GET", CONTENT_TYPE_SJS + "?fmt=css", { - status: 200, - statusText: "OK", - type: "css", - fullMimeType: "text/css; charset=utf-8", - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.03), - time: true - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(2), - "GET", CONTENT_TYPE_SJS + "?fmt=js", { - status: 200, - statusText: "OK", - type: "js", - fullMimeType: "application/javascript; charset=utf-8", - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.03), - time: true - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(3), - "GET", CONTENT_TYPE_SJS + "?fmt=json", { - status: 200, - statusText: "OK", - type: "json", - fullMimeType: "application/json; charset=utf-8", - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.02), - time: true - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(4), - "GET", CONTENT_TYPE_SJS + "?fmt=bogus", { - status: 404, - statusText: "Not Found", - type: "html", - fullMimeType: "text/html; charset=utf-8", - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.02), - time: true - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(5), - "GET", TEST_IMAGE, { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "png", - fullMimeType: "image/png", - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.75), - time: true - }); - - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.getElementById("details-pane-toggle")); - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.querySelectorAll("#details-pane tab")[3]); - - Task.spawn(function*() { - yield waitForResponseBodyDisplayed(); - yield testResponseTab("xml"); - RequestsMenu.selectedIndex = 1; - yield waitForTabUpdated(); - yield testResponseTab("css"); - RequestsMenu.selectedIndex = 2; - yield waitForTabUpdated(); - yield testResponseTab("js"); - RequestsMenu.selectedIndex = 3; - yield waitForTabUpdated(); - yield testResponseTab("json"); - RequestsMenu.selectedIndex = 4; - yield waitForTabUpdated(); - yield testResponseTab("html"); - RequestsMenu.selectedIndex = 5; - yield waitForTabUpdated(); - yield testResponseTab("png"); - yield teardown(aMonitor); - finish(); - }); - - function testResponseTab(aType) { - let tab = document.querySelectorAll("#details-pane tab")[3]; - let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3]; - - is(tab.getAttribute("selected"), "true", - "The response tab in the network details pane should be selected."); - - function checkVisibility(aBox) { - is(tabpanel.querySelector("#response-content-info-header") - .hasAttribute("hidden"), true, - "The response info header doesn't have the intended visibility."); - is(tabpanel.querySelector("#response-content-json-box") - .hasAttribute("hidden"), aBox != "json", - "The response content json box doesn't have the intended visibility."); - is(tabpanel.querySelector("#response-content-textarea-box") - .hasAttribute("hidden"), aBox != "textarea", - "The response content textarea box doesn't have the intended visibility."); - is(tabpanel.querySelector("#response-content-image-box") - .hasAttribute("hidden"), aBox != "image", - "The response content image box doesn't have the intended visibility."); - } - - switch (aType) { - case "xml": { - checkVisibility("textarea"); - - return NetMonitorView.editor("#response-content-textarea").then((aEditor) => { - is(aEditor.getText(), "<label value='greeting'>Hello XML!</label>", - "The text shown in the source editor is incorrect for the xml request."); - is(aEditor.getMode(), Editor.modes.html, - "The mode active in the source editor is incorrect for the xml request."); - }); - } - case "css": { - checkVisibility("textarea"); - - return NetMonitorView.editor("#response-content-textarea").then((aEditor) => { - is(aEditor.getText(), "body:pre { content: 'Hello CSS!' }", - "The text shown in the source editor is incorrect for the xml request."); - is(aEditor.getMode(), Editor.modes.css, - "The mode active in the source editor is incorrect for the xml request."); - }); - } - case "js": { - checkVisibility("textarea"); - - return NetMonitorView.editor("#response-content-textarea").then((aEditor) => { - is(aEditor.getText(), "function() { return 'Hello JS!'; }", - "The text shown in the source editor is incorrect for the xml request."); - is(aEditor.getMode(), Editor.modes.js, - "The mode active in the source editor is incorrect for the xml request."); - }); - } - case "json": { - checkVisibility("json"); - - is(tabpanel.querySelectorAll(".variables-view-scope").length, 1, - "There should be 1 json scope displayed in this tabpanel."); - is(tabpanel.querySelectorAll(".variables-view-property").length, 2, - "There should be 2 json properties displayed in this tabpanel."); - is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0, - "The empty notice should not be displayed in this tabpanel."); - - let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; - - is(jsonScope.querySelector(".name").getAttribute("value"), - L10N.getStr("jsonScopeName"), - "The json scope doesn't have the correct title."); - - is(jsonScope.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"), - "greeting", "The first json property name was incorrect."); - is(jsonScope.querySelectorAll(".variables-view-property .value")[0].getAttribute("value"), - "\"Hello JSON!\"", "The first json property value was incorrect."); - - is(jsonScope.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"), - "__proto__", "The second json property name was incorrect."); - is(jsonScope.querySelectorAll(".variables-view-property .value")[1].getAttribute("value"), - "Object", "The second json property value was incorrect."); - - return promise.resolve(); - } - case "html": { - checkVisibility("textarea"); - - return NetMonitorView.editor("#response-content-textarea").then((aEditor) => { - is(aEditor.getText(), "<blink>Not Found</blink>", - "The text shown in the source editor is incorrect for the xml request."); - is(aEditor.getMode(), Editor.modes.html, - "The mode active in the source editor is incorrect for the xml request."); - }); - } - case "png": { - checkVisibility("image"); - - let imageNode = tabpanel.querySelector("#response-content-image"); - let deferred = promise.defer(); - - imageNode.addEventListener("load", function onLoad() { - imageNode.removeEventListener("load", onLoad); - - is(tabpanel.querySelector("#response-content-image-name-value") - .getAttribute("value"), "test-image.png", - "The image name info isn't correct."); - is(tabpanel.querySelector("#response-content-image-mime-value") - .getAttribute("value"), "image/png", - "The image mime info isn't correct."); - is(tabpanel.querySelector("#response-content-image-encoding-value") - .getAttribute("value"), "base64", - "The image encoding info isn't correct."); - is(tabpanel.querySelector("#response-content-image-dimensions-value") - .getAttribute("value"), "16" + " \u00D7 " + "16", - "The image dimensions info isn't correct."); - - deferred.resolve(); - }); - - return deferred.promise; - } - } - } - - function waitForTabUpdated () { - return waitFor(aMonitor.panelWin, aMonitor.panelWin.EVENTS.TAB_UPDATED); - } - - function waitForResponseBodyDisplayed () { - return waitFor(aMonitor.panelWin, aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED); - } - }); - - aDebuggee.performRequests(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_copy_as_curl.js b/browser/devtools/netmonitor/test/browser_net_copy_as_curl.js deleted file mode 100644 index a5b1adb8e..000000000 --- a/browser/devtools/netmonitor/test/browser_net_copy_as_curl.js +++ /dev/null @@ -1,73 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if Copy as cURL works. - */ - -function test() { - initNetMonitor(CURL_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - const EXPECTED_POSIX_RESULT = [ - "curl", - "'" + SIMPLE_SJS + "'", - "-H 'Host: example.com'", - "-H 'User-Agent: " + navigator.userAgent + "'", - "-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'", - "-H 'Accept-Language: " + navigator.language + "'", - "--compressed", - "-H 'X-Custom-Header-1: Custom value'", - "-H 'X-Custom-Header-2: 8.8.8.8'", - "-H 'X-Custom-Header-3: Mon, 3 Mar 2014 11:11:11 GMT'", - "-H 'Referer: " + CURL_URL + "'", - "-H 'Connection: keep-alive'" - ].join(" "); - - const EXPECTED_WIN_RESULT = [ - 'curl', - '"' + SIMPLE_SJS + '"', - '-H "Host: example.com"', - '-H "User-Agent: ' + navigator.userAgent + '"', - '-H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"', - '-H "Accept-Language: ' + navigator.language + '"', - "--compressed", - '-H "X-Custom-Header-1: Custom value"', - '-H "X-Custom-Header-2: 8.8.8.8"', - '-H "X-Custom-Header-3: Mon, 3 Mar 2014 11:11:11 GMT"', - '-H "Referer: ' + CURL_URL + '"', - '-H "Connection: keep-alive"' - ].join(" "); - - const EXPECTED_RESULT = Services.appinfo.OS == "WINNT" - ? EXPECTED_WIN_RESULT - : EXPECTED_POSIX_RESULT; - - let { NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 1).then(() => { - let requestItem = RequestsMenu.getItemAtIndex(0); - RequestsMenu.selectedItem = requestItem; - - waitForClipboard(EXPECTED_RESULT, function setup() { - RequestsMenu.copyAsCurl(); - }, function onSuccess() { - ok(true, "Clipboard contains a cURL command for the currently selected item's url."); - cleanUp(); - }, function onFailure() { - ok(false, "Creating a cURL command for the currently selected item was unsuccessful."); - cleanUp(); - }); - - }); - - aDebuggee.performRequest(SIMPLE_SJS); - - function cleanUp(){ - teardown(aMonitor).then(finish); - } - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_copy_image_as_data_uri.js b/browser/devtools/netmonitor/test/browser_net_copy_image_as_data_uri.js deleted file mode 100644 index f82fa22e8..000000000 --- a/browser/devtools/netmonitor/test/browser_net_copy_image_as_data_uri.js +++ /dev/null @@ -1,38 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if copying an image as data uri works. - */ - -function test() { - initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 6).then(() => { - let requestItem = RequestsMenu.getItemAtIndex(5); - RequestsMenu.selectedItem = requestItem; - - waitForClipboard(TEST_IMAGE_DATA_URI, function setup() { - RequestsMenu.copyImageAsDataUri(); - }, function onSuccess() { - ok(true, "Clipboard contains the currently selected image as data uri."); - cleanUp(); - }, function onFailure() { - ok(false, "Copying the currently selected image as data uri was unsuccessful."); - cleanUp(); - }); - }); - - aDebuggee.performRequests(); - - function cleanUp(){ - teardown(aMonitor).then(finish); - } - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_copy_url.js b/browser/devtools/netmonitor/test/browser_net_copy_url.js deleted file mode 100644 index d2e54f17d..000000000 --- a/browser/devtools/netmonitor/test/browser_net_copy_url.js +++ /dev/null @@ -1,36 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if copying a request's url works. - */ - -function test() { - initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - waitForNetworkEvents(aMonitor, 1).then(() => { - let requestItem = RequestsMenu.getItemAtIndex(0); - RequestsMenu.selectedItem = requestItem; - - waitForClipboard(requestItem.attachment.url, function setup() { - RequestsMenu.copyUrl(); - }, function onSuccess() { - ok(true, "Clipboard contains the currently selected item's url."); - cleanUp(); - }, function onFailure() { - ok(false, "Copying the currently selected item's url was unsuccessful."); - cleanUp(); - }); - }); - - aDebuggee.performRequests(1); - - function cleanUp(){ - teardown(aMonitor).then(finish); - } - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_curl-utils.js b/browser/devtools/netmonitor/test/browser_net_curl-utils.js deleted file mode 100644 index cbb438912..000000000 --- a/browser/devtools/netmonitor/test/browser_net_curl-utils.js +++ /dev/null @@ -1,232 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests Curl Utils functionality. - */ - -function test() { - initNetMonitor(CURL_UTILS_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { NetMonitorView, gNetwork } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 1, 3).then(() => { - let requests = { - get: RequestsMenu.getItemAtIndex(0), - post: RequestsMenu.getItemAtIndex(1), - multipart: RequestsMenu.getItemAtIndex(2), - multipartForm: RequestsMenu.getItemAtIndex(3) - }; - - Task.spawn(function*() { - yield createCurlData(requests.get.attachment, gNetwork).then((aData) => { - test_findHeader(aData); - }); - - yield createCurlData(requests.post.attachment, gNetwork).then((aData) => { - test_isUrlEncodedRequest(aData); - test_writePostDataTextParams(aData); - }); - - yield createCurlData(requests.multipart.attachment, gNetwork).then((aData) => { - test_isMultipartRequest(aData); - test_getMultipartBoundary(aData); - test_removeBinaryDataFromMultipartText(aData); - }); - - yield createCurlData(requests.multipartForm.attachment, gNetwork).then((aData) => { - test_getHeadersFromMultipartText(aData); - }); - - if (Services.appinfo.OS != "WINNT") { - test_escapeStringPosix(); - } else { - test_escapeStringWin(); - } - - teardown(aMonitor).then(finish); - }); - }); - - aDebuggee.performRequests(SIMPLE_SJS); - }); -} - -function test_isUrlEncodedRequest(aData) { - let isUrlEncoded = CurlUtils.isUrlEncodedRequest(aData); - ok(isUrlEncoded, "Should return true for url encoded requests."); -} - -function test_isMultipartRequest(aData) { - let isMultipart = CurlUtils.isMultipartRequest(aData); - ok(isMultipart, "Should return true for multipart/form-data requests."); -} - -function test_findHeader(aData) { - let headers = aData.headers; - let hostName = CurlUtils.findHeader(headers, "Host"); - let requestedWithLowerCased = CurlUtils.findHeader(headers, "x-requested-with"); - let doesNotExist = CurlUtils.findHeader(headers, "X-Does-Not-Exist"); - - is(hostName, "example.com", - "Header with name 'Host' should be found in the request array."); - is(requestedWithLowerCased, "XMLHttpRequest", - "The search should be case insensitive."); - is(doesNotExist, null, - "Should return null when a header is not found."); -} - -function test_writePostDataTextParams(aData) { - let params = CurlUtils.writePostDataTextParams(aData.postDataText); - is(params, "param1=value1¶m2=value2¶m3=value3", - "Should return a serialized representation of the request parameters"); -} - -function test_getMultipartBoundary(aData) { - let boundary = CurlUtils.getMultipartBoundary(aData); - ok(/-{3,}\w+/.test(boundary), - "A boundary string should be found in a multipart request."); -} - -function test_removeBinaryDataFromMultipartText(aData) { - let generatedBoundary = CurlUtils.getMultipartBoundary(aData); - let text = aData.postDataText; - let binaryRemoved = - CurlUtils.removeBinaryDataFromMultipartText(text, generatedBoundary); - let boundary = "--" + generatedBoundary; - - const EXPECTED_POSIX_RESULT = [ - "$'", - boundary, - "\\r\\n\\r\\n", - "Content-Disposition: form-data; name=\"param1\"", - "\\r\\n\\r\\n", - "value1", - "\\r\\n", - boundary, - "\\r\\n\\r\\n", - "Content-Disposition: form-data; name=\"file\"; filename=\"filename.png\"", - "\\r\\n", - "Content-Type: image/png", - "\\r\\n\\r\\n", - generatedBoundary, - "--\\r\\n", - "'" - ].join(""); - - const EXPECTED_WIN_RESULT = [ - '"' + boundary + '"^', - '\u000d\u000A\u000d\u000A', - '"Content-Disposition: form-data; name=""param1"""^', - '\u000d\u000A\u000d\u000A', - '"value1"^', - '\u000d\u000A', - '"' + boundary + '"^', - '\u000d\u000A\u000d\u000A', - '"Content-Disposition: form-data; name=""file""; filename=""filename.png"""^', - '\u000d\u000A', - '"Content-Type: image/png"^', - '\u000d\u000A\u000d\u000A', - '"' + generatedBoundary + '--"^', - '\u000d\u000A', - '""' - ].join(""); - - if (Services.appinfo.OS != "WINNT") { - is(CurlUtils.escapeStringPosix(binaryRemoved), EXPECTED_POSIX_RESULT, - "The mulitpart request payload should not contain binary data."); - } else { - is(CurlUtils.escapeStringWin(binaryRemoved), EXPECTED_WIN_RESULT, - "WinNT: The mulitpart request payload should not contain binary data."); - } -} - -function test_getHeadersFromMultipartText(aData) { - let headers = CurlUtils.getHeadersFromMultipartText(aData.postDataText); - - ok(Array.isArray(headers), - "Should return an array."); - ok(headers.length > 0, - "There should exist at least one request header."); - is(headers[0].name, "Content-Type", - "The first header name should be 'Content-Type'."); -} - -function test_escapeStringPosix() { - let surroundedWithQuotes = "A simple string"; - is(CurlUtils.escapeStringPosix(surroundedWithQuotes), "'A simple string'", - "The string should be surrounded with single quotes."); - - let singleQuotes = "It's unusual to put crickets in your coffee."; - is(CurlUtils.escapeStringPosix(singleQuotes), - "$'It\\'s unusual to put crickets in your coffee.'", - "Single quotes should be escaped."); - - let newLines = "Line 1\r\nLine 2\u000d\u000ALine3"; - is(CurlUtils.escapeStringPosix(newLines), "$'Line 1\\r\\nLine 2\\r\\nLine3'", - "Newlines should be escaped."); - - let controlChars = "\u0007 \u0009 \u000C \u001B"; - is(CurlUtils.escapeStringPosix(controlChars), "$'\\x07 \\x09 \\x0c \\x1b'", - "Control characters should be escaped."); - - let extendedAsciiChars = "æ ø ü ß ö é"; - is(CurlUtils.escapeStringPosix(extendedAsciiChars), - "$'\\xc3\\xa6 \\xc3\\xb8 \\xc3\\xbc \\xc3\\x9f \\xc3\\xb6 \\xc3\\xa9'", - "Character codes outside of the decimal range 32 - 126 should be escaped."); -} - -function test_escapeStringWin() { - let surroundedWithDoubleQuotes = "A simple string"; - is(CurlUtils.escapeStringWin(surroundedWithDoubleQuotes), '"A simple string"', - "The string should be surrounded with double quotes."); - - let doubleQuotes = "Quote: \"Time is an illusion. Lunchtime doubly so.\""; - is(CurlUtils.escapeStringWin(doubleQuotes), - '"Quote: ""Time is an illusion. Lunchtime doubly so."""', - "Double quotes should be escaped."); - - let percentSigns = "%AppData%"; - is(CurlUtils.escapeStringWin(percentSigns), '""%"AppData"%""', - "Percent signs should be escaped."); - - let backslashes = "\\A simple string\\"; - is(CurlUtils.escapeStringWin(backslashes), '"\\\\A simple string\\\\"', - "Backslashes should be escaped."); - - let newLines = "line1\r\nline2\r\nline3"; - is(CurlUtils.escapeStringWin(newLines), - '"line1"^\u000d\u000A"line2"^\u000d\u000A"line3"', - "Newlines should be escaped."); -} - -function createCurlData(aSelected, aNetwork) { - return Task.spawn(function*() { - // Create a sanitized object for the Curl command generator. - let data = { - url: aSelected.url, - method: aSelected.method, - headers: [], - httpVersion: aSelected.httpVersion, - postDataText: null - }; - - // Fetch header values. - for (let { name, value } of aSelected.requestHeaders.headers) { - let text = yield aNetwork.getString(value); - data.headers.push({ name: name, value: text }); - } - - // Fetch the request payload. - if (aSelected.requestPostData) { - let postData = aSelected.requestPostData.postData.text; - data.postDataText = yield aNetwork.getString(postData); - } - - return data; - }); -}
\ No newline at end of file diff --git a/browser/devtools/netmonitor/test/browser_net_cyrillic-01.js b/browser/devtools/netmonitor/test/browser_net_cyrillic-01.js deleted file mode 100644 index 3bf6a97f2..000000000 --- a/browser/devtools/netmonitor/test/browser_net_cyrillic-01.js +++ /dev/null @@ -1,44 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if cyrillic text is rendered correctly in the source editor. - */ - -function test() { - initNetMonitor(CYRILLIC_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, Editor, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 1).then(() => { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0), - "GET", CONTENT_TYPE_SJS + "?fmt=txt", { - status: 200, - statusText: "DA DA DA" - }); - - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.getElementById("details-pane-toggle")); - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.querySelectorAll("#details-pane tab")[3]); - - let RESPONSE_BODY_DISPLAYED = aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED; - waitFor(aMonitor.panelWin, RESPONSE_BODY_DISPLAYED).then(() => - NetMonitorView.editor("#response-content-textarea") - ).then((aEditor) => { - is(aEditor.getText().indexOf("\u044F"), 26, // я - "The text shown in the source editor is incorrect."); - is(aEditor.getMode(), Editor.modes.text, - "The mode active in the source editor is incorrect."); - - teardown(aMonitor).then(finish); - }); - }); - - aDebuggee.performRequests(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_cyrillic-02.js b/browser/devtools/netmonitor/test/browser_net_cyrillic-02.js deleted file mode 100644 index 27b951d86..000000000 --- a/browser/devtools/netmonitor/test/browser_net_cyrillic-02.js +++ /dev/null @@ -1,45 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if cyrillic text is rendered correctly in the source editor - * when loaded directly from an HTML page. - */ - -function test() { - initNetMonitor(CYRILLIC_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, Editor, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 1).then(() => { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0), - "GET", CYRILLIC_URL, { - status: 200, - statusText: "OK" - }); - - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.getElementById("details-pane-toggle")); - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.querySelectorAll("#details-pane tab")[3]); - - let RESPONSE_BODY_DISPLAYED = aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED; - waitFor(aMonitor.panelWin, RESPONSE_BODY_DISPLAYED).then(() => - NetMonitorView.editor("#response-content-textarea") - ).then((aEditor) => { - is(aEditor.getText().indexOf("\u044F"), 486, // я - "The text shown in the source editor is incorrect."); - is(aEditor.getMode(), Editor.modes.html, - "The mode active in the source editor is incorrect."); - - teardown(aMonitor).then(finish); - }); - }); - - aDebuggee.location.reload(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_details-no-duplicated-content.js b/browser/devtools/netmonitor/test/browser_net_details-no-duplicated-content.js deleted file mode 100644 index 343f80607..000000000 --- a/browser/devtools/netmonitor/test/browser_net_details-no-duplicated-content.js +++ /dev/null @@ -1,155 +0,0 @@ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -// A test to ensure that the content in details pane is not duplicated. - -let test = Task.async(function* () { - info("Initializing test"); - let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL); - let panel = monitor.panelWin; - let { NetMonitorView, EVENTS } = panel; - let { RequestsMenu, NetworkDetails } = NetMonitorView; - - const COOKIE_UNIQUE_PATH = "/do-not-use-in-other-tests-using-cookies"; - - let TEST_CASES = [ - { - desc: "Test headers tab", - pageURI: CUSTOM_GET_URL, - requestURI: null, - isPost: false, - tabIndex: 0, - variablesView: NetworkDetails._headers, - expectedScopeLength: 2, - }, - { - desc: "Test cookies tab", - pageURI: CUSTOM_GET_URL, - requestURI: COOKIE_UNIQUE_PATH, - isPost: false, - tabIndex: 1, - variablesView: NetworkDetails._cookies, - expectedScopeLength: 1, - }, - { - desc: "Test params tab", - pageURI: POST_RAW_URL, - requestURI: null, - isPost: true, - tabIndex: 2, - variablesView: NetworkDetails._params, - expectedScopeLength: 1, - }, - ]; - - info("Adding a cookie for the \"Cookie\" tab test"); - debuggee.document.cookie = "a=b; path=" + COOKIE_UNIQUE_PATH; - - info("Running tests"); - for (let spec of TEST_CASES) { - yield runTestCase(spec); - } - - // Remove the cookie. If an error occurs the path of the cookie ensures it - // doesn't mess with the other tests. - info("Removing the added cookie."); - debuggee.document.cookie = "a=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=" + - COOKIE_UNIQUE_PATH; - - yield teardown(monitor); - finish(); - - /** - * A helper that handles the execution of each case. - */ - function* runTestCase(spec) { - info("Running case: " + spec.desc); - debuggee.content.location = spec.pageURI; - - yield waitForNetworkEvents(monitor, 1); - RequestsMenu.clear(); - yield waitForFinalDetailTabUpdate(spec.tabIndex, spec.isPost, spec.requestURI); - - is(spec.variablesView._store.length, spec.expectedScopeLength, - "View contains " + spec.expectedScopeLength + " scope headers"); - } - - /** - * A helper that prepares the variables view for the actual testing. It - * - selects the correct tab - * - performs the specified request to specified URI - * - opens the details view - * - waits for the final update to happen - */ - function* waitForFinalDetailTabUpdate(tabIndex, isPost, uri) { - let onNetworkEvent = waitFor(panel, EVENTS.NETWORK_EVENT); - let onDetailsPopulated = waitFor(panel, EVENTS.NETWORKDETAILSVIEW_POPULATED); - let onRequestFinished = isPost ? - waitForNetworkEvents(monitor, 0, 1) : waitForNetworkEvents(monitor, 1); - - info("Performing a request"); - debuggee.performRequests(1, uri); - - info("Waiting for NETWORK_EVENT"); - yield onNetworkEvent; - - ok(true, "Received NETWORK_EVENT. Selecting the item."); - let item = RequestsMenu.getItemAtIndex(0); - RequestsMenu.selectedItem = item; - - info("Item selected. Waiting for NETWORKDETAILSVIEW_POPULATED"); - yield onDetailsPopulated; - - info("Received populated event. Selecting tab at index " + tabIndex); - NetworkDetails.widget.selectedIndex = tabIndex; - - info("Waiting for request to finish."); - yield onRequestFinished; - - ok(true, "Request finished."); - - /** - * Because this test uses lazy updates there's four scenarios to consider: - * #1: Everything is updated and test is ready to continue. - * #2: There's updates that are waiting to be flushed. - * #3: Updates are flushed but the tab update is still running. - * #4: There's pending updates and a tab update is still running. - * - * For case #1 there's not going to be a TAB_UPDATED event so don't wait for - * it (bug 1106181). - * - * For cases #2 and #3 it's enough to wait for one TAB_UPDATED event as for - * - case #2 the next flush will perform the final update and single - * TAB_UPDATED event is emitted. - * - case #3 the running update is the final update that'll emit one - * TAB_UPDATED event. - * - * For case #4 we must wait for the updates to be flushed before we can - * start waiting for TAB_UPDATED event or we'll continue the test right - * after the pending update finishes. - */ - let hasQueuedUpdates = RequestsMenu._updateQueue.length !== 0; - let hasRunningTabUpdate = NetworkDetails._viewState.updating[tabIndex]; - - if (hasQueuedUpdates || hasRunningTabUpdate) { - info("There's pending updates - waiting for them to finish."); - info(" hasQueuedUpdates: " + hasQueuedUpdates); - info(" hasRunningTabUpdate: " + hasRunningTabUpdate); - - if (hasQueuedUpdates && hasRunningTabUpdate) { - info("Waiting for updates to be flushed."); - // _flushRequests calls .populate which emits the following event - yield waitFor(panel, EVENTS.NETWORKDETAILSVIEW_POPULATED); - - info("Requests flushed."); - } - - info("Waiting for final tab update."); - yield waitFor(panel, EVENTS.TAB_UPDATED); - } - - info("All updates completed."); - } -}); diff --git a/browser/devtools/netmonitor/test/browser_net_filter-01.js b/browser/devtools/netmonitor/test/browser_net_filter-01.js deleted file mode 100644 index 2d129c483..000000000 --- a/browser/devtools/netmonitor/test/browser_net_filter-01.js +++ /dev/null @@ -1,229 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Test if filtering items in the network table works correctly. - */ -const BASIC_REQUESTS = [ - { url: "sjs_content-type-test-server.sjs?fmt=html&res=undefined" }, - { url: "sjs_content-type-test-server.sjs?fmt=css" }, - { url: "sjs_content-type-test-server.sjs?fmt=js" }, -]; - -const REQUESTS_WITH_MEDIA = BASIC_REQUESTS.concat([ - { url: "sjs_content-type-test-server.sjs?fmt=font" }, - { url: "sjs_content-type-test-server.sjs?fmt=image" }, - { url: "sjs_content-type-test-server.sjs?fmt=audio" }, - { url: "sjs_content-type-test-server.sjs?fmt=video" }, -]); - -const REQUESTS_WITH_MEDIA_AND_FLASH = REQUESTS_WITH_MEDIA.concat([ - { url: "sjs_content-type-test-server.sjs?fmt=flash" }, -]); - -function test() { - initNetMonitor(FILTERING_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { $, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 8).then(() => { - EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle")); - - isnot(RequestsMenu.selectedItem, null, - "There should be a selected item in the requests menu."); - is(RequestsMenu.selectedIndex, 0, - "The first item should be selected in the requests menu."); - is(NetMonitorView.detailsPaneHidden, false, - "The details pane should not be hidden after toggle button was pressed."); - - // First test with single filters... - testFilterButtons(aMonitor, "all"); - testContents([1, 1, 1, 1, 1, 1, 1, 1]) - .then(() => { - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button")); - testFilterButtons(aMonitor, "html"); - return testContents([1, 0, 0, 0, 0, 0, 0, 0]); - }) - .then(() => { - // Reset filters - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button")); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button")); - testFilterButtons(aMonitor, "css"); - return testContents([0, 1, 0, 0, 0, 0, 0, 0]); - }) - .then(() => { - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button")); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-js-button")); - testFilterButtons(aMonitor, "js"); - return testContents([0, 0, 1, 0, 0, 0, 0, 0]); - }) - .then(() => { - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button")); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-xhr-button")); - testFilterButtons(aMonitor, "xhr"); - return testContents([1, 1, 1, 1, 1, 1, 1, 1]); - }) - .then(() => { - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button")); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-fonts-button")); - testFilterButtons(aMonitor, "fonts"); - return testContents([0, 0, 0, 1, 0, 0, 0, 0]); - }) - .then(() => { - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button")); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-images-button")); - testFilterButtons(aMonitor, "images"); - return testContents([0, 0, 0, 0, 1, 0, 0, 0]); - }) - .then(() => { - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button")); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-media-button")); - testFilterButtons(aMonitor, "media"); - return testContents([0, 0, 0, 0, 0, 1, 1, 0]); - }) - .then(() => { - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button")); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-flash-button")); - testFilterButtons(aMonitor, "flash"); - return testContents([0, 0, 0, 0, 0, 0, 0, 1]); - }) - .then(() => { - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button")); - testFilterButtons(aMonitor, "all"); - return testContents([1, 1, 1, 1, 1, 1, 1, 1]); - }) - // ...then combine multiple filters together. - .then(() => { - // Enable filtering for html and css; should show request of both type. - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button")); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button")); - testFilterButtonsCustom(aMonitor, [0, 1, 1, 0, 0, 0, 0, 0, 0, 0]); - return testContents([1, 1, 0, 0, 0, 0, 0, 0]); - }) - .then(() => { - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-flash-button")); - testFilterButtonsCustom(aMonitor, [0, 1, 1, 0, 0, 0, 0, 0, 1, 0]); - return testContents([1, 1, 0, 0, 0, 0, 0, 1]); - }) - .then(() => { - // Disable some filters. Only one left active. - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button")); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-flash-button")); - testFilterButtons(aMonitor, "html"); - return testContents([1, 0, 0, 0, 0, 0, 0, 0]); - }) - .then(() => { - // Disable last active filter. Should toggle to all. - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button")); - testFilterButtons(aMonitor, "all"); - return testContents([1, 1, 1, 1, 1, 1, 1, 1]); - }) - .then(() => { - // Enable few filters and click on all. Only "all" should be checked. - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button")); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button")); - testFilterButtonsCustom(aMonitor, [0, 1, 1, 0, 0, 0, 0, 0, 0]); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button")); - testFilterButtons(aMonitor, "all"); - return testContents([1, 1, 1, 1, 1, 1, 1, 1]); - }) - .then(() => { - return teardown(aMonitor); - }) - .then(finish); - }); - - function testContents(aVisibility) { - isnot(RequestsMenu.selectedItem, null, - "There should still be a selected item after filtering."); - is(RequestsMenu.selectedIndex, 0, - "The first item should be still selected after filtering."); - is(NetMonitorView.detailsPaneHidden, false, - "The details pane should still be visible after filtering."); - - is(RequestsMenu.items.length, aVisibility.length, - "There should be a specific amount of items in the requests menu."); - is(RequestsMenu.visibleItems.length, aVisibility.filter(e => e).length, - "There should be a specific amount of visbile items in the requests menu."); - - for (let i = 0; i < aVisibility.length; i++) { - is(RequestsMenu.getItemAtIndex(i).target.hidden, !aVisibility[i], - "The item at index " + i + " doesn't have the correct hidden state."); - } - - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0), - "GET", CONTENT_TYPE_SJS + "?fmt=html", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "html", - fullMimeType: "text/html; charset=utf-8" - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(1), - "GET", CONTENT_TYPE_SJS + "?fmt=css", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "css", - fullMimeType: "text/css; charset=utf-8" - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(2), - "GET", CONTENT_TYPE_SJS + "?fmt=js", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "js", - fullMimeType: "application/javascript; charset=utf-8" - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(3), - "GET", CONTENT_TYPE_SJS + "?fmt=font", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "woff", - fullMimeType: "font/woff" - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(4), - "GET", CONTENT_TYPE_SJS + "?fmt=image", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "png", - fullMimeType: "image/png" - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(5), - "GET", CONTENT_TYPE_SJS + "?fmt=audio", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "ogg", - fullMimeType: "audio/ogg" - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(6), - "GET", CONTENT_TYPE_SJS + "?fmt=video", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "webm", - fullMimeType: "video/webm" - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(7), - "GET", CONTENT_TYPE_SJS + "?fmt=flash", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "x-shockwave-flash", - fullMimeType: "application/x-shockwave-flash" - }); - - return promise.resolve(null); - } - - loadCommonFrameScript(); - performRequestsInContent(REQUESTS_WITH_MEDIA_AND_FLASH); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_filter-02.js b/browser/devtools/netmonitor/test/browser_net_filter-02.js deleted file mode 100644 index aafa039d2..000000000 --- a/browser/devtools/netmonitor/test/browser_net_filter-02.js +++ /dev/null @@ -1,191 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Test if filtering items in the network table works correctly with new requests. - */ -const BASIC_REQUESTS = [ - { url: "sjs_content-type-test-server.sjs?fmt=html&res=undefined" }, - { url: "sjs_content-type-test-server.sjs?fmt=css" }, - { url: "sjs_content-type-test-server.sjs?fmt=js" }, -]; - -const REQUESTS_WITH_MEDIA = BASIC_REQUESTS.concat([ - { url: "sjs_content-type-test-server.sjs?fmt=font" }, - { url: "sjs_content-type-test-server.sjs?fmt=image" }, - { url: "sjs_content-type-test-server.sjs?fmt=audio" }, - { url: "sjs_content-type-test-server.sjs?fmt=video" }, -]); - -const REQUESTS_WITH_MEDIA_AND_FLASH = REQUESTS_WITH_MEDIA.concat([ - { url: "sjs_content-type-test-server.sjs?fmt=flash" }, -]); - -function test() { - initNetMonitor(FILTERING_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - // It seems that this test may be slow on Ubuntu builds running on ec2. - requestLongerTimeout(2); - - let { $, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 8).then(() => { - EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle")); - - isnot(RequestsMenu.selectedItem, null, - "There should be a selected item in the requests menu."); - is(RequestsMenu.selectedIndex, 0, - "The first item should be selected in the requests menu."); - is(NetMonitorView.detailsPaneHidden, false, - "The details pane should not be hidden after toggle button was pressed."); - - testFilterButtons(aMonitor, "all"); - testContents([1, 1, 1, 1, 1, 1, 1, 1]) - .then(() => { - info("Testing html filtering."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button")); - testFilterButtons(aMonitor, "html"); - return testContents([1, 0, 0, 0, 0, 0, 0, 0]); - }) - .then(() => { - info("Performing more requests."); - performRequestsInContent(REQUESTS_WITH_MEDIA_AND_FLASH); - return waitForNetworkEvents(aMonitor, 8); - }) - .then(() => { - info("Testing html filtering again."); - testFilterButtons(aMonitor, "html"); - return testContents([1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]); - }) - .then(() => { - info("Performing more requests."); - performRequestsInContent(REQUESTS_WITH_MEDIA_AND_FLASH); - return waitForNetworkEvents(aMonitor, 8); - }) - .then(() => { - info("Testing html filtering again."); - testFilterButtons(aMonitor, "html"); - return testContents([1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]); - }) - .then(() => { - info("Resetting filters."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button")); - testFilterButtons(aMonitor, "all"); - return testContents([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]); - }) - .then(() => { - return teardown(aMonitor); - }) - .then(finish); - }); - - function testContents(aVisibility) { - isnot(RequestsMenu.selectedItem, null, - "There should still be a selected item after filtering."); - is(RequestsMenu.selectedIndex, 0, - "The first item should be still selected after filtering."); - is(NetMonitorView.detailsPaneHidden, false, - "The details pane should still be visible after filtering."); - - is(RequestsMenu.items.length, aVisibility.length, - "There should be a specific amount of items in the requests menu."); - is(RequestsMenu.visibleItems.length, aVisibility.filter(e => e).length, - "There should be a specific amount of visbile items in the requests menu."); - - for (let i = 0; i < aVisibility.length; i++) { - is(RequestsMenu.getItemAtIndex(i).target.hidden, !aVisibility[i], - "The item at index " + i + " doesn't have the correct hidden state."); - } - - for (let i = 0; i < aVisibility.length; i += 8) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i), - "GET", CONTENT_TYPE_SJS + "?fmt=html", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "html", - fullMimeType: "text/html; charset=utf-8" - }); - } - for (let i = 1; i < aVisibility.length; i += 8) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i), - "GET", CONTENT_TYPE_SJS + "?fmt=css", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "css", - fullMimeType: "text/css; charset=utf-8" - }); - } - for (let i = 2; i < aVisibility.length; i += 8) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i), - "GET", CONTENT_TYPE_SJS + "?fmt=js", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "js", - fullMimeType: "application/javascript; charset=utf-8" - }); - } - for (let i = 3; i < aVisibility.length; i += 8) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i), - "GET", CONTENT_TYPE_SJS + "?fmt=font", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "woff", - fullMimeType: "font/woff" - }); - } - for (let i = 4; i < aVisibility.length; i += 8) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i), - "GET", CONTENT_TYPE_SJS + "?fmt=image", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "png", - fullMimeType: "image/png" - }); - } - for (let i = 5; i < aVisibility.length; i += 8) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i), - "GET", CONTENT_TYPE_SJS + "?fmt=audio", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "ogg", - fullMimeType: "audio/ogg" - }); - } - for (let i = 6; i < aVisibility.length; i += 8) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i), - "GET", CONTENT_TYPE_SJS + "?fmt=video", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "webm", - fullMimeType: "video/webm" - }); - } - for (let i = 7; i < aVisibility.length; i += 8) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i), - "GET", CONTENT_TYPE_SJS + "?fmt=flash", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "x-shockwave-flash", - fullMimeType: "application/x-shockwave-flash" - }); - } - - return promise.resolve(null); - } - - loadCommonFrameScript(); - performRequestsInContent(REQUESTS_WITH_MEDIA_AND_FLASH); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_filter-03.js b/browser/devtools/netmonitor/test/browser_net_filter-03.js deleted file mode 100644 index 8e595b69b..000000000 --- a/browser/devtools/netmonitor/test/browser_net_filter-03.js +++ /dev/null @@ -1,197 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Test if filtering items in the network table works correctly with new requests - * and while sorting is enabled. - */ -const BASIC_REQUESTS = [ - { url: "sjs_content-type-test-server.sjs?fmt=html&res=undefined" }, - { url: "sjs_content-type-test-server.sjs?fmt=css" }, - { url: "sjs_content-type-test-server.sjs?fmt=js" }, -]; - -const REQUESTS_WITH_MEDIA = BASIC_REQUESTS.concat([ - { url: "sjs_content-type-test-server.sjs?fmt=font" }, - { url: "sjs_content-type-test-server.sjs?fmt=image" }, - { url: "sjs_content-type-test-server.sjs?fmt=audio" }, - { url: "sjs_content-type-test-server.sjs?fmt=video" }, -]); - -const REQUESTS_WITH_MEDIA_AND_FLASH = REQUESTS_WITH_MEDIA.concat([ - { url: "sjs_content-type-test-server.sjs?fmt=flash" }, -]); - -function test() { - initNetMonitor(FILTERING_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - // It seems that this test may be slow on Ubuntu builds running on ec2. - requestLongerTimeout(2); - - let { $, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 7).then(() => { - EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle")); - - isnot(RequestsMenu.selectedItem, null, - "There should be a selected item in the requests menu."); - is(RequestsMenu.selectedIndex, 0, - "The first item should be selected in the requests menu."); - is(NetMonitorView.detailsPaneHidden, false, - "The details pane should not be hidden after toggle button was pressed."); - - testFilterButtons(aMonitor, "all"); - testContents([0, 1, 2, 3, 4, 5, 6], 7, 0) - .then(() => { - info("Sorting by size, ascending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button")); - testFilterButtons(aMonitor, "all"); - return testContents([6, 4, 5, 0, 1, 2, 3], 7, 6); - }) - .then(() => { - info("Testing html filtering."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button")); - testFilterButtons(aMonitor, "html"); - return testContents([6, 4, 5, 0, 1, 2, 3], 1, 6); - }) - .then(() => { - info("Performing more requests."); - performRequestsInContent(REQUESTS_WITH_MEDIA); - return waitForNetworkEvents(aMonitor, 7); - }) - .then(() => { - info("Testing html filtering again."); - resetSorting(); - testFilterButtons(aMonitor, "html"); - return testContents([8, 13, 9, 11, 10, 12, 0, 4, 1, 5, 2, 6, 3, 7], 2, 13); - }) - .then(() => { - info("Performing more requests."); - performRequestsInContent(REQUESTS_WITH_MEDIA); - return waitForNetworkEvents(aMonitor, 7); - }) - .then(() => { - info("Testing html filtering again."); - resetSorting(); - testFilterButtons(aMonitor, "html"); - return testContents([12, 13, 20, 14, 16, 18, 15, 17, 19, 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11], 3, 20); - }) - .then(() => { - return teardown(aMonitor); - }) - .then(finish); - }); - - function resetSorting() { - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button")); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button")); - } - - function testContents(aOrder, aVisible, aSelection) { - isnot(RequestsMenu.selectedItem, null, - "There should still be a selected item after filtering."); - is(RequestsMenu.selectedIndex, aSelection, - "The first item should be still selected after filtering."); - is(NetMonitorView.detailsPaneHidden, false, - "The details pane should still be visible after filtering."); - - is(RequestsMenu.items.length, aOrder.length, - "There should be a specific amount of items in the requests menu."); - is(RequestsMenu.visibleItems.length, aVisible, - "There should be a specific amount of visbile items in the requests menu."); - - for (let i = 0; i < aOrder.length; i++) { - is(RequestsMenu.getItemAtIndex(i), RequestsMenu.items[i], - "The requests menu items aren't ordered correctly. Misplaced item " + i + "."); - } - - for (let i = 0, len = aOrder.length / 7; i < len; i++) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i]), - "GET", CONTENT_TYPE_SJS + "?fmt=html", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "html", - fullMimeType: "text/html; charset=utf-8" - }); - } - for (let i = 0, len = aOrder.length / 7; i < len; i++) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len]), - "GET", CONTENT_TYPE_SJS + "?fmt=css", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "css", - fullMimeType: "text/css; charset=utf-8" - }); - } - for (let i = 0, len = aOrder.length / 7; i < len; i++) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 2]), - "GET", CONTENT_TYPE_SJS + "?fmt=js", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "js", - fullMimeType: "application/javascript; charset=utf-8" - }); - } - for (let i = 0, len = aOrder.length / 7; i < len; i++) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 3]), - "GET", CONTENT_TYPE_SJS + "?fmt=font", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "woff", - fullMimeType: "font/woff" - }); - } - for (let i = 0, len = aOrder.length / 7; i < len; i++) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 4]), - "GET", CONTENT_TYPE_SJS + "?fmt=image", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "png", - fullMimeType: "image/png" - }); - } - for (let i = 0, len = aOrder.length / 7; i < len; i++) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 5]), - "GET", CONTENT_TYPE_SJS + "?fmt=audio", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "ogg", - fullMimeType: "audio/ogg" - }); - } - for (let i = 0, len = aOrder.length / 7; i < len; i++) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 6]), - "GET", CONTENT_TYPE_SJS + "?fmt=video", { - fuzzyUrl: true, - status: 200, - statusText: "OK", - type: "webm", - fullMimeType: "video/webm" - }); - } - - return promise.resolve(null); - } - - // The test assumes that the first HTML request here has a longer response - // body than the other HTML requests performed later during the test. - let requests = Cu.cloneInto(REQUESTS_WITH_MEDIA, {}); - - let newres = "res=<p>" + new Array(10).join(Math.random(10)) + "</p>"; - requests[0].url = requests[0].url.replace("res=undefined", newres); - - loadCommonFrameScript(); - performRequestsInContent(requests); - - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_filter-04.js b/browser/devtools/netmonitor/test/browser_net_filter-04.js deleted file mode 100644 index 64f6e58f5..000000000 --- a/browser/devtools/netmonitor/test/browser_net_filter-04.js +++ /dev/null @@ -1,59 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if invalid filter types are sanitized when loaded from the preferences. - */ - -const BASIC_REQUESTS = [ - { url: "sjs_content-type-test-server.sjs?fmt=html&res=undefined" }, - { url: "sjs_content-type-test-server.sjs?fmt=css" }, - { url: "sjs_content-type-test-server.sjs?fmt=js" }, -]; - -const REQUESTS_WITH_MEDIA = BASIC_REQUESTS.concat([ - { url: "sjs_content-type-test-server.sjs?fmt=font" }, - { url: "sjs_content-type-test-server.sjs?fmt=image" }, - { url: "sjs_content-type-test-server.sjs?fmt=audio" }, - { url: "sjs_content-type-test-server.sjs?fmt=video" }, -]); - -const REQUESTS_WITH_MEDIA_AND_FLASH = REQUESTS_WITH_MEDIA.concat([ - { url: "sjs_content-type-test-server.sjs?fmt=flash" }, -]); - -function test() { - Services.prefs.setCharPref("devtools.netmonitor.filters", '["js", "bogus"]'); - - initNetMonitor(FILTERING_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { Prefs, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - is(Prefs.filters.length, 2, - "All filter types were loaded as an array from the preferences."); - is(Prefs.filters[0], "js", - "The first filter type is correct."); - is(Prefs.filters[1], "bogus", - "The second filter type is invalid, but loaded anyway."); - - waitForNetworkEvents(aMonitor, 8).then(() => { - testFilterButtons(aMonitor, "js"); - ok(true, "Only the correct filter type was taken into consideration."); - - teardown(aMonitor).then(() => { - let filters = Services.prefs.getCharPref("devtools.netmonitor.filters"); - is(filters, '["js"]', - "The bogus filter type was ignored and removed from the preferences."); - - finish(); - }); - }); - - loadCommonFrameScript(); - performRequestsInContent(REQUESTS_WITH_MEDIA_AND_FLASH); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_footer-summary.js b/browser/devtools/netmonitor/test/browser_net_footer-summary.js deleted file mode 100644 index 9677afaa4..000000000 --- a/browser/devtools/netmonitor/test/browser_net_footer-summary.js +++ /dev/null @@ -1,116 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Test if the summary text displayed in the network requests menu footer - * is correct. - */ - -function test() { - requestLongerTimeout(2); - let { PluralForm } = Cu.import("resource://gre/modules/PluralForm.jsm", {}); - - initNetMonitor(FILTERING_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { $, L10N, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - testStatus(); - - waitForNetworkEvents(aMonitor, 8).then(() => { - testStatus(); - - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button")); - testStatus(); - - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button")); - testStatus(); - - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-js-button")); - testStatus(); - - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-xhr-button")); - testStatus(); - - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-fonts-button")); - testStatus(); - - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-images-button")); - testStatus(); - - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-media-button")); - testStatus(); - - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-flash-button")); - testStatus(); - - info("Performing more requests."); - aDebuggee.performRequests('{ "getMedia": true, "getFlash": true }'); - return waitForNetworkEvents(aMonitor, 8); - }) - .then(() => { - testStatus(); - - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button")); - testStatus(); - - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button")); - testStatus(); - - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-js-button")); - testStatus(); - - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-xhr-button")); - testStatus(); - - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-fonts-button")); - testStatus(); - - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-images-button")); - testStatus(); - - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-media-button")); - testStatus(); - - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-flash-button")); - testStatus(); - - teardown(aMonitor).then(finish); - }) - - function testStatus() { - let summary = $("#requests-menu-network-summary-label"); - let value = summary.getAttribute("value"); - info("Current summary: " + value); - - let visibleItems = RequestsMenu.visibleItems; - let visibleRequestsCount = visibleItems.length; - let totalRequestsCount = RequestsMenu.itemCount; - info("Current requests: " + visibleRequestsCount + " of " + totalRequestsCount + "."); - - if (!totalRequestsCount || !visibleRequestsCount) { - is(value, L10N.getStr("networkMenu.empty"), - "The current summary text is incorrect, expected an 'empty' label."); - return; - } - - let totalBytes = RequestsMenu._getTotalBytesOfRequests(visibleItems); - let totalMillis = - RequestsMenu._getNewestRequest(visibleItems).attachment.endedMillis - - RequestsMenu._getOldestRequest(visibleItems).attachment.startedMillis; - - info("Computed total bytes: " + totalBytes); - info("Computed total millis: " + totalMillis); - - is(value, PluralForm.get(visibleRequestsCount, L10N.getStr("networkMenu.summary")) - .replace("#1", visibleRequestsCount) - .replace("#2", L10N.numberWithDecimals((totalBytes || 0) / 1024, 2)) - .replace("#3", L10N.numberWithDecimals((totalMillis || 0) / 1000, 2)) - , "The current summary text is incorrect.") - } - - aDebuggee.performRequests('{ "getMedia": true, "getFlash": true }'); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_html-preview.js b/browser/devtools/netmonitor/test/browser_net_html-preview.js deleted file mode 100644 index b9d614685..000000000 --- a/browser/devtools/netmonitor/test/browser_net_html-preview.js +++ /dev/null @@ -1,62 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if html responses show and properly populate a "Preview" tab. - */ - -function test() { - initNetMonitor(CONTENT_TYPE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { $, document, EVENTS, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 6).then(() => { - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.getElementById("details-pane-toggle")); - - is($("#event-details-pane").selectedIndex, 0, - "The first tab in the details pane should be selected."); - is($("#preview-tab").hidden, true, - "The preview tab should be hidden for non html responses."); - is($("#preview-tabpanel").hidden, true, - "The preview tabpanel should be hidden for non html responses."); - - RequestsMenu.selectedIndex = 4; - NetMonitorView.toggleDetailsPane({ visible: true, animated: false }, 6); - - is($("#event-details-pane").selectedIndex, 6, - "The sixth tab in the details pane should be selected."); - is($("#preview-tab").hidden, false, - "The preview tab should be visible now."); - is($("#preview-tabpanel").hidden, false, - "The preview tabpanel should be visible now."); - - waitFor(aMonitor.panelWin, EVENTS.RESPONSE_HTML_PREVIEW_DISPLAYED).then(() => { - let iframe = $("#response-preview"); - ok(iframe, - "There should be a response preview iframe available."); - ok(iframe.contentDocument, - "The iframe's content document should be available."); - is(iframe.contentDocument.querySelector("blink").textContent, "Not Found", - "The iframe's content document should be loaded and correct."); - - RequestsMenu.selectedIndex = 5; - - is($("#event-details-pane").selectedIndex, 0, - "The first tab in the details pane should be selected again."); - is($("#preview-tab").hidden, true, - "The preview tab should be hidden again for non html responses."); - is($("#preview-tabpanel").hidden, true, - "The preview tabpanel should be hidden again for non html responses."); - - teardown(aMonitor).then(finish); - }); - }); - - aDebuggee.performRequests(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_icon-preview.js b/browser/devtools/netmonitor/test/browser_net_icon-preview.js deleted file mode 100644 index 19b4c4cfe..000000000 --- a/browser/devtools/netmonitor/test/browser_net_icon-preview.js +++ /dev/null @@ -1,61 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if image responses show a thumbnail in the requests menu. - */ - -function test() { - initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { $, $all, EVENTS, ACTIVITY_TYPE, NetMonitorView, NetMonitorController } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - promise.all([ - waitForNetworkEvents(aMonitor, 6), - waitFor(aMonitor.panelWin, EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED) - ]).then(() => { - info("Checking the image thumbnail when all items are shown."); - checkImageThumbnail(); - - RequestsMenu.sortBy("size"); - info("Checking the image thumbnail when all items are sorted."); - checkImageThumbnail(); - - RequestsMenu.filterOn("images"); - info("Checking the image thumbnail when only images are shown."); - checkImageThumbnail(); - - info("Reloading the debuggee and performing all requests again..."); - reloadAndPerformRequests(); - - return promise.all([ - waitForNetworkEvents(aMonitor, 7), // 6 + 1 - waitFor(aMonitor.panelWin, EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED) - ]); - }).then(() => { - info("Checking the image thumbnail after a reload."); - checkImageThumbnail(); - - teardown(aMonitor).then(finish); - }); - - function reloadAndPerformRequests() { - NetMonitorController.triggerActivity(ACTIVITY_TYPE.RELOAD.WITH_CACHE_ENABLED).then(() => { - aDebuggee.performRequests(); - }); - } - - function checkImageThumbnail() { - is($all(".requests-menu-icon[type=thumbnail]").length, 1, - "There should be only one image request with a thumbnail displayed."); - is($(".requests-menu-icon[type=thumbnail]").src, TEST_IMAGE_DATA_URI, - "The image requests-menu-icon thumbnail is displayed correctly."); - is($(".requests-menu-icon[type=thumbnail]").hidden, false, - "The image requests-menu-icon thumbnail should not be hidden."); - } - - aDebuggee.performRequests(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_image-tooltip.js b/browser/devtools/netmonitor/test/browser_net_image-tooltip.js deleted file mode 100644 index 996b95064..000000000 --- a/browser/devtools/netmonitor/test/browser_net_image-tooltip.js +++ /dev/null @@ -1,77 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if image responses show a popup in the requests menu when hovered. - */ - -function test() { - initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { $, EVENTS, ACTIVITY_TYPE, NetMonitorView, NetMonitorController } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - promise.all([ - waitForNetworkEvents(aMonitor, 6), - waitFor(aMonitor.panelWin, EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED) - ]).then(() => { - info("Checking the image thumbnail after a few requests were made..."); - let requestItem = RequestsMenu.items[5]; - let requestTooltip = requestItem.attachment.tooltip; - ok(requestTooltip, "There should be a tooltip instance for the image request."); - - let anchor = $(".requests-menu-file", requestItem.target); - return showTooltipOn(requestTooltip, anchor); - }).then(aTooltip => { - ok(true, - "An tooltip was successfully opened for the image request."); - is(aTooltip.content.querySelector("image").src, TEST_IMAGE_DATA_URI, - "The tooltip's image content is displayed correctly."); - - info("Reloading the debuggee and performing all requests again..."); - reloadAndPerformRequests(); - - return promise.all([ - waitForNetworkEvents(aMonitor, 7), // 6 + 1 - waitFor(aMonitor.panelWin, EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED) - ]); - }).then(() => { - info("Checking the image thumbnail after a reload."); - let requestItem = RequestsMenu.items[6]; - let requestTooltip = requestItem.attachment.tooltip; - ok(requestTooltip, "There should be a tooltip instance for the image request."); - - let anchor = $(".requests-menu-file", requestItem.target); - return showTooltipOn(requestTooltip, anchor); - }).then(aTooltip => { - ok(true, - "An tooltip was successfully opened for the image request."); - is(aTooltip.content.querySelector("image").src, TEST_IMAGE_DATA_URI, - "The tooltip's image content is displayed correctly."); - - teardown(aMonitor).then(finish); - }); - - function reloadAndPerformRequests() { - NetMonitorController.triggerActivity(ACTIVITY_TYPE.RELOAD.WITH_CACHE_ENABLED).then(() => { - aDebuggee.performRequests(); - }); - } - - /** - * @return a promise that resolves when the tooltip is shown - */ - function showTooltipOn(tooltip, element) { - return Task.spawn(function*() { - let isTarget = yield tooltip.isValidHoverTarget(element); - let onShown = tooltip.once("shown"); - tooltip.show(); - yield onShown; - return tooltip; - }); - } - - aDebuggee.performRequests(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_json-long.js b/browser/devtools/netmonitor/test/browser_net_json-long.js deleted file mode 100644 index 4eea879f4..000000000 --- a/browser/devtools/netmonitor/test/browser_net_json-long.js +++ /dev/null @@ -1,91 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if very long JSON responses are handled correctly. - */ - -function test() { - initNetMonitor(JSON_LONG_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - // This is receiving over 80 KB of json and will populate over 6000 items - // in a variables view instance. Debug builds are slow. - requestLongerTimeout(4); - - let { document, L10N, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 1).then(() => { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0), - "GET", CONTENT_TYPE_SJS + "?fmt=json-long", { - status: 200, - statusText: "OK", - type: "json", - fullMimeType: "text/json; charset=utf-8", - size: L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(85975/1024, 2)), - time: true - }); - - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED, () => { - testResponseTab(); - teardown(aMonitor).then(finish); - }); - - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.getElementById("details-pane-toggle")); - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.querySelectorAll("#details-pane tab")[3]); - - function testResponseTab() { - let tab = document.querySelectorAll("#details-pane tab")[3]; - let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3]; - - is(tab.getAttribute("selected"), "true", - "The response tab in the network details pane should be selected."); - - is(tabpanel.querySelector("#response-content-info-header") - .hasAttribute("hidden"), true, - "The response info header doesn't have the intended visibility."); - is(tabpanel.querySelector("#response-content-json-box") - .hasAttribute("hidden"), false, - "The response content json box doesn't have the intended visibility."); - is(tabpanel.querySelector("#response-content-textarea-box") - .hasAttribute("hidden"), true, - "The response content textarea box doesn't have the intended visibility."); - is(tabpanel.querySelector("#response-content-image-box") - .hasAttribute("hidden"), true, - "The response content image box doesn't have the intended visibility."); - - is(tabpanel.querySelectorAll(".variables-view-scope").length, 1, - "There should be 1 json scope displayed in this tabpanel."); - is(tabpanel.querySelectorAll(".variables-view-property").length, 6143, - "There should be 6143 json properties displayed in this tabpanel."); - is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0, - "The empty notice should not be displayed in this tabpanel."); - - let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; - let names = ".variables-view-property > .title > .name"; - let values = ".variables-view-property > .title > .value"; - - is(jsonScope.querySelector(".name").getAttribute("value"), - L10N.getStr("jsonScopeName"), - "The json scope doesn't have the correct title."); - - is(jsonScope.querySelectorAll(names)[0].getAttribute("value"), - "0", "The first json property name was incorrect."); - is(jsonScope.querySelectorAll(values)[0].getAttribute("value"), - "Object", "The first json property value was incorrect."); - - is(jsonScope.querySelectorAll(names)[1].getAttribute("value"), - "greeting", "The second json property name was incorrect."); - is(jsonScope.querySelectorAll(values)[1].getAttribute("value"), - "\"Hello long string JSON!\"", "The second json property value was incorrect."); - } - }); - - aDebuggee.performRequests(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_json-malformed.js b/browser/devtools/netmonitor/test/browser_net_json-malformed.js deleted file mode 100644 index d1e55df14..000000000 --- a/browser/devtools/netmonitor/test/browser_net_json-malformed.js +++ /dev/null @@ -1,74 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if malformed JSON responses are handled correctly. - */ - -function test() { - initNetMonitor(JSON_MALFORMED_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, Editor, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 1).then(() => { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0), - "GET", CONTENT_TYPE_SJS + "?fmt=json-malformed", { - status: 200, - statusText: "OK", - type: "json", - fullMimeType: "text/json; charset=utf-8" - }); - - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.getElementById("details-pane-toggle")); - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.querySelectorAll("#details-pane tab")[3]); - - let tab = document.querySelectorAll("#details-pane tab")[3]; - let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3]; - - let RESPONSE_BODY_DISPLAYED = aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED; - waitFor(aMonitor.panelWin, RESPONSE_BODY_DISPLAYED).then(() => { - is(tab.getAttribute("selected"), "true", - "The response tab in the network details pane should be selected."); - - is(tabpanel.querySelector("#response-content-info-header") - .hasAttribute("hidden"), false, - "The response info header doesn't have the intended visibility."); - is(tabpanel.querySelector("#response-content-info-header") - .getAttribute("value"), - "SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 40 of the JSON data", - "The response info header doesn't have the intended value attribute."); - is(tabpanel.querySelector("#response-content-info-header") - .getAttribute("tooltiptext"), - "SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 40 of the JSON data", - "The response info header doesn't have the intended tooltiptext attribute."); - - is(tabpanel.querySelector("#response-content-json-box") - .hasAttribute("hidden"), true, - "The response content json box doesn't have the intended visibility."); - is(tabpanel.querySelector("#response-content-textarea-box") - .hasAttribute("hidden"), false, - "The response content textarea box doesn't have the intended visibility."); - is(tabpanel.querySelector("#response-content-image-box") - .hasAttribute("hidden"), true, - "The response content image box doesn't have the intended visibility."); - - NetMonitorView.editor("#response-content-textarea").then((aEditor) => { - is(aEditor.getText(), "{ \"greeting\": \"Hello malformed JSON!\" },", - "The text shown in the source editor is incorrect."); - is(aEditor.getMode(), Editor.modes.js, - "The mode active in the source editor is incorrect."); - - teardown(aMonitor).then(finish); - }); - }); - }); - - aDebuggee.performRequests(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_json_custom_mime.js b/browser/devtools/netmonitor/test/browser_net_json_custom_mime.js deleted file mode 100644 index 340c3307e..000000000 --- a/browser/devtools/netmonitor/test/browser_net_json_custom_mime.js +++ /dev/null @@ -1,81 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if JSON responses with unusal/custom MIME types are handled correctly. - */ - -function test() { - initNetMonitor(JSON_CUSTOM_MIME_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, L10N, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 1).then(() => { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0), - "GET", CONTENT_TYPE_SJS + "?fmt=json-custom-mime", { - status: 200, - statusText: "OK", - type: "x-bigcorp-json", - fullMimeType: "text/x-bigcorp-json; charset=utf-8", - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.04), - time: true - }); - - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.getElementById("details-pane-toggle")); - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.querySelectorAll("#details-pane tab")[3]); - - let RESPONSE_BODY_DISPLAYED = aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED; - waitFor(aMonitor.panelWin, RESPONSE_BODY_DISPLAYED) - .then(testResponseTab) - .then(() => teardown(aMonitor)) - .then(finish); - - function testResponseTab() { - let tab = document.querySelectorAll("#details-pane tab")[3]; - let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3]; - - is(tab.getAttribute("selected"), "true", - "The response tab in the network details pane should be selected."); - - is(tabpanel.querySelector("#response-content-info-header") - .hasAttribute("hidden"), true, - "The response info header doesn't have the intended visibility."); - is(tabpanel.querySelector("#response-content-json-box") - .hasAttribute("hidden"), false, - "The response content json box doesn't have the intended visibility."); - is(tabpanel.querySelector("#response-content-textarea-box") - .hasAttribute("hidden"), true, - "The response content textarea box doesn't have the intended visibility."); - is(tabpanel.querySelector("#response-content-image-box") - .hasAttribute("hidden"), true, - "The response content image box doesn't have the intended visibility."); - - is(tabpanel.querySelectorAll(".variables-view-scope").length, 1, - "There should be 1 json scope displayed in this tabpanel."); - is(tabpanel.querySelectorAll(".variables-view-property").length, 2, - "There should be 2 json properties displayed in this tabpanel."); - is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0, - "The empty notice should not be displayed in this tabpanel."); - - let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; - is(jsonScope.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"), - "greeting", "The first json property name was incorrect."); - is(jsonScope.querySelectorAll(".variables-view-property .value")[0].getAttribute("value"), - "\"Hello oddly-named JSON!\"", "The first json property value was incorrect."); - - is(jsonScope.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"), - "__proto__", "The second json property name was incorrect."); - is(jsonScope.querySelectorAll(".variables-view-property .value")[1].getAttribute("value"), - "Object", "The second json property value was incorrect."); - } - }); - - aDebuggee.performRequests(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_json_text_mime.js b/browser/devtools/netmonitor/test/browser_net_json_text_mime.js deleted file mode 100644 index 2057881de..000000000 --- a/browser/devtools/netmonitor/test/browser_net_json_text_mime.js +++ /dev/null @@ -1,81 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if JSON responses with unusal/custom MIME types are handled correctly. - */ - -function test() { - initNetMonitor(JSON_TEXT_MIME_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, L10N, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 1).then(() => { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0), - "GET", CONTENT_TYPE_SJS + "?fmt=json-text-mime", { - status: 200, - statusText: "OK", - type: "plain", - fullMimeType: "text/plain; charset=utf-8", - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.04), - time: true - }); - - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.getElementById("details-pane-toggle")); - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.querySelectorAll("#details-pane tab")[3]); - - let RESPONSE_BODY_DISPLAYED = aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED; - waitFor(aMonitor.panelWin, RESPONSE_BODY_DISPLAYED) - .then(testResponseTab) - .then(() => teardown(aMonitor)) - .then(finish); - - function testResponseTab() { - let tab = document.querySelectorAll("#details-pane tab")[3]; - let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3]; - - is(tab.getAttribute("selected"), "true", - "The response tab in the network details pane should be selected."); - - is(tabpanel.querySelector("#response-content-info-header") - .hasAttribute("hidden"), true, - "The response info header doesn't have the intended visibility."); - is(tabpanel.querySelector("#response-content-json-box") - .hasAttribute("hidden"), false, - "The response content json box doesn't have the intended visibility."); - is(tabpanel.querySelector("#response-content-textarea-box") - .hasAttribute("hidden"), true, - "The response content textarea box doesn't have the intended visibility."); - is(tabpanel.querySelector("#response-content-image-box") - .hasAttribute("hidden"), true, - "The response content image box doesn't have the intended visibility."); - - is(tabpanel.querySelectorAll(".variables-view-scope").length, 1, - "There should be 1 json scope displayed in this tabpanel."); - is(tabpanel.querySelectorAll(".variables-view-property").length, 2, - "There should be 2 json properties displayed in this tabpanel."); - is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0, - "The empty notice should not be displayed in this tabpanel."); - - let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; - is(jsonScope.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"), - "greeting", "The first json property name was incorrect."); - is(jsonScope.querySelectorAll(".variables-view-property .value")[0].getAttribute("value"), - "\"Hello third-party JSON!\"", "The first json property value was incorrect."); - - is(jsonScope.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"), - "__proto__", "The second json property name was incorrect."); - is(jsonScope.querySelectorAll(".variables-view-property .value")[1].getAttribute("value"), - "Object", "The second json property value was incorrect."); - } - }); - - aDebuggee.performRequests(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_jsonp.js b/browser/devtools/netmonitor/test/browser_net_jsonp.js deleted file mode 100644 index 871bc7b3a..000000000 --- a/browser/devtools/netmonitor/test/browser_net_jsonp.js +++ /dev/null @@ -1,105 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if JSONP responses are handled correctly. - */ - -function test() { - initNetMonitor(JSONP_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, L10N, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu, NetworkDetails } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - NetworkDetails._json.lazyEmpty = false; - - waitForNetworkEvents(aMonitor, 2).then(() => { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0), - "GET", CONTENT_TYPE_SJS + "?fmt=jsonp&jsonp=$_0123Fun", { - status: 200, - statusText: "OK", - type: "json", - fullMimeType: "text/json; charset=utf-8", - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.04), - time: true - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(1), - "GET", CONTENT_TYPE_SJS + "?fmt=jsonp2&jsonp=$_4567Sad", { - status: 200, - statusText: "OK", - type: "json", - fullMimeType: "text/json; charset=utf-8", - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.05), - time: true - }); - - Task.spawn(function*() { - let RESPONSE_BODY_DISPLAYED = aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED; - - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.getElementById("details-pane-toggle")); - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.querySelectorAll("#details-pane tab")[3]); - - yield waitFor(aMonitor.panelWin, RESPONSE_BODY_DISPLAYED); - testResponseTab("$_0123Fun", "\"Hello JSONP!\""); - - RequestsMenu.selectedIndex = 1; - - yield waitFor(aMonitor.panelWin, RESPONSE_BODY_DISPLAYED); - testResponseTab("$_4567Sad", "\"Hello weird JSONP!\""); - - yield teardown(aMonitor); - finish(); - }); - - function testResponseTab(aFunction, aGreeting) { - let tab = document.querySelectorAll("#details-pane tab")[3]; - let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3]; - - is(tab.getAttribute("selected"), "true", - "The response tab in the network details pane should be selected."); - - is(tabpanel.querySelector("#response-content-info-header") - .hasAttribute("hidden"), true, - "The response info header doesn't have the intended visibility."); - is(tabpanel.querySelector("#response-content-json-box") - .hasAttribute("hidden"), false, - "The response content json box doesn't have the intended visibility."); - is(tabpanel.querySelector("#response-content-textarea-box") - .hasAttribute("hidden"), true, - "The response content textarea box doesn't have the intended visibility."); - is(tabpanel.querySelector("#response-content-image-box") - .hasAttribute("hidden"), true, - "The response content image box doesn't have the intended visibility."); - - is(tabpanel.querySelectorAll(".variables-view-scope").length, 1, - "There should be 1 json scope displayed in this tabpanel."); - is(tabpanel.querySelectorAll(".variables-view-property").length, 2, - "There should be 2 json properties displayed in this tabpanel."); - is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0, - "The empty notice should not be displayed in this tabpanel."); - - let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; - - is(jsonScope.querySelector(".name").getAttribute("value"), - L10N.getFormatStr("jsonpScopeName", aFunction), - "The json scope doesn't have the correct title."); - - is(jsonScope.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"), - "greeting", "The first json property name was incorrect."); - is(jsonScope.querySelectorAll(".variables-view-property .value")[0].getAttribute("value"), - aGreeting, "The first json property value was incorrect."); - - is(jsonScope.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"), - "__proto__", "The second json property name was incorrect."); - is(jsonScope.querySelectorAll(".variables-view-property .value")[1].getAttribute("value"), - "Object", "The second json property value was incorrect."); - } - }); - - aDebuggee.performRequests(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_large-response.js b/browser/devtools/netmonitor/test/browser_net_large-response.js deleted file mode 100644 index 71d3ccf94..000000000 --- a/browser/devtools/netmonitor/test/browser_net_large-response.js +++ /dev/null @@ -1,51 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if very large response contents are just displayed as plain text. - */ - -function test() { - initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - // This test could potentially be slow because over 100 KB of stuff - // is going to be requested and displayed in the source editor. - requestLongerTimeout(2); - - let { document, Editor, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 1).then(() => { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0), - "GET", CONTENT_TYPE_SJS + "?fmt=html-long", { - status: 200, - statusText: "OK" - }); - - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED, () => { - NetMonitorView.editor("#response-content-textarea").then((aEditor) => { - ok(aEditor.getText().match(/^<p>/), - "The text shown in the source editor is incorrect."); - is(aEditor.getMode(), Editor.modes.text, - "The mode active in the source editor is incorrect."); - - teardown(aMonitor).then(finish); - }); - }); - - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.getElementById("details-pane-toggle")); - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.querySelectorAll("#details-pane tab")[3]); - }); - - aDebuggee.performRequests(1, CONTENT_TYPE_SJS + "?fmt=html-long"); - }); - - // This test uses a lot of memory, so force a GC to help fragmentation. - info("Forcing GC after netmonitor test."); - Cu.forceGC(); -} diff --git a/browser/devtools/netmonitor/test/browser_net_open_request_in_tab.js b/browser/devtools/netmonitor/test/browser_net_open_request_in_tab.js deleted file mode 100644 index ea2c99157..000000000 --- a/browser/devtools/netmonitor/test/browser_net_open_request_in_tab.js +++ /dev/null @@ -1,40 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if Open in new tab works. - */ - -function test() { - waitForExplicitFinish(); - - initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test..."); - - let { NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 1).then(() => { - let requestItem = RequestsMenu.getItemAtIndex(0); - RequestsMenu.selectedItem = requestItem; - - gBrowser.tabContainer.addEventListener("TabOpen",function onOpen(event){ - ok(true, "A new tab has been opened "); - gBrowser.tabContainer.removeEventListener("TabOpen", onOpen, false); - cleanUp(); - }, false); - - RequestsMenu.openRequestInTab(); - }); - - aDebuggee.performRequests(1); - function cleanUp(){ - teardown(aMonitor).then(() => { - gBrowser.removeCurrentTab(); - finish(); - }); - } - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_page-nav.js b/browser/devtools/netmonitor/test/browser_net_page-nav.js deleted file mode 100644 index 3c0a8d519..000000000 --- a/browser/devtools/netmonitor/test/browser_net_page-nav.js +++ /dev/null @@ -1,68 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if page navigation ("close", "navigate", etc.) triggers an appropriate - * action in the network monitor. - */ - -function test() { - initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - testNavigate(() => testNavigateBack(() => testClose(() => finish()))); - - function testNavigate(aCallback) { - info("Navigating forward..."); - - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_WILL_NAVIGATE, () => { - is(aDebuggee.location, SIMPLE_URL, - "Target started navigating to the correct location."); - - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_DID_NAVIGATE, () => { - is(aDebuggee.location, NAVIGATE_URL, - "Target finished navigating to the correct location."); - - aCallback(); - }); - }); - - aDebuggee.location = NAVIGATE_URL; - } - - function testNavigateBack(aCallback) { - info("Navigating backward..."); - - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_WILL_NAVIGATE, () => { - is(aDebuggee.location, NAVIGATE_URL, - "Target started navigating back to the previous location."); - - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_DID_NAVIGATE, () => { - is(aDebuggee.location, SIMPLE_URL, - "Target finished navigating back to the previous location."); - - aCallback(); - }); - }); - - aDebuggee.location = SIMPLE_URL; - } - - function testClose(aCallback) { - info("Closing..."); - - aMonitor.once("destroyed", () => { - ok(!aMonitor._controller.client, - "There shouldn't be a client available after destruction."); - ok(!aMonitor._controller.tabClient, - "There shouldn't be a tabClient available after destruction."); - ok(!aMonitor._controller.webConsoleClient, - "There shouldn't be a webConsoleClient available after destruction."); - - aCallback(); - }); - - removeTab(aTab); - } - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_pane-collapse.js b/browser/devtools/netmonitor/test/browser_net_pane-collapse.js deleted file mode 100644 index 6434aa259..000000000 --- a/browser/devtools/netmonitor/test/browser_net_pane-collapse.js +++ /dev/null @@ -1,66 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if the network monitor panes collapse properly. - */ - -function test() { - initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, Prefs, NetMonitorView } = aMonitor.panelWin; - let detailsPane = document.getElementById("details-pane"); - let detailsPaneToggleButton = document.getElementById("details-pane-toggle"); - - ok(detailsPane.hasAttribute("pane-collapsed") && - detailsPaneToggleButton.hasAttribute("pane-collapsed"), - "The details pane should initially be hidden."); - - NetMonitorView.toggleDetailsPane({ visible: true, animated: false }); - - let width = ~~(detailsPane.getAttribute("width")); - is(width, Prefs.networkDetailsWidth, - "The details pane has an incorrect width."); - is(detailsPane.style.marginLeft, "0px", - "The details pane has an incorrect left margin."); - is(detailsPane.style.marginRight, "0px", - "The details pane has an incorrect right margin."); - ok(!detailsPane.hasAttribute("animated"), - "The details pane has an incorrect animated attribute."); - ok(!detailsPane.hasAttribute("pane-collapsed") && - !detailsPaneToggleButton.hasAttribute("pane-collapsed"), - "The details pane should at this point be visible."); - - NetMonitorView.toggleDetailsPane({ visible: false, animated: true }); - - let margin = -(width + 1) + "px"; - is(width, Prefs.networkDetailsWidth, - "The details pane has an incorrect width after collapsing."); - is(detailsPane.style.marginLeft, margin, - "The details pane has an incorrect left margin after collapsing."); - is(detailsPane.style.marginRight, margin, - "The details pane has an incorrect right margin after collapsing."); - ok(detailsPane.hasAttribute("animated"), - "The details pane has an incorrect attribute after an animated collapsing."); - ok(detailsPane.hasAttribute("pane-collapsed") && - detailsPaneToggleButton.hasAttribute("pane-collapsed"), - "The details pane should not be visible after collapsing."); - - NetMonitorView.toggleDetailsPane({ visible: true, animated: false }); - - is(width, Prefs.networkDetailsWidth, - "The details pane has an incorrect width after uncollapsing."); - is(detailsPane.style.marginLeft, "0px", - "The details pane has an incorrect left margin after uncollapsing."); - is(detailsPane.style.marginRight, "0px", - "The details pane has an incorrect right margin after uncollapsing."); - ok(!detailsPane.hasAttribute("animated"), - "The details pane has an incorrect attribute after an unanimated uncollapsing."); - ok(!detailsPane.hasAttribute("pane-collapsed") && - !detailsPaneToggleButton.hasAttribute("pane-collapsed"), - "The details pane should be visible again after uncollapsing."); - - teardown(aMonitor).then(finish); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_pane-toggle.js b/browser/devtools/netmonitor/test/browser_net_pane-toggle.js deleted file mode 100644 index 85c29c143..000000000 --- a/browser/devtools/netmonitor/test/browser_net_pane-toggle.js +++ /dev/null @@ -1,79 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if toggling the details pane works as expected. - */ - -function test() { - initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - is(document.querySelector("#details-pane-toggle") - .hasAttribute("disabled"), true, - "The pane toggle button should be disabled when the frontend is opened."); - is(document.querySelector("#details-pane-toggle") - .hasAttribute("pane-collapsed"), true, - "The pane toggle button should indicate that the details pane is " + - "collapsed when the frontend is opened."); - is(NetMonitorView.detailsPaneHidden, true, - "The details pane should be hidden when the frontend is opened."); - is(RequestsMenu.selectedItem, null, - "There should be no selected item in the requests menu."); - - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.NETWORK_EVENT, () => { - is(document.querySelector("#details-pane-toggle") - .hasAttribute("disabled"), false, - "The pane toggle button should be enabled after the first request."); - is(document.querySelector("#details-pane-toggle") - .hasAttribute("pane-collapsed"), true, - "The pane toggle button should still indicate that the details pane is " + - "collapsed after the first request."); - is(NetMonitorView.detailsPaneHidden, true, - "The details pane should still be hidden after the first request."); - is(RequestsMenu.selectedItem, null, - "There should still be no selected item in the requests menu."); - - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.getElementById("details-pane-toggle")); - - is(document.querySelector("#details-pane-toggle") - .hasAttribute("disabled"), false, - "The pane toggle button should still be enabled after being pressed."); - is(document.querySelector("#details-pane-toggle") - .hasAttribute("pane-collapsed"), false, - "The pane toggle button should now indicate that the details pane is " + - "not collapsed anymore after being pressed."); - is(NetMonitorView.detailsPaneHidden, false, - "The details pane should not be hidden after toggle button was pressed."); - isnot(RequestsMenu.selectedItem, null, - "There should be a selected item in the requests menu."); - is(RequestsMenu.selectedIndex, 0, - "The first item should be selected in the requests menu."); - - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.getElementById("details-pane-toggle")); - - is(document.querySelector("#details-pane-toggle") - .hasAttribute("disabled"), false, - "The pane toggle button should still be enabled after being pressed again."); - is(document.querySelector("#details-pane-toggle") - .hasAttribute("pane-collapsed"), true, - "The pane toggle button should now indicate that the details pane is " + - "collapsed after being pressed again."); - is(NetMonitorView.detailsPaneHidden, true, - "The details pane should now be hidden after the toggle button was pressed again."); - is(RequestsMenu.selectedItem, null, - "There should now be no selected item in the requests menu."); - - teardown(aMonitor).then(finish); - }); - - aDebuggee.location.reload(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_persistent_logs.js b/browser/devtools/netmonitor/test/browser_net_persistent_logs.js deleted file mode 100644 index 31e969178..000000000 --- a/browser/devtools/netmonitor/test/browser_net_persistent_logs.js +++ /dev/null @@ -1,53 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if the network monitor leaks on initialization and sudden destruction. - * You can also use this initialization format as a template for other tests. - */ - -function test() { - let monitor, reqMenu; - initNetMonitor(SINGLE_GET_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - monitor = aMonitor; - let { document, NetMonitorView, NetMonitorController } = aMonitor.panelWin; - let { RequestsMenu, NetworkDetails } = NetMonitorView; - reqMenu = RequestsMenu; - - Services.prefs.setBoolPref("devtools.webconsole.persistlog", false); - content.location.reload(true); - }) - .then(() => { - return waitForNetworkEvents(monitor, 2); - }) - .then(() => { - is(reqMenu.itemCount, 2, - "The request menu should have two items at this point."); - }) - .then(() => { - content.location.reload(true); - return waitForNetworkEvents(monitor, 2); - }) - .then(() => { - // Since the reload clears the log, we still expect two requests in the log - is(reqMenu.itemCount, 2, - "The request menu should still have two items at this point."); - }) - .then(() => { - // Now we toggle the persistence logs on - Services.prefs.setBoolPref("devtools.webconsole.persistlog", true); - content.location.reload(true); - return waitForNetworkEvents(monitor, 2); - }) - .then(() => { - // Since we togged the persistence logs, we expect four items after the reload - is(reqMenu.itemCount, 4, - "The request menu should now have four items at this point."); - }) - .then(() => { - Services.prefs.setBoolPref("devtools.webconsole.persistlog", false); - return teardown(monitor).then(finish); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_post-data-01.js b/browser/devtools/netmonitor/test/browser_net_post-data-01.js deleted file mode 100644 index 661606174..000000000 --- a/browser/devtools/netmonitor/test/browser_net_post-data-01.js +++ /dev/null @@ -1,153 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if the POST requests display the correct information in the UI. - */ - -function test() { - initNetMonitor(POST_DATA_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, L10N, Editor, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu, NetworkDetails } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - NetworkDetails._params.lazyEmpty = false; - - waitForNetworkEvents(aMonitor, 0, 2).then(() => { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0), - "POST", SIMPLE_SJS + "?foo=bar&baz=42&type=urlencoded", { - status: 200, - statusText: "Och Aye", - type: "plain", - fullMimeType: "text/plain; charset=utf-8", - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.01), - time: true - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(1), - "POST", SIMPLE_SJS + "?foo=bar&baz=42&type=multipart", { - status: 200, - statusText: "Och Aye", - type: "plain", - fullMimeType: "text/plain; charset=utf-8", - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.01), - time: true - }); - - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.getElementById("details-pane-toggle")); - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.querySelectorAll("#details-pane tab")[2]); - - let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED; - waitFor(aMonitor.panelWin, TAB_UPDATED).then(() => - testParamsTab("urlencoded") - ).then(() => { - RequestsMenu.selectedIndex = 1; - return waitFor(aMonitor.panelWin, TAB_UPDATED); - }).then(() => testParamsTab("multipart")) - .then(() => teardown(aMonitor)) - .then(finish); - - function testParamsTab(aType) { - let tab = document.querySelectorAll("#details-pane tab")[2]; - let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2]; - - is(tab.getAttribute("selected"), "true", - "The params tab in the network details pane should be selected."); - - function checkVisibility(aBox) { - is(tabpanel.querySelector("#request-params-box") - .hasAttribute("hidden"), !aBox.contains("params"), - "The request params box doesn't have the indended visibility."); - is(tabpanel.querySelector("#request-post-data-textarea-box") - .hasAttribute("hidden"), !aBox.contains("textarea"), - "The request post data textarea box doesn't have the indended visibility."); - } - - is(tabpanel.querySelectorAll(".variables-view-scope").length, 2, - "There should be 2 param scopes displayed in this tabpanel."); - is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0, - "The empty notice should not be displayed in this tabpanel."); - - let queryScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; - let postScope = tabpanel.querySelectorAll(".variables-view-scope")[1]; - - is(queryScope.querySelector(".name").getAttribute("value"), - L10N.getStr("paramsQueryString"), - "The query scope doesn't have the correct title."); - - is(postScope.querySelector(".name").getAttribute("value"), - L10N.getStr(aType == "urlencoded" ? "paramsFormData" : "paramsPostPayload"), - "The post scope doesn't have the correct title."); - - is(queryScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"), - "foo", "The first query param name was incorrect."); - is(queryScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"), - "\"bar\"", "The first query param value was incorrect."); - is(queryScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"), - "baz", "The second query param name was incorrect."); - is(queryScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"), - "\"42\"", "The second query param value was incorrect."); - is(queryScope.querySelectorAll(".variables-view-variable .name")[2].getAttribute("value"), - "type", "The third query param name was incorrect."); - is(queryScope.querySelectorAll(".variables-view-variable .value")[2].getAttribute("value"), - "\"" + aType + "\"", "The third query param value was incorrect."); - - if (aType == "urlencoded") { - checkVisibility("params"); - - is(tabpanel.querySelectorAll(".variables-view-variable").length, 5, - "There should be 5 param values displayed in this tabpanel."); - is(queryScope.querySelectorAll(".variables-view-variable").length, 3, - "There should be 3 param values displayed in the query scope."); - is(postScope.querySelectorAll(".variables-view-variable").length, 2, - "There should be 2 param values displayed in the post scope."); - - is(postScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"), - "foo", "The first post param name was incorrect."); - is(postScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"), - "\"bar\"", "The first post param value was incorrect."); - is(postScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"), - "baz", "The second post param name was incorrect."); - is(postScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"), - "\"123\"", "The second post param value was incorrect."); - - return promise.resolve(); - } - else { - checkVisibility("params textarea"); - - is(tabpanel.querySelectorAll(".variables-view-variable").length, 3, - "There should be 3 param values displayed in this tabpanel."); - is(queryScope.querySelectorAll(".variables-view-variable").length, 3, - "There should be 3 param values displayed in the query scope."); - is(postScope.querySelectorAll(".variables-view-variable").length, 0, - "There should be 0 param values displayed in the post scope."); - - return NetMonitorView.editor("#request-post-data-textarea").then((aEditor) => { - ok(aEditor.getText().contains("Content-Disposition: form-data; name=\"text\""), - "The text shown in the source editor is incorrect (1.1)."); - ok(aEditor.getText().contains("Content-Disposition: form-data; name=\"email\""), - "The text shown in the source editor is incorrect (2.1)."); - ok(aEditor.getText().contains("Content-Disposition: form-data; name=\"range\""), - "The text shown in the source editor is incorrect (3.1)."); - ok(aEditor.getText().contains("Content-Disposition: form-data; name=\"Custom field\""), - "The text shown in the source editor is incorrect (4.1)."); - ok(aEditor.getText().contains("Some text..."), - "The text shown in the source editor is incorrect (2.2)."); - ok(aEditor.getText().contains("42"), - "The text shown in the source editor is incorrect (3.2)."); - ok(aEditor.getText().contains("Extra data"), - "The text shown in the source editor is incorrect (4.2)."); - is(aEditor.getMode(), Editor.modes.text, - "The mode active in the source editor is incorrect."); - }); - } - } - }); - - aDebuggee.performRequests(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_post-data-02.js b/browser/devtools/netmonitor/test/browser_net_post-data-02.js deleted file mode 100644 index 7799bef3c..000000000 --- a/browser/devtools/netmonitor/test/browser_net_post-data-02.js +++ /dev/null @@ -1,65 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if the POST requests display the correct information in the UI, - * for raw payloads with attached content-type headers. - */ - -function test() { - initNetMonitor(POST_RAW_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, L10N, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu, NetworkDetails } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - NetworkDetails._params.lazyEmpty = false; - - waitForNetworkEvents(aMonitor, 0, 1).then(() => { - NetMonitorView.toggleDetailsPane({ visible: true }, 2) - RequestsMenu.selectedIndex = 0; - - let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED; - waitFor(aMonitor.panelWin, TAB_UPDATED).then(() => { - let tab = document.querySelectorAll("#event-details-pane tab")[2]; - let tabpanel = document.querySelectorAll("#event-details-pane tabpanel")[2]; - - is(tab.getAttribute("selected"), "true", - "The params tab in the network details pane should be selected."); - - is(tabpanel.querySelector("#request-params-box") - .hasAttribute("hidden"), false, - "The request params box doesn't have the indended visibility."); - is(tabpanel.querySelector("#request-post-data-textarea-box") - .hasAttribute("hidden"), true, - "The request post data textarea box doesn't have the indended visibility."); - - is(tabpanel.querySelectorAll(".variables-view-scope").length, 1, - "There should be 1 param scopes displayed in this tabpanel."); - is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0, - "The empty notice should not be displayed in this tabpanel."); - - let postScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; - is(postScope.querySelector(".name").getAttribute("value"), - L10N.getStr("paramsFormData"), - "The post scope doesn't have the correct title."); - - is(postScope.querySelectorAll(".variables-view-variable").length, 2, - "There should be 2 param values displayed in the post scope."); - is(postScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"), - "foo", "The first query param name was incorrect."); - is(postScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"), - "\"bar\"", "The first query param value was incorrect."); - is(postScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"), - "baz", "The second query param name was incorrect."); - is(postScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"), - "\"123\"", "The second query param value was incorrect."); - - teardown(aMonitor).then(finish); - }); - }); - - aDebuggee.performRequests(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_post-data-03.js b/browser/devtools/netmonitor/test/browser_net_post-data-03.js deleted file mode 100644 index 620111abe..000000000 --- a/browser/devtools/netmonitor/test/browser_net_post-data-03.js +++ /dev/null @@ -1,87 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if the POST requests display the correct information in the UI, - * for raw payloads with content-type headers attached to the upload stream. - */ - -function test() { - initNetMonitor(POST_RAW_WITH_HEADERS_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, L10N, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu, NetworkDetails } = NetMonitorView; - let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED; - RequestsMenu.lazyUpdate = false; - - Task.spawn(function*() { - yield waitForNetworkEvents(aMonitor, 0, 1); - - NetMonitorView.toggleDetailsPane({ visible: true }); - RequestsMenu.selectedIndex = 0; - - yield waitFor(aMonitor.panelWin, TAB_UPDATED); - - let tab = document.querySelectorAll("#details-pane tab")[0]; - let tabpanel = document.querySelectorAll("#details-pane tabpanel")[0]; - let requestFromUploadScope = tabpanel.querySelectorAll(".variables-view-scope")[2]; - - is(tab.getAttribute("selected"), "true", - "The headers tab in the network details pane should be selected."); - is(tabpanel.querySelectorAll(".variables-view-scope").length, 3, - "There should be 3 header scopes displayed in this tabpanel."); - - is(requestFromUploadScope.querySelector(".name").getAttribute("value"), - L10N.getStr("requestHeadersFromUpload") + " (" + - L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(74/1024, 3)) + ")", - "The request headers from upload scope doesn't have the correct title."); - - is(requestFromUploadScope.querySelectorAll(".variables-view-variable").length, 2, - "There should be 2 header values displayed in the request headers from upload scope."); - - is(requestFromUploadScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"), - "content-type", "The first request header name was incorrect."); - is(requestFromUploadScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"), - "\"application/x-www-form-urlencoded\"", "The first request header value was incorrect."); - is(requestFromUploadScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"), - "custom-header", "The second request header name was incorrect."); - is(requestFromUploadScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"), - "\"hello world!\"", "The second request header value was incorrect."); - - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.querySelectorAll("#details-pane tab")[2]); - - yield waitFor(aMonitor.panelWin, TAB_UPDATED); - - tab = document.querySelectorAll("#details-pane tab")[2]; - tabpanel = document.querySelectorAll("#details-pane tabpanel")[2]; - let formDataScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; - - is(tab.getAttribute("selected"), "true", - "The response tab in the network details pane should be selected."); - is(tabpanel.querySelectorAll(".variables-view-scope").length, 1, - "There should be 1 header scope displayed in this tabpanel."); - - is(formDataScope.querySelector(".name").getAttribute("value"), - L10N.getStr("paramsFormData"), - "The form data scope doesn't have the correct title."); - - is(formDataScope.querySelectorAll(".variables-view-variable").length, 2, - "There should be 2 payload values displayed in the form data scope."); - - is(formDataScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"), - "foo", "The first payload param name was incorrect."); - is(formDataScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"), - "\"bar\"", "The first payload param value was incorrect."); - is(formDataScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"), - "baz", "The second payload param name was incorrect."); - is(formDataScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"), - "\"123\"", "The second payload param value was incorrect."); - - teardown(aMonitor).then(finish); - }); - - aDebuggee.performRequests(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_prefs-and-l10n.js b/browser/devtools/netmonitor/test/browser_net_prefs-and-l10n.js deleted file mode 100644 index 1882f30a6..000000000 --- a/browser/devtools/netmonitor/test/browser_net_prefs-and-l10n.js +++ /dev/null @@ -1,67 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if the preferences and localization objects work correctly. - */ - -function test() { - initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - ok(aMonitor.panelWin.L10N, - "Should have a localization object available on the panel window."); - ok(aMonitor.panelWin.Prefs, - "Should have a preferences object available on the panel window."); - - function testL10N() { - let { L10N } = aMonitor.panelWin; - - ok(L10N.stringBundle, - "The localization object should have a string bundle available."); - - let bundleName = "chrome://browser/locale/devtools/netmonitor.properties"; - let stringBundle = Services.strings.createBundle(bundleName); - - is(L10N.getStr("netmonitor.label"), - stringBundle.GetStringFromName("netmonitor.label"), - "The getStr() method didn't return the expected string."); - - is(L10N.getFormatStr("networkMenu.totalMS", "foo"), - stringBundle.formatStringFromName("networkMenu.totalMS", ["foo"], 1), - "The getFormatStr() method didn't return the expected string."); - } - - function testPrefs() { - let { Prefs } = aMonitor.panelWin; - - is(Prefs._root, "devtools.netmonitor", - "The preferences object should have a correct root path."); - - is(Prefs.networkDetailsWidth, - Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"), - "Getting a pref should work correctly."); - - let previousValue = Prefs.networkDetailsWidth; - let bogusValue = ~~(Math.random() * 100); - Prefs.networkDetailsWidth = bogusValue; - is(Prefs.networkDetailsWidth, - Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"), - "Getting a pref after it has been modified should work correctly."); - is(Prefs.networkDetailsWidth, bogusValue, - "The pref wasn't updated correctly in the preferences object."); - - Prefs.networkDetailsWidth = previousValue; - is(Prefs.networkDetailsWidth, - Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"), - "Getting a pref after it has been modified again should work correctly."); - is(Prefs.networkDetailsWidth, previousValue, - "The pref wasn't updated correctly again in the preferences object."); - } - - testL10N(); - testPrefs(); - - teardown(aMonitor).then(finish); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_prefs-reload.js b/browser/devtools/netmonitor/test/browser_net_prefs-reload.js deleted file mode 100644 index 669ec31f2..000000000 --- a/browser/devtools/netmonitor/test/browser_net_prefs-reload.js +++ /dev/null @@ -1,233 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if the prefs that should survive across tool reloads work. - */ - -function test() { - initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - // This test reopens the network monitor a bunch of times, for different - // hosts (bottom, side, window). This seems to be slow on debug builds. - requestLongerTimeout(3); - - // Use these getters instead of caching instances inside the panel win, - // since the tool is reopened a bunch of times during this test - // and the instances will differ. - let getView = () => aMonitor.panelWin.NetMonitorView; - let getController = () => aMonitor.panelWin.NetMonitorController; - - let prefsToCheck = { - filters: { - // A custom new value to be used for the verified preference. - newValue: ["html", "css"], - // Getter used to retrieve the current value from the frontend, in order - // to verify that the pref was applied properly. - validateValue: ($) => getView().RequestsMenu._activeFilters, - // Predicate used to modify the frontend when setting the new pref value, - // before trying to validate the changes. - modifyFrontend: ($, aValue) => aValue.forEach(e => getView().RequestsMenu.filterOn(e)) - }, - networkDetailsWidth: { - newValue: ~~(Math.random() * 200 + 100), - validateValue: ($) => ~~$("#details-pane").getAttribute("width"), - modifyFrontend: ($, aValue) => $("#details-pane").setAttribute("width", aValue) - }, - networkDetailsHeight: { - newValue: ~~(Math.random() * 300 + 100), - validateValue: ($) => ~~$("#details-pane").getAttribute("height"), - modifyFrontend: ($, aValue) => $("#details-pane").setAttribute("height", aValue) - } - /* add more prefs here... */ - }; - - function storeFirstPrefValues() { - info("Caching initial pref values."); - - for (let name in prefsToCheck) { - let currentValue = aMonitor.panelWin.Prefs[name]; - prefsToCheck[name].firstValue = currentValue; - } - } - - function validateFirstPrefValues() { - info("Validating current pref values to the UI elements."); - - for (let name in prefsToCheck) { - let currentValue = aMonitor.panelWin.Prefs[name]; - let firstValue = prefsToCheck[name].firstValue; - let validateValue = prefsToCheck[name].validateValue; - - is(currentValue.toSource(), firstValue.toSource(), - "Pref " + name + " should be equal to first value: " + firstValue); - is(currentValue.toSource(), validateValue(aMonitor.panelWin.$).toSource(), - "Pref " + name + " should validate: " + currentValue); - } - } - - function modifyFrontend() { - info("Modifying UI elements to the specified new values."); - - for (let name in prefsToCheck) { - let currentValue = aMonitor.panelWin.Prefs[name]; - let firstValue = prefsToCheck[name].firstValue; - let newValue = prefsToCheck[name].newValue; - let validateValue = prefsToCheck[name].validateValue; - let modifyFrontend = prefsToCheck[name].modifyFrontend; - - modifyFrontend(aMonitor.panelWin.$, newValue); - info("Modified UI element affecting " + name + " to: " + newValue); - - is(currentValue.toSource(), firstValue.toSource(), - "Pref " + name + " should still be equal to first value: " + firstValue); - isnot(currentValue.toSource(), newValue.toSource(), - "Pref " + name + " should't yet be equal to second value: " + newValue); - is(newValue.toSource(), validateValue(aMonitor.panelWin.$).toSource(), - "The UI element affecting " + name + " should validate: " + newValue); - } - } - - function validateNewPrefValues() { - info("Invalidating old pref values to the modified UI elements."); - - for (let name in prefsToCheck) { - let currentValue = aMonitor.panelWin.Prefs[name]; - let firstValue = prefsToCheck[name].firstValue; - let newValue = prefsToCheck[name].newValue; - let validateValue = prefsToCheck[name].validateValue; - - isnot(currentValue.toSource(), firstValue.toSource(), - "Pref " + name + " should't be equal to first value: " + firstValue); - is(currentValue.toSource(), newValue.toSource(), - "Pref " + name + " should now be equal to second value: " + newValue); - is(newValue.toSource(), validateValue(aMonitor.panelWin.$).toSource(), - "The UI element affecting " + name + " should validate: " + newValue); - } - } - - function resetFrontend() { - info("Resetting UI elements to the cached initial pref values."); - - for (let name in prefsToCheck) { - let currentValue = aMonitor.panelWin.Prefs[name]; - let firstValue = prefsToCheck[name].firstValue; - let newValue = prefsToCheck[name].newValue; - let validateValue = prefsToCheck[name].validateValue; - let modifyFrontend = prefsToCheck[name].modifyFrontend; - - modifyFrontend(aMonitor.panelWin.$, firstValue); - info("Modified UI element affecting " + name + " to: " + firstValue); - - isnot(currentValue.toSource(), firstValue.toSource(), - "Pref " + name + " should't yet be equal to first value: " + firstValue); - is(currentValue.toSource(), newValue.toSource(), - "Pref " + name + " should still be equal to second value: " + newValue); - is(firstValue.toSource(), validateValue(aMonitor.panelWin.$).toSource(), - "The UI element affecting " + name + " should validate: " + firstValue); - } - } - - function testBottom() { - info("Testing prefs reload for a bottom host."); - storeFirstPrefValues(); - - // Validate and modify while toolbox is on the bottom. - validateFirstPrefValues(); - modifyFrontend(); - - return restartNetMonitor(aMonitor) - .then(([,, aNewMonitor]) => { - aMonitor = aNewMonitor; - - // Revalidate and reset frontend while toolbox is on the bottom. - validateNewPrefValues(); - resetFrontend(); - - return restartNetMonitor(aMonitor); - }) - .then(([,, aNewMonitor]) => { - aMonitor = aNewMonitor; - - // Revalidate. - validateFirstPrefValues(); - }); - } - - function testSide() { - info("Moving toolbox to the side..."); - - return aMonitor._toolbox.switchHost(Toolbox.HostType.SIDE) - .then(() => { - info("Testing prefs reload for a side host."); - storeFirstPrefValues(); - - // Validate and modify frontend while toolbox is on the side. - validateFirstPrefValues(); - modifyFrontend(); - - return restartNetMonitor(aMonitor); - }) - .then(([,, aNewMonitor]) => { - aMonitor = aNewMonitor; - - // Revalidate and reset frontend while toolbox is on the side. - validateNewPrefValues(); - resetFrontend(); - - return restartNetMonitor(aMonitor); - }) - .then(([,, aNewMonitor]) => { - aMonitor = aNewMonitor; - - // Revalidate. - validateFirstPrefValues(); - }); - } - - function testWindow() { - info("Moving toolbox into a window..."); - - return aMonitor._toolbox.switchHost(Toolbox.HostType.WINDOW) - .then(() => { - info("Testing prefs reload for a window host."); - storeFirstPrefValues(); - - // Validate and modify frontend while toolbox is in a window. - validateFirstPrefValues(); - modifyFrontend(); - - return restartNetMonitor(aMonitor); - }) - .then(([,, aNewMonitor]) => { - aMonitor = aNewMonitor; - - // Revalidate and reset frontend while toolbox is in a window. - validateNewPrefValues(); - resetFrontend(); - - return restartNetMonitor(aMonitor); - }) - .then(([,, aNewMonitor]) => { - aMonitor = aNewMonitor; - - // Revalidate. - validateFirstPrefValues(); - }); - } - - function cleanupAndFinish() { - info("Moving toolbox back to the bottom..."); - - aMonitor._toolbox.switchHost(Toolbox.HostType.BOTTOM) - .then(() => teardown(aMonitor)) - .then(finish); - } - - testBottom() - .then(testSide) - .then(testWindow) - .then(cleanupAndFinish); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_raw_headers.js b/browser/devtools/netmonitor/test/browser_net_raw_headers.js deleted file mode 100644 index 2c57d47cd..000000000 --- a/browser/devtools/netmonitor/test/browser_net_raw_headers.js +++ /dev/null @@ -1,72 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -let gPanelWin; -let gPanelDoc; - -/** - * Tests if showing raw headers works. - */ - -function test() { - initNetMonitor(POST_DATA_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - gPanelWin = aMonitor.panelWin; - gPanelDoc = gPanelWin.document; - - let { document, Editor, NetMonitorView } = gPanelWin; - let { RequestsMenu } = NetMonitorView; - let TAB_UPDATED = gPanelWin.EVENTS.TAB_UPDATED; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 0, 2).then(() => { - let origItem = RequestsMenu.getItemAtIndex(0); - RequestsMenu.selectedItem = origItem; - - waitFor(aMonitor.panelWin, TAB_UPDATED).then(() => { - EventUtils.sendMouseEvent({ type: "click" }, document.getElementById("toggle-raw-headers")); - testShowRawHeaders(origItem.attachment); - EventUtils.sendMouseEvent({ type: "click" }, document.getElementById("toggle-raw-headers")); - testHideRawHeaders(document); - finishUp(aMonitor); - }); - }); - - aDebuggee.performRequests(); - }); -} - -/* - * Tests that raw headers were displayed correctly - */ -function testShowRawHeaders(aData) { - let requestHeaders = gPanelDoc.getElementById("raw-request-headers-textarea").value; - for (let header of aData.requestHeaders.headers) { - ok(requestHeaders.indexOf(header.name + ": " + header.value) >= 0, "textarea contains request headers"); - } - let responseHeaders = gPanelDoc.getElementById("raw-response-headers-textarea").value; - for (let header of aData.responseHeaders.headers) { - ok(responseHeaders.indexOf(header.name + ": " + header.value) >= 0, "textarea contains response headers"); - } -} - -/* - * Tests that raw headers textareas are hidden and empty - */ -function testHideRawHeaders(document) { - let rawHeadersHidden = document.getElementById("raw-headers").getAttribute("hidden"); - let requestTextarea = document.getElementById("raw-request-headers-textarea"); - let responseTextare = document.getElementById("raw-response-headers-textarea"); - ok(rawHeadersHidden, "raw headers textareas are hidden"); - ok(requestTextarea.value == '', "raw request headers textarea is empty"); - ok(responseTextare.value == '', "raw response headers textarea is empty"); -} - -function finishUp(aMonitor) { - gPanelWin = null; - gPanelDoc = null; - - teardown(aMonitor).then(finish); -} diff --git a/browser/devtools/netmonitor/test/browser_net_reload-button.js b/browser/devtools/netmonitor/test/browser_net_reload-button.js deleted file mode 100644 index ab551b124..000000000 --- a/browser/devtools/netmonitor/test/browser_net_reload-button.js +++ /dev/null @@ -1,34 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if the empty-requests reload button works. - */ - -function test() { - let monitor, reqMenu; - initNetMonitor(SINGLE_GET_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - monitor = aMonitor; - let { document, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - reqMenu = RequestsMenu; - - is(reqMenu.itemCount, 0, - "The request menu should empty before reloading"); - - let button = document.querySelector("#requests-menu-reload-notice-button"); - button.click(); - }) - .then(() => { - return waitForNetworkEvents(monitor, 2); - }) - .then(() => { - is(reqMenu.itemCount, 2, - "The request menu should have two items after reloading"); - }) - .then(() => { - return teardown(monitor).then(finish); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_req-resp-bodies.js b/browser/devtools/netmonitor/test/browser_net_req-resp-bodies.js deleted file mode 100644 index 1f1a55a16..000000000 --- a/browser/devtools/netmonitor/test/browser_net_req-resp-bodies.js +++ /dev/null @@ -1,60 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Test if request and response body logging stays on after opening the console. - */ - -function test() { - initNetMonitor(JSON_LONG_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { L10N, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - function verifyRequest(aOffset) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOffset), - "GET", CONTENT_TYPE_SJS + "?fmt=json-long", { - status: 200, - statusText: "OK", - type: "json", - fullMimeType: "text/json; charset=utf-8", - size: L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(85975/1024, 2)), - time: true - }); - } - - waitForNetworkEvents(aMonitor, 1).then(() => { - verifyRequest(0); - - aMonitor._toolbox.once("webconsole-selected", () => { - aMonitor._toolbox.once("netmonitor-selected", () => { - - waitForNetworkEvents(aMonitor, 1).then(() => { - waitForNetworkEvents(aMonitor, 1).then(() => { - verifyRequest(1); - teardown(aMonitor).then(finish); - }); - - // Perform another batch of requests. - aDebuggee.performRequests(); - }); - - // Reload debugee. - aDebuggee.location.reload(); - }); - - // Switch back to the netmonitor. - aMonitor._toolbox.selectTool("netmonitor"); - }); - - // Switch to the webconsole. - aMonitor._toolbox.selectTool("webconsole"); - }); - - // Perform first batch of requests. - aDebuggee.performRequests(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_resend.js b/browser/devtools/netmonitor/test/browser_net_resend.js deleted file mode 100644 index cb3f196e9..000000000 --- a/browser/devtools/netmonitor/test/browser_net_resend.js +++ /dev/null @@ -1,173 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -let gPanelWin; -let gPanelDoc; - -const ADD_QUERY = "t1=t2"; -const ADD_HEADER = "Test-header: true"; -const ADD_POSTDATA = "t3=t4"; - -/** - * Tests if resending a request works. - */ - -function test() { - initNetMonitor(POST_DATA_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - gPanelWin = aMonitor.panelWin; - gPanelDoc = gPanelWin.document; - - let { NetMonitorView } = gPanelWin; - let { RequestsMenu } = NetMonitorView; - let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED; - let CUSTOMREQUESTVIEW_POPULATED = aMonitor.panelWin.EVENTS.CUSTOMREQUESTVIEW_POPULATED; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 0, 2).then(() => { - let origItem = RequestsMenu.getItemAtIndex(0); - RequestsMenu.selectedItem = origItem; - - waitFor(aMonitor.panelWin, TAB_UPDATED).then(() => { - // add a new custom request cloned from selected request - RequestsMenu.cloneSelectedRequest(); - return waitFor(aMonitor.panelWin, CUSTOMREQUESTVIEW_POPULATED); - }).then(() => { - testCustomForm(origItem.attachment); - - let customItem = RequestsMenu.selectedItem; - testCustomItem(customItem, origItem); - - // edit the custom request - editCustomForm(() => { - testCustomItemChanged(customItem, origItem); - - waitForNetworkEvents(aMonitor, 0, 1).then(() => { - let sentItem = RequestsMenu.selectedItem; - testSentRequest(sentItem.attachment, origItem.attachment); - finishUp(aMonitor); - }); - // send the new request - RequestsMenu.sendCustomRequest(); - }); - }); - }); - - aDebuggee.performRequests(); - }); -} - -function testCustomItem(aItem, aOrigItem) { - let method = aItem.target.querySelector(".requests-menu-method").value; - let origMethod = aOrigItem.target.querySelector(".requests-menu-method").value; - is(method, origMethod, "menu item is showing the same method as original request"); - - let file = aItem.target.querySelector(".requests-menu-file").value; - let origFile = aOrigItem.target.querySelector(".requests-menu-file").value; - is(file, origFile, "menu item is showing the same file name as original request"); - - let domain = aItem.target.querySelector(".requests-menu-domain").value; - let origDomain = aOrigItem.target.querySelector(".requests-menu-domain").value; - is(domain, origDomain, "menu item is showing the same domain as original request"); -} - -function testCustomItemChanged(aItem, aOrigItem) { - let file = aItem.target.querySelector(".requests-menu-file").value; - let expectedFile = aOrigItem.target.querySelector(".requests-menu-file").value + "&" + ADD_QUERY; - - is(file, expectedFile, "menu item is updated to reflect url entered in form"); -} - -/* - * Test that the New Request form was populated correctly - */ -function testCustomForm(aData) { - is(gPanelDoc.getElementById("custom-method-value").value, aData.method, - "new request form showing correct method"); - - is(gPanelDoc.getElementById("custom-url-value").value, aData.url, - "new request form showing correct url"); - - let query = gPanelDoc.getElementById("custom-query-value"); - is(query.value, "foo=bar\nbaz=42\ntype=urlencoded", - "new request form showing correct query string"); - - let headers = gPanelDoc.getElementById("custom-headers-value").value.split("\n"); - for (let {name, value} of aData.requestHeaders.headers) { - ok(headers.indexOf(name + ": " + value) >= 0, "form contains header from request"); - } - - let postData = gPanelDoc.getElementById("custom-postdata-value"); - is(postData.value, aData.requestPostData.postData.text, - "new request form showing correct post data"); -} - -/* - * Add some params and headers to the request form - */ -function editCustomForm(callback) { - gPanelWin.focus(); - - let query = gPanelDoc.getElementById("custom-query-value"); - query.addEventListener("focus", function onFocus() { - query.removeEventListener("focus", onFocus, false); - - // add params to url query string field - type(["VK_RETURN"]); - type(ADD_QUERY); - - let headers = gPanelDoc.getElementById("custom-headers-value"); - headers.addEventListener("focus", function onFocus() { - headers.removeEventListener("focus", onFocus, false); - - // add a header - type(["VK_RETURN"]); - type(ADD_HEADER); - - let postData = gPanelDoc.getElementById("custom-postdata-value"); - postData.addEventListener("focus", function onFocus() { - postData.removeEventListener("focus", onFocus, false); - - // add to POST data - type(ADD_POSTDATA); - callback(); - }, false); - postData.focus(); - }, false); - headers.focus(); - }, false); - query.focus(); -} - -/* - * Make sure newly created event matches expected request - */ -function testSentRequest(aData, aOrigData) { - is(aData.method, aOrigData.method, "correct method in sent request"); - is(aData.url, aOrigData.url + "&" + ADD_QUERY, "correct url in sent request"); - - let hasHeader = aData.requestHeaders.headers.some((header) => { - return (header.name + ": " + header.value) == ADD_HEADER; - }) - ok(hasHeader, "new header added to sent request"); - - is(aData.requestPostData.postData.text, - aOrigData.requestPostData.postData.text + ADD_POSTDATA, - "post data added to sent request"); -} - - -function type(aString) { - for (let ch of aString) { - EventUtils.synthesizeKey(ch, {}, gPanelWin); - } -} - -function finishUp(aMonitor) { - gPanelWin = null; - gPanelDoc = null; - - teardown(aMonitor).then(finish); -} diff --git a/browser/devtools/netmonitor/test/browser_net_security-details.js b/browser/devtools/netmonitor/test/browser_net_security-details.js deleted file mode 100644 index f4a899068..000000000 --- a/browser/devtools/netmonitor/test/browser_net_security-details.js +++ /dev/null @@ -1,99 +0,0 @@ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -/** - * Test that Security details tab contains the expected data. - */ - -add_task(function* () { - let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL); - let { $, EVENTS, NetMonitorView } = monitor.panelWin; - let { RequestsMenu, NetworkDetails } = NetMonitorView; - RequestsMenu.lazyUpdate = false; - - info("Performing a secure request."); - debuggee.performRequests(1, "https://example.com" + CORS_SJS_PATH); - - yield waitForNetworkEvents(monitor, 1); - - info("Selecting the request."); - RequestsMenu.selectedIndex = 0; - - info("Waiting for details pane to be updated."); - yield monitor.panelWin.once(EVENTS.TAB_UPDATED); - - info("Selecting security tab."); - NetworkDetails.widget.selectedIndex = 5; - - info("Waiting for security tab to be updated."); - yield monitor.panelWin.once(EVENTS.TAB_UPDATED); - - let errorbox = $("#security-error"); - let infobox = $("#security-information"); - - is(errorbox.hidden, true, "Error box is hidden."); - is(infobox.hidden, false, "Information box visible."); - - // Connection - - // The protocol will be TLS but the exact version depends on which protocol - // the test server example.com supports. - let protocol = $("#security-protocol-version-value").value; - ok(protocol.startsWith("TLS"), "The protocol " + protocol + " seems valid."); - - // The cipher suite used by the test server example.com might change at any - // moment but all of them should start with "TLS_". - // http://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml - let suite = $("#security-ciphersuite-value").value; - ok(suite.startsWith("TLS_"), "The suite " + suite + " seems valid."); - - // Host - checkLabel("#security-info-host-header", "Host example.com:"); - checkLabel("#security-http-strict-transport-security-value", "Disabled"); - checkLabel("#security-public-key-pinning-value", "Disabled"); - - // Cert - checkLabel("#security-cert-subject-cn", "example.com"); - checkLabel("#security-cert-subject-o", "<Not Available>"); - checkLabel("#security-cert-subject-ou", "<Not Available>"); - - checkLabel("#security-cert-issuer-cn", "Temporary Certificate Authority"); - checkLabel("#security-cert-issuer-o", "Mozilla Testing"); - checkLabel("#security-cert-issuer-ou", "<Not Available>"); - - // Locale sensitive and varies between timezones. Cant't compare equality or - // the test fails depending on which part of the world the test is executed. - checkLabelNotEmpty("#security-cert-validity-begins"); - checkLabelNotEmpty("#security-cert-validity-expires"); - - checkLabelNotEmpty("#security-cert-sha1-fingerprint"); - checkLabelNotEmpty("#security-cert-sha256-fingerprint"); - yield teardown(monitor); - - /** - * A helper that compares value attribute of a label with given selector to the - * expected value. - */ - function checkLabel(selector, expected) { - info("Checking label " + selector); - - let element = $(selector); - - ok(element, "Selector matched an element."); - is(element.value, expected, "Label has the expected value."); - } - - /** - * A helper that checks the label with given selector is not an empty string. - */ - function checkLabelNotEmpty(selector) { - info("Checking that label " + selector + " is non-empty."); - - let element = $(selector); - - ok(element, "Selector matched an element."); - isnot(element.value, "", "Label was not empty."); - } -}); diff --git a/browser/devtools/netmonitor/test/browser_net_security-error.js b/browser/devtools/netmonitor/test/browser_net_security-error.js deleted file mode 100644 index b4a5705e0..000000000 --- a/browser/devtools/netmonitor/test/browser_net_security-error.js +++ /dev/null @@ -1,67 +0,0 @@ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -/** - * Test that Security details tab shows an error message with broken connections. - */ - -add_task(function* () { - let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL); - let { $, EVENTS, NetMonitorView } = monitor.panelWin; - let { RequestsMenu, NetworkDetails } = NetMonitorView; - RequestsMenu.lazyUpdate = false; - - info("Requesting a resource that has a certificate problem."); - debuggee.performRequests(1, "https://nocert.example.com"); - - yield waitForSecurityBrokenNetworkEvent(); - - info("Selecting the request."); - RequestsMenu.selectedIndex = 0; - - info("Waiting for details pane to be updated."); - yield monitor.panelWin.once(EVENTS.TAB_UPDATED); - - info("Selecting security tab."); - NetworkDetails.widget.selectedIndex = 5; - - info("Waiting for security tab to be updated."); - yield monitor.panelWin.once(EVENTS.TAB_UPDATED); - - let errorbox = $("#security-error"); - let errormsg = $("#security-error-message"); - let infobox = $("#security-information"); - - is(errorbox.hidden, false, "Error box is visble."); - is(infobox.hidden, true, "Information box is hidden."); - - isnot(errormsg.value, "", "Error message is not empty."); - - yield teardown(monitor); - - /** - * Returns a promise that's resolved once a request with security issues is - * completed. - */ - function waitForSecurityBrokenNetworkEvent() { - let awaitedEvents = [ - "UPDATING_REQUEST_HEADERS", - "RECEIVED_REQUEST_HEADERS", - "UPDATING_REQUEST_COOKIES", - "RECEIVED_REQUEST_COOKIES", - "STARTED_RECEIVING_RESPONSE", - "UPDATING_RESPONSE_CONTENT", - "RECEIVED_RESPONSE_CONTENT", - "UPDATING_EVENT_TIMINGS", - "RECEIVED_EVENT_TIMINGS", - ]; - - let promises = awaitedEvents.map((event) => { - return monitor.panelWin.once(EVENTS[event]); - }); - - return Promise.all(promises); - } -}); diff --git a/browser/devtools/netmonitor/test/browser_net_security-icon-click.js b/browser/devtools/netmonitor/test/browser_net_security-icon-click.js deleted file mode 100644 index bf48b13bd..000000000 --- a/browser/devtools/netmonitor/test/browser_net_security-icon-click.js +++ /dev/null @@ -1,53 +0,0 @@ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -/** - * Test that clicking on the security indicator opens the security details tab. - */ - -add_task(function* () { - let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL); - let { $, EVENTS, NetMonitorView } = monitor.panelWin; - let { RequestsMenu, NetworkDetails } = NetMonitorView; - RequestsMenu.lazyUpdate = false; - - info("Requesting a resource over HTTPS."); - debuggee.performRequests(1, "https://example.com" + CORS_SJS_PATH + "?request_2"); - yield waitForNetworkEvents(monitor, 1); - - debuggee.performRequests(1, "https://example.com" + CORS_SJS_PATH + "?request_1"); - yield waitForNetworkEvents(monitor, 1); - - is(RequestsMenu.itemCount, 2, "Two events event logged."); - - yield clickAndTestSecurityIcon(); - - info("Selecting headers panel again."); - NetworkDetails.widget.selectedIndex = 0; - yield monitor.panelWin.once(EVENTS.TAB_UPDATED); - - info("Sorting the items by filename."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button")); - - info("Testing that security icon can be clicked after the items were sorted."); - yield clickAndTestSecurityIcon(); - - yield teardown(monitor); - - function* clickAndTestSecurityIcon() { - let item = RequestsMenu.items[0]; - let icon = $(".requests-security-state-icon", item.target); - - info("Clicking security icon of the first request and waiting for the " + - "panel to update."); - - icon.click(); - yield monitor.panelWin.once(EVENTS.TAB_UPDATED); - - is(NetworkDetails.widget.selectedPanel, $("#security-tabpanel"), - "Security tab is selected."); - } - -}); diff --git a/browser/devtools/netmonitor/test/browser_net_security-redirect.js b/browser/devtools/netmonitor/test/browser_net_security-redirect.js deleted file mode 100644 index 6a60f804b..000000000 --- a/browser/devtools/netmonitor/test/browser_net_security-redirect.js +++ /dev/null @@ -1,35 +0,0 @@ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -/** - * Test a http -> https redirect shows secure icon only for redirected https - * request. - */ - -add_task(function* () { - let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL); - let { $, NetMonitorView } = monitor.panelWin; - let { RequestsMenu } = NetMonitorView; - RequestsMenu.lazyUpdate = false; - - debuggee.performRequests(1, HTTPS_REDIRECT_SJS); - yield waitForNetworkEvents(monitor, 2); - - is(RequestsMenu.itemCount, 2, "There were two requests due to redirect."); - - let initial = RequestsMenu.items[0]; - let redirect = RequestsMenu.items[1]; - - let initialSecurityIcon = $(".requests-security-state-icon", initial.target); - let redirectSecurityIcon = $(".requests-security-state-icon", redirect.target); - - ok(initialSecurityIcon.classList.contains("security-state-insecure"), - "Initial request was marked insecure."); - - ok(redirectSecurityIcon.classList.contains("security-state-secure"), - "Redirected request was marked secure."); - - yield teardown(monitor); -}); diff --git a/browser/devtools/netmonitor/test/browser_net_security-state.js b/browser/devtools/netmonitor/test/browser_net_security-state.js deleted file mode 100644 index ae32473e6..000000000 --- a/browser/devtools/netmonitor/test/browser_net_security-state.js +++ /dev/null @@ -1,111 +0,0 @@ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -/** - * Test that correct security state indicator appears depending on the security - * state. - */ - -add_task(function* () { - const EXPECTED_SECURITY_STATES = { - "test1.example.com": "security-state-insecure", - "example.com": "security-state-secure", - "nocert.example.com": "security-state-broken", - "rc4.example.com": "security-state-weak", - }; - - yield new promise(resolve => { - SpecialPowers.pushPrefEnv({"set": [ - ["security.tls.insecure_fallback_hosts", "rc4.example.com"] - ]}, resolve); - }); - - let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL); - let { $, EVENTS, NetMonitorView } = monitor.panelWin; - let { RequestsMenu } = NetMonitorView; - RequestsMenu.lazyUpdate = false; - - yield performRequests(); - - for (let item of RequestsMenu.items) { - let domain = $(".requests-menu-domain", item.target).value; - - info("Found a request to " + domain); - ok(domain in EXPECTED_SECURITY_STATES, "Domain " + domain + " was expected."); - - let classes = $(".requests-security-state-icon", item.target).classList; - let expectedClass = EXPECTED_SECURITY_STATES[domain]; - - info("Classes of security state icon are: " + classes); - info("Security state icon is expected to contain class: " + expectedClass); - ok(classes.contains(expectedClass), "Icon contained the correct class name."); - } - - yield teardown(monitor); - - /** - * A helper that performs requests to - * - https://nocert.example.com (broken) - * - https://example.com (secure) - * - http://test1.example.com (insecure) - * and waits until NetworkMonitor has handled all packets sent by the server. - */ - function* performRequests() { - // waitForNetworkEvents does not work for requests with security errors as - // those only emit 9/13 events of a successful request. - let done = waitForSecurityBrokenNetworkEvent(); - - info("Requesting a resource that has a certificate problem."); - debuggee.performRequests(1, "https://nocert.example.com"); - - // Wait for the request to complete before firing another request. Otherwise - // the request with security issues interfere with waitForNetworkEvents. - info("Waiting for request to complete."); - yield done; - - // Next perform a request over HTTP. If done the other way around the latter - // occasionally hangs waiting for event timings that don't seem to appear... - done = waitForNetworkEvents(monitor, 1); - info("Requesting a resource over HTTP."); - debuggee.performRequests(1, "http://test1.example.com" + CORS_SJS_PATH); - yield done; - - done = waitForNetworkEvents(monitor, 1); - info("Requesting a resource over HTTPS."); - debuggee.performRequests(1, "https://example.com" + CORS_SJS_PATH); - yield done; - - done = waitForNetworkEvents(monitor, 1); - info("Requesting a resource over HTTPS with RC4."); - debuggee.performRequests(1, "https://rc4.example.com" + CORS_SJS_PATH); - yield done; - - is(RequestsMenu.itemCount, 4, "Four events logged."); - } - - /** - * Returns a promise that's resolved once a request with security issues is - * completed. - */ - function waitForSecurityBrokenNetworkEvent() { - let awaitedEvents = [ - "UPDATING_REQUEST_HEADERS", - "RECEIVED_REQUEST_HEADERS", - "UPDATING_REQUEST_COOKIES", - "RECEIVED_REQUEST_COOKIES", - "STARTED_RECEIVING_RESPONSE", - "UPDATING_RESPONSE_CONTENT", - "RECEIVED_RESPONSE_CONTENT", - "UPDATING_EVENT_TIMINGS", - "RECEIVED_EVENT_TIMINGS", - ]; - - let promises = awaitedEvents.map((event) => { - return monitor.panelWin.once(EVENTS[event]); - }); - - return Promise.all(promises); - } -}); diff --git a/browser/devtools/netmonitor/test/browser_net_security-tab-deselect.js b/browser/devtools/netmonitor/test/browser_net_security-tab-deselect.js deleted file mode 100644 index 2f45ac7aa..000000000 --- a/browser/devtools/netmonitor/test/browser_net_security-tab-deselect.js +++ /dev/null @@ -1,38 +0,0 @@ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -/** - * Test that security details tab is no longer selected if an insecure request - * is selected. - */ - -add_task(function* () { - let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL); - let { $, EVENTS, NetMonitorView } = monitor.panelWin; - let { RequestsMenu, NetworkDetails } = NetMonitorView; - RequestsMenu.lazyUpdate = false; - - info("Performing requests."); - debuggee.performRequests(1, "https://example.com" + CORS_SJS_PATH); - debuggee.performRequests(1, "http://example.com" + CORS_SJS_PATH); - yield waitForNetworkEvents(monitor, 2); - - info("Selecting secure request."); - RequestsMenu.selectedIndex = 0; - - info("Selecting security tab."); - NetworkDetails.widget.selectedIndex = 5; - - info("Selecting insecure request."); - RequestsMenu.selectedIndex = 1; - - info("Waiting for security tab to be updated."); - yield monitor.panelWin.once(EVENTS.NETWORKDETAILSVIEW_POPULATED); - - is(NetworkDetails.widget.selectedIndex, 0, - "Selected tab was reset when selected security tab was hidden."); - - yield teardown(monitor); -}); diff --git a/browser/devtools/netmonitor/test/browser_net_security-tab-visibility.js b/browser/devtools/netmonitor/test/browser_net_security-tab-visibility.js deleted file mode 100644 index bc905a5ec..000000000 --- a/browser/devtools/netmonitor/test/browser_net_security-tab-visibility.js +++ /dev/null @@ -1,111 +0,0 @@ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -/** - * Test that security details tab is visible only when it should. - */ - -add_task(function* () { - const TEST_DATA = [ - { - desc: "http request", - uri: "http://example.com" + CORS_SJS_PATH, - visibleOnNewEvent: false, - visibleOnSecurityInfo: false, - visibleOnceComplete: false, - }, { - desc: "working https request", - uri: "https://example.com" + CORS_SJS_PATH, - visibleOnNewEvent: false, - visibleOnSecurityInfo: true, - visibleOnceComplete: true, - }, { - desc: "broken https request", - uri: "https://nocert.example.com", - isBroken: true, - visibleOnNewEvent: false, - visibleOnSecurityInfo: true, - visibleOnceComplete: true, - } - ]; - - let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL); - let { $, EVENTS, NetMonitorView } = monitor.panelWin; - let { RequestsMenu } = NetMonitorView; - RequestsMenu.lazyUpdate = false; - - for (let testcase of TEST_DATA) { - info("Testing Security tab visibility for " + testcase.desc); - let onNewItem = monitor.panelWin.once(EVENTS.NETWORK_EVENT); - let onSecurityInfo = monitor.panelWin.once(EVENTS.RECEIVED_SECURITY_INFO); - let onComplete = testcase.isBroken ? - waitForSecurityBrokenNetworkEvent() : - waitForNetworkEvents(monitor, 1); - - let tab = $("#security-tab"); - - info("Performing a request to " + testcase.uri); - debuggee.performRequests(1, testcase.uri); - - info("Waiting for new network event."); - yield onNewItem; - - info("Selecting the request."); - RequestsMenu.selectedIndex = 0; - - is(RequestsMenu.selectedItem.attachment.securityState, undefined, - "Security state has not yet arrived."); - is(tab.hidden, !testcase.visibleOnNewEvent, - "Security tab is " + - (testcase.visibleOnNewEvent ? "visible" : "hidden") + - " after new request was added to the menu."); - - info("Waiting for security information to arrive."); - yield onSecurityInfo; - - ok(RequestsMenu.selectedItem.attachment.securityState, - "Security state arrived."); - is(tab.hidden, !testcase.visibleOnSecurityInfo, - "Security tab is " + - (testcase.visibleOnSecurityInfo ? "visible" : "hidden") + - " after security information arrived."); - - info("Waiting for request to complete."); - yield onComplete; - is(tab.hidden, !testcase.visibleOnceComplete, - "Security tab is " + - (testcase.visibleOnceComplete ? "visible" : "hidden") + - " after request has been completed."); - - info("Clearing requests."); - RequestsMenu.clear(); - } - - yield teardown(monitor); - - /** - * Returns a promise that's resolved once a request with security issues is - * completed. - */ - function waitForSecurityBrokenNetworkEvent() { - let awaitedEvents = [ - "UPDATING_REQUEST_HEADERS", - "RECEIVED_REQUEST_HEADERS", - "UPDATING_REQUEST_COOKIES", - "RECEIVED_REQUEST_COOKIES", - "STARTED_RECEIVING_RESPONSE", - "UPDATING_RESPONSE_CONTENT", - "RECEIVED_RESPONSE_CONTENT", - "UPDATING_EVENT_TIMINGS", - "RECEIVED_EVENT_TIMINGS", - ]; - - let promises = awaitedEvents.map((event) => { - return monitor.panelWin.once(EVENTS[event]); - }); - - return Promise.all(promises); - } -}); diff --git a/browser/devtools/netmonitor/test/browser_net_security-warnings.js b/browser/devtools/netmonitor/test/browser_net_security-warnings.js deleted file mode 100644 index f900c1d07..000000000 --- a/browser/devtools/netmonitor/test/browser_net_security-warnings.js +++ /dev/null @@ -1,84 +0,0 @@ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -/** - * Test that warning indicators are shown when appropriate. - */ - -const TEST_CASES = [ - { - desc: "no warnings", - uri: "https://example.com" + CORS_SJS_PATH, - warnCipher: false, - warnSSLv3: false, - }, - { - desc: "sslv3 warning", - uri: "https://ssl3.example.com" + CORS_SJS_PATH, - warnCipher: false, - warnSSLv3: true, - }, - { - desc: "cipher warning", - uri: "https://rc4.example.com" + CORS_SJS_PATH, - warnCipher: true, - warnSSLv3: false, - }, - { - desc: "cipher and sslv3 warning", - uri: "https://ssl3rc4.example.com" + CORS_SJS_PATH, - warnCipher: true, - warnSSLv3: true, - }, -]; - -add_task(function* () { - let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL); - let { $, EVENTS, NetMonitorView } = monitor.panelWin; - let { RequestsMenu, NetworkDetails } = NetMonitorView; - RequestsMenu.lazyUpdate = false; - - info("Enabling SSLv3 and RC4 for the test."); - yield new promise(resolve => { - SpecialPowers.pushPrefEnv({"set": [ - ["security.tls.version.min", 0], - ["security.tls.insecure_fallback_hosts", "rc4.example.com,ssl3rc4.example.com"] - ]}, resolve); - }); - - let cipher = $("#security-warning-cipher"); - let sslv3 = $("#security-warning-sslv3"); - - for (let test of TEST_CASES) { - info("Testing site with " + test.desc); - - info("Performing request to " + test.uri); - debuggee.performRequests(1, test.uri); - yield waitForNetworkEvents(monitor, 1); - - info("Selecting the request."); - RequestsMenu.selectedIndex = 0; - - info("Waiting for details pane to be updated."); - yield monitor.panelWin.once(EVENTS.TAB_UPDATED); - - if (NetworkDetails.widget.selectedIndex !== 5) { - info("Selecting security tab."); - NetworkDetails.widget.selectedIndex = 5; - - info("Waiting for details pane to be updated."); - yield monitor.panelWin.once(EVENTS.TAB_UPDATED); - } - - is(cipher.hidden, !test.warnCipher, "Cipher suite warning is hidden."); - is(sslv3.hidden, !test.warnSSLv3, "SSLv3 warning is hidden."); - - RequestsMenu.clear(); - - } - - yield teardown(monitor); - -}); diff --git a/browser/devtools/netmonitor/test/browser_net_simple-init.js b/browser/devtools/netmonitor/test/browser_net_simple-init.js deleted file mode 100644 index e132f2ba6..000000000 --- a/browser/devtools/netmonitor/test/browser_net_simple-init.js +++ /dev/null @@ -1,93 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Simple check if the network monitor starts up and shuts down properly. - */ - -function test() { - // These test suite functions are removed from the global scope inside a - // cleanup function. However, we still need them. - let gInfo = info; - let gOk = ok; - - initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - is(aTab.linkedBrowser.contentWindow.wrappedJSObject.location, SIMPLE_URL, - "The current tab's location is the correct one."); - is(aDebuggee.location, SIMPLE_URL, - "The current debuggee's location is the correct one."); - - function checkIfInitialized(aTag) { - info("Checking if initialization is ok (" + aTag + ")."); - - ok(aMonitor._view, - "The network monitor view object exists (" + aTag + ")."); - ok(aMonitor._controller, - "The network monitor controller object exists (" + aTag + ")."); - ok(aMonitor._controller._startup, - "The network monitor controller object exists and is initialized (" + aTag + ")."); - - ok(aMonitor.isReady, - "The network monitor panel appears to be ready (" + aTag + ")."); - - ok(aMonitor._controller.client, - "There should be a client available at this point (" + aTag + ")."); - ok(aMonitor._controller.tabClient, - "There should be a tabClient available at this point (" + aTag + ")."); - ok(aMonitor._controller.webConsoleClient, - "There should be a webConsoleClient available at this point (" + aTag + ")."); - } - - function checkIfDestroyed(aTag) { - gInfo("Checking if destruction is ok."); - - gOk(aMonitor._view, - "The network monitor view object still exists (" + aTag + ")."); - gOk(aMonitor._controller, - "The network monitor controller object still exists (" + aTag + ")."); - gOk(aMonitor._controller._shutdown, - "The network monitor controller object still exists and is destroyed (" + aTag + ")."); - - gOk(!aMonitor._controller.client, - "There shouldn't be a client available after destruction (" + aTag + ")."); - gOk(!aMonitor._controller.tabClient, - "There shouldn't be a tabClient available after destruction (" + aTag + ")."); - gOk(!aMonitor._controller.webConsoleClient, - "There shouldn't be a webConsoleClient available after destruction (" + aTag + ")."); - } - - executeSoon(() => { - checkIfInitialized(1); - - aMonitor._controller.startupNetMonitor() - .then(() => { - info("Starting up again shouldn't do anything special."); - checkIfInitialized(2); - return aMonitor._controller.connect(); - }) - .then(() => { - info("Connecting again shouldn't do anything special."); - checkIfInitialized(3); - return teardown(aMonitor); - }) - .then(finish); - }); - - registerCleanupFunction(() => { - checkIfDestroyed(1); - - aMonitor._controller.shutdownNetMonitor() - .then(() => { - gInfo("Shutting down again shouldn't do anything special."); - checkIfDestroyed(2); - return aMonitor._controller.disconnect(); - }) - .then(() => { - gInfo("Disconnecting again shouldn't do anything special."); - checkIfDestroyed(3); - }); - }); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_simple-request-data.js b/browser/devtools/netmonitor/test/browser_net_simple-request-data.js deleted file mode 100644 index 11da60e39..000000000 --- a/browser/devtools/netmonitor/test/browser_net_simple-request-data.js +++ /dev/null @@ -1,241 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if requests render correct information in the menu UI. - */ - -function test() { - initNetMonitor(SIMPLE_SJS).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { L10N, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 1) - .then(() => teardown(aMonitor)) - .then(finish); - - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.NETWORK_EVENT, () => { - is(RequestsMenu.selectedItem, null, - "There shouldn't be any selected item in the requests menu."); - is(RequestsMenu.itemCount, 1, - "The requests menu should not be empty after the first request."); - is(NetMonitorView.detailsPaneHidden, true, - "The details pane should still be hidden after the first request."); - - let requestItem = RequestsMenu.getItemAtIndex(0); - let target = requestItem.target; - - is(typeof requestItem.value, "string", - "The attached request id is incorrect."); - isnot(requestItem.value, "", - "The attached request id should not be empty."); - - is(typeof requestItem.attachment.startedDeltaMillis, "number", - "The attached startedDeltaMillis is incorrect."); - is(requestItem.attachment.startedDeltaMillis, 0, - "The attached startedDeltaMillis should be zero."); - - is(typeof requestItem.attachment.startedMillis, "number", - "The attached startedMillis is incorrect."); - isnot(requestItem.attachment.startedMillis, 0, - "The attached startedMillis should not be zero."); - - is(requestItem.attachment.requestHeaders, undefined, - "The requestHeaders should not yet be set."); - is(requestItem.attachment.requestCookies, undefined, - "The requestCookies should not yet be set."); - is(requestItem.attachment.requestPostData, undefined, - "The requestPostData should not yet be set."); - - is(requestItem.attachment.responseHeaders, undefined, - "The responseHeaders should not yet be set."); - is(requestItem.attachment.responseCookies, undefined, - "The responseCookies should not yet be set."); - - is(requestItem.attachment.httpVersion, undefined, - "The httpVersion should not yet be set."); - is(requestItem.attachment.status, undefined, - "The status should not yet be set."); - is(requestItem.attachment.statusText, undefined, - "The statusText should not yet be set."); - - is(requestItem.attachment.headersSize, undefined, - "The headersSize should not yet be set."); - is(requestItem.attachment.transferredSize, undefined, - "The transferredSize should not yet be set."); - is(requestItem.attachment.contentSize, undefined, - "The contentSize should not yet be set."); - - is(requestItem.attachment.mimeType, undefined, - "The mimeType should not yet be set."); - is(requestItem.attachment.responseContent, undefined, - "The responseContent should not yet be set."); - - is(requestItem.attachment.totalTime, undefined, - "The totalTime should not yet be set."); - is(requestItem.attachment.eventTimings, undefined, - "The eventTimings should not yet be set."); - - verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS); - }); - - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_REQUEST_HEADERS, () => { - let requestItem = RequestsMenu.getItemAtIndex(0); - - ok(requestItem.attachment.requestHeaders, - "There should be a requestHeaders attachment available."); - is(requestItem.attachment.requestHeaders.headers.length, 9, - "The requestHeaders attachment has an incorrect |headers| property."); - isnot(requestItem.attachment.requestHeaders.headersSize, 0, - "The requestHeaders attachment has an incorrect |headersSize| property."); - // Can't test for the exact request headers size because the value may - // vary across platforms ("User-Agent" header differs). - - verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS); - }); - - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_REQUEST_COOKIES, () => { - let requestItem = RequestsMenu.getItemAtIndex(0); - - ok(requestItem.attachment.requestCookies, - "There should be a requestCookies attachment available."); - is(requestItem.attachment.requestCookies.cookies.length, 2, - "The requestCookies attachment has an incorrect |cookies| property."); - - verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS); - }); - - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_REQUEST_POST_DATA, () => { - ok(false, "Trap listener: this request doesn't have any post data.") - }); - - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_RESPONSE_HEADERS, () => { - let requestItem = RequestsMenu.getItemAtIndex(0); - - ok(requestItem.attachment.responseHeaders, - "There should be a responseHeaders attachment available."); - is(requestItem.attachment.responseHeaders.headers.length, 10, - "The responseHeaders attachment has an incorrect |headers| property."); - is(requestItem.attachment.responseHeaders.headersSize, 330, - "The responseHeaders attachment has an incorrect |headersSize| property."); - - verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS); - }); - - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_RESPONSE_COOKIES, () => { - let requestItem = RequestsMenu.getItemAtIndex(0); - - ok(requestItem.attachment.responseCookies, - "There should be a responseCookies attachment available."); - is(requestItem.attachment.responseCookies.cookies.length, 2, - "The responseCookies attachment has an incorrect |cookies| property."); - - verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS); - }); - - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.STARTED_RECEIVING_RESPONSE, () => { - let requestItem = RequestsMenu.getItemAtIndex(0); - - is(requestItem.attachment.httpVersion, "HTTP/1.1", - "The httpVersion attachment has an incorrect value."); - is(requestItem.attachment.status, "200", - "The status attachment has an incorrect value."); - is(requestItem.attachment.statusText, "Och Aye", - "The statusText attachment has an incorrect value."); - is(requestItem.attachment.headersSize, 330, - "The headersSize attachment has an incorrect value."); - - verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS, { - status: "200", - statusText: "Och Aye" - }); - }); - - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.UPDATING_RESPONSE_CONTENT, () => { - let requestItem = RequestsMenu.getItemAtIndex(0); - - is(requestItem.attachment.transferredSize, "12", - "The transferredSize attachment has an incorrect value."); - is(requestItem.attachment.contentSize, "12", - "The contentSize attachment has an incorrect value."); - is(requestItem.attachment.mimeType, "text/plain; charset=utf-8", - "The mimeType attachment has an incorrect value."); - - verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS, { - type: "plain", - fullMimeType: "text/plain; charset=utf-8", - transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.01), - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.01), - }); - }); - - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_RESPONSE_CONTENT, () => { - let requestItem = RequestsMenu.getItemAtIndex(0); - - ok(requestItem.attachment.responseContent, - "There should be a responseContent attachment available."); - is(requestItem.attachment.responseContent.content.mimeType, "text/plain; charset=utf-8", - "The responseContent attachment has an incorrect |content.mimeType| property."); - is(requestItem.attachment.responseContent.content.text, "Hello world!", - "The responseContent attachment has an incorrect |content.text| property."); - is(requestItem.attachment.responseContent.content.size, 12, - "The responseContent attachment has an incorrect |content.size| property."); - - verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS, { - type: "plain", - fullMimeType: "text/plain; charset=utf-8", - transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.01), - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.01), - }); - }); - - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.UPDATING_EVENT_TIMINGS, () => { - let requestItem = RequestsMenu.getItemAtIndex(0); - - is(typeof requestItem.attachment.totalTime, "number", - "The attached totalTime is incorrect."); - ok(requestItem.attachment.totalTime >= 0, - "The attached totalTime should be positive."); - - is(typeof requestItem.attachment.endedMillis, "number", - "The attached endedMillis is incorrect."); - ok(requestItem.attachment.endedMillis >= 0, - "The attached endedMillis should be positive."); - - verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS, { - time: true - }); - }); - - aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_EVENT_TIMINGS, () => { - let requestItem = RequestsMenu.getItemAtIndex(0); - - ok(requestItem.attachment.eventTimings, - "There should be a eventTimings attachment available."); - is(typeof requestItem.attachment.eventTimings.timings.blocked, "number", - "The eventTimings attachment has an incorrect |timings.blocked| property."); - is(typeof requestItem.attachment.eventTimings.timings.dns, "number", - "The eventTimings attachment has an incorrect |timings.dns| property."); - is(typeof requestItem.attachment.eventTimings.timings.connect, "number", - "The eventTimings attachment has an incorrect |timings.connect| property."); - is(typeof requestItem.attachment.eventTimings.timings.send, "number", - "The eventTimings attachment has an incorrect |timings.send| property."); - is(typeof requestItem.attachment.eventTimings.timings.wait, "number", - "The eventTimings attachment has an incorrect |timings.wait| property."); - is(typeof requestItem.attachment.eventTimings.timings.receive, "number", - "The eventTimings attachment has an incorrect |timings.receive| property."); - is(typeof requestItem.attachment.eventTimings.totalTime, "number", - "The eventTimings attachment has an incorrect |totalTime| property."); - - verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS, { - time: true - }); - }); - - aDebuggee.location.reload(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_simple-request-details.js b/browser/devtools/netmonitor/test/browser_net_simple-request-details.js deleted file mode 100644 index bb2ff3d59..000000000 --- a/browser/devtools/netmonitor/test/browser_net_simple-request-details.js +++ /dev/null @@ -1,242 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if requests render correct information in the details UI. - */ - -function test() { - initNetMonitor(SIMPLE_SJS).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, L10N, Editor, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu, NetworkDetails } = NetMonitorView; - let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED; - RequestsMenu.lazyUpdate = false; - - Task.spawn(function () { - yield waitForNetworkEvents(aMonitor, 1); - is(RequestsMenu.selectedItem, null, - "There shouldn't be any selected item in the requests menu."); - is(RequestsMenu.itemCount, 1, - "The requests menu should not be empty after the first request."); - is(NetMonitorView.detailsPaneHidden, true, - "The details pane should still be hidden after the first request."); - - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.getElementById("details-pane-toggle")); - - isnot(RequestsMenu.selectedItem, null, - "There should be a selected item in the requests menu."); - is(RequestsMenu.selectedIndex, 0, - "The first item should be selected in the requests menu."); - is(NetMonitorView.detailsPaneHidden, false, - "The details pane should not be hidden after toggle button was pressed."); - - yield waitFor(aMonitor.panelWin, TAB_UPDATED) - testHeadersTab(); - yield testCookiesTab(); - testParamsTab(); - yield testResponseTab(); - testTimingsTab(); - yield teardown(aMonitor); - finish(); - }); - - function testHeadersTab() { - let tab = document.querySelectorAll("#details-pane tab")[0]; - let tabpanel = document.querySelectorAll("#details-pane tabpanel")[0]; - - is(tab.getAttribute("selected"), "true", - "The headers tab in the network details pane should be selected."); - - is(tabpanel.querySelector("#headers-summary-url-value").getAttribute("value"), - SIMPLE_SJS, "The url summary value is incorrect."); - is(tabpanel.querySelector("#headers-summary-url-value").getAttribute("tooltiptext"), - SIMPLE_SJS, "The url summary tooltiptext is incorrect."); - is(tabpanel.querySelector("#headers-summary-method-value").getAttribute("value"), - "GET", "The method summary value is incorrect."); - is(tabpanel.querySelector("#headers-summary-status-circle").getAttribute("code"), - "200", "The status summary code is incorrect."); - is(tabpanel.querySelector("#headers-summary-status-value").getAttribute("value"), - "200 Och Aye", "The status summary value is incorrect."); - - is(tabpanel.querySelectorAll(".variables-view-scope").length, 2, - "There should be 2 header scopes displayed in this tabpanel."); - is(tabpanel.querySelectorAll(".variable-or-property").length, 19, - "There should be 19 header values displayed in this tabpanel."); - - is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0, - "The empty notice should not be displayed in this tabpanel."); - - let responseScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; - let requestScope = tabpanel.querySelectorAll(".variables-view-scope")[1]; - - is(responseScope.querySelector(".name").getAttribute("value"), - L10N.getStr("responseHeaders") + " (" + - L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(330/1024, 3)) + ")", - "The response headers scope doesn't have the correct title."); - - ok(requestScope.querySelector(".name").getAttribute("value").contains( - L10N.getStr("requestHeaders") + " (0"), - "The request headers scope doesn't have the correct title."); - // Can't test for full request headers title because the size may - // vary across platforms ("User-Agent" header differs). We're pretty - // sure it's smaller than 1 MB though, so it starts with a 0. - - is(responseScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"), - "Cache-Control", "The first response header name was incorrect."); - is(responseScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"), - "\"no-cache, no-store, must-revalidate\"", "The first response header value was incorrect."); - is(responseScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"), - "Connection", "The second response header name was incorrect."); - is(responseScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"), - "\"close\"", "The second response header value was incorrect."); - is(responseScope.querySelectorAll(".variables-view-variable .name")[2].getAttribute("value"), - "Content-Length", "The third response header name was incorrect."); - is(responseScope.querySelectorAll(".variables-view-variable .value")[2].getAttribute("value"), - "\"12\"", "The third response header value was incorrect."); - is(responseScope.querySelectorAll(".variables-view-variable .name")[3].getAttribute("value"), - "Content-Type", "The fourth response header name was incorrect."); - is(responseScope.querySelectorAll(".variables-view-variable .value")[3].getAttribute("value"), - "\"text/plain; charset=utf-8\"", "The fourth response header value was incorrect."); - is(responseScope.querySelectorAll(".variables-view-variable .name")[9].getAttribute("value"), - "foo-bar", "The last response header name was incorrect."); - is(responseScope.querySelectorAll(".variables-view-variable .value")[9].getAttribute("value"), - "\"baz\"", "The last response header value was incorrect."); - - is(requestScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"), - "Host", "The first request header name was incorrect."); - is(requestScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"), - "\"example.com\"", "The first request header value was incorrect."); - is(requestScope.querySelectorAll(".variables-view-variable .name")[6].getAttribute("value"), - "Connection", "The ante-penultimate request header name was incorrect."); - is(requestScope.querySelectorAll(".variables-view-variable .value")[6].getAttribute("value"), - "\"keep-alive\"", "The ante-penultimate request header value was incorrect."); - is(requestScope.querySelectorAll(".variables-view-variable .name")[7].getAttribute("value"), - "Pragma", "The penultimate request header name was incorrect."); - is(requestScope.querySelectorAll(".variables-view-variable .value")[7].getAttribute("value"), - "\"no-cache\"", "The penultimate request header value was incorrect."); - is(requestScope.querySelectorAll(".variables-view-variable .name")[8].getAttribute("value"), - "Cache-Control", "The last request header name was incorrect."); - is(requestScope.querySelectorAll(".variables-view-variable .value")[8].getAttribute("value"), - "\"no-cache\"", "The last request header value was incorrect."); - } - - function testCookiesTab() { - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.querySelectorAll("#details-pane tab")[1]); - - return Task.spawn(function*() { - yield waitFor(aMonitor.panelWin, TAB_UPDATED); - - let tab = document.querySelectorAll("#details-pane tab")[1]; - let tabpanel = document.querySelectorAll("#details-pane tabpanel")[1]; - - is(tab.getAttribute("selected"), "true", - "The cookies tab in the network details pane should be selected."); - - is(tabpanel.querySelectorAll(".variables-view-scope").length, 2, - "There should be 2 cookie scopes displayed in this tabpanel."); - is(tabpanel.querySelectorAll(".variable-or-property").length, 6, - "There should be 6 cookie values displayed in this tabpanel."); - }); - } - - function testParamsTab() { - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.querySelectorAll("#details-pane tab")[2]); - - let tab = document.querySelectorAll("#details-pane tab")[2]; - let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2]; - - is(tab.getAttribute("selected"), "true", - "The params tab in the network details pane should be selected."); - - is(tabpanel.querySelectorAll(".variables-view-scope").length, 0, - "There should be no param scopes displayed in this tabpanel."); - is(tabpanel.querySelectorAll(".variable-or-property").length, 0, - "There should be no param values displayed in this tabpanel."); - is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 1, - "The empty notice should be displayed in this tabpanel."); - - is(tabpanel.querySelector("#request-params-box") - .hasAttribute("hidden"), false, - "The request params box should not be hidden."); - is(tabpanel.querySelector("#request-post-data-textarea-box") - .hasAttribute("hidden"), true, - "The request post data textarea box should be hidden."); - } - - function testResponseTab() { - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.querySelectorAll("#details-pane tab")[3]); - - return Task.spawn(function () { - yield waitFor(aMonitor.panelWin, TAB_UPDATED); - - let tab = document.querySelectorAll("#details-pane tab")[3]; - let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3]; - - is(tab.getAttribute("selected"), "true", - "The response tab in the network details pane should be selected."); - - is(tabpanel.querySelector("#response-content-info-header") - .hasAttribute("hidden"), true, - "The response info header should be hidden."); - is(tabpanel.querySelector("#response-content-json-box") - .hasAttribute("hidden"), true, - "The response content json box should be hidden."); - is(tabpanel.querySelector("#response-content-textarea-box") - .hasAttribute("hidden"), false, - "The response content textarea box should not be hidden."); - is(tabpanel.querySelector("#response-content-image-box") - .hasAttribute("hidden"), true, - "The response content image box should be hidden."); - - let aEditor = yield NetMonitorView.editor("#response-content-textarea"); - is(aEditor.getText(), "Hello world!", - "The text shown in the source editor is incorrect."); - is(aEditor.getMode(), Editor.modes.text, - "The mode active in the source editor is incorrect."); - }); - } - - function testTimingsTab() { - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.querySelectorAll("#details-pane tab")[4]); - - let tab = document.querySelectorAll("#details-pane tab")[4]; - let tabpanel = document.querySelectorAll("#details-pane tabpanel")[4]; - - is(tab.getAttribute("selected"), "true", - "The timings tab in the network details pane should be selected."); - - ok(tabpanel.querySelector("#timings-summary-blocked .requests-menu-timings-total") - .getAttribute("value").match(/[0-9]+/), - "The blocked timing info does not appear to be correct."); - - ok(tabpanel.querySelector("#timings-summary-dns .requests-menu-timings-total") - .getAttribute("value").match(/[0-9]+/), - "The dns timing info does not appear to be correct."); - - ok(tabpanel.querySelector("#timings-summary-connect .requests-menu-timings-total") - .getAttribute("value").match(/[0-9]+/), - "The connect timing info does not appear to be correct."); - - ok(tabpanel.querySelector("#timings-summary-send .requests-menu-timings-total") - .getAttribute("value").match(/[0-9]+/), - "The send timing info does not appear to be correct."); - - ok(tabpanel.querySelector("#timings-summary-wait .requests-menu-timings-total") - .getAttribute("value").match(/[0-9]+/), - "The wait timing info does not appear to be correct."); - - ok(tabpanel.querySelector("#timings-summary-receive .requests-menu-timings-total") - .getAttribute("value").match(/[0-9]+/), - "The receive timing info does not appear to be correct."); - } - - aDebuggee.location.reload(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_simple-request.js b/browser/devtools/netmonitor/test/browser_net_simple-request.js deleted file mode 100644 index 0129ed584..000000000 --- a/browser/devtools/netmonitor/test/browser_net_simple-request.js +++ /dev/null @@ -1,60 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if requests are handled correctly. - */ - -function test() { - initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - is(document.querySelector("#details-pane-toggle") - .hasAttribute("disabled"), true, - "The pane toggle button should be disabled when the frontend is opened."); - is(document.querySelector("#requests-menu-empty-notice") - .hasAttribute("hidden"), false, - "An empty notice should be displayed when the frontend is opened."); - is(RequestsMenu.itemCount, 0, - "The requests menu should be empty when the frontend is opened."); - is(NetMonitorView.detailsPaneHidden, true, - "The details pane should be hidden when the frontend is opened."); - - waitForNetworkEvents(aMonitor, 1).then(() => { - is(document.querySelector("#details-pane-toggle") - .hasAttribute("disabled"), false, - "The pane toggle button should be enabled after the first request."); - is(document.querySelector("#requests-menu-empty-notice") - .hasAttribute("hidden"), true, - "The empty notice should be hidden after the first request."); - is(RequestsMenu.itemCount, 1, - "The requests menu should not be empty after the first request."); - is(NetMonitorView.detailsPaneHidden, true, - "The details pane should still be hidden after the first request."); - - waitForNetworkEvents(aMonitor, 1).then(() => { - is(document.querySelector("#details-pane-toggle") - .hasAttribute("disabled"), false, - "The pane toggle button should be still be enabled after a reload."); - is(document.querySelector("#requests-menu-empty-notice") - .hasAttribute("hidden"), true, - "The empty notice should be still hidden after a reload."); - is(RequestsMenu.itemCount, 1, - "The requests menu should not be empty after a reload."); - is(NetMonitorView.detailsPaneHidden, true, - "The details pane should still be hidden after a reload."); - - teardown(aMonitor).then(finish); - }); - - aDebuggee.location.reload(); - }); - - aDebuggee.location.reload(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_sort-01.js b/browser/devtools/netmonitor/test/browser_net_sort-01.js deleted file mode 100644 index ed8f2b8ae..000000000 --- a/browser/devtools/netmonitor/test/browser_net_sort-01.js +++ /dev/null @@ -1,255 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Test if the sorting mechanism works correctly. - */ - -function test() { - initNetMonitor(STATUS_CODES_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { $all, L10N, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 5).then(() => { - testContents([0, 1, 2, 3, 4]) - .then(() => { - info("Testing swap(0, 0)"); - RequestsMenu.swapItemsAtIndices(0, 0); - RequestsMenu.refreshZebra(); - return testContents([0, 1, 2, 3, 4]); - }) - .then(() => { - info("Testing swap(0, 1)"); - RequestsMenu.swapItemsAtIndices(0, 1); - RequestsMenu.refreshZebra(); - return testContents([1, 0, 2, 3, 4]); - }) - .then(() => { - info("Testing swap(0, 2)"); - RequestsMenu.swapItemsAtIndices(0, 2); - RequestsMenu.refreshZebra(); - return testContents([1, 2, 0, 3, 4]); - }) - .then(() => { - info("Testing swap(0, 3)"); - RequestsMenu.swapItemsAtIndices(0, 3); - RequestsMenu.refreshZebra(); - return testContents([1, 2, 3, 0, 4]); - }) - .then(() => { - info("Testing swap(0, 4)"); - RequestsMenu.swapItemsAtIndices(0, 4); - RequestsMenu.refreshZebra(); - return testContents([1, 2, 3, 4, 0]); - }) - .then(() => { - info("Testing swap(1, 0)"); - RequestsMenu.swapItemsAtIndices(1, 0); - RequestsMenu.refreshZebra(); - return testContents([0, 2, 3, 4, 1]); - }) - .then(() => { - info("Testing swap(1, 1)"); - RequestsMenu.swapItemsAtIndices(1, 1); - RequestsMenu.refreshZebra(); - return testContents([0, 2, 3, 4, 1]); - }) - .then(() => { - info("Testing swap(1, 2)"); - RequestsMenu.swapItemsAtIndices(1, 2); - RequestsMenu.refreshZebra(); - return testContents([0, 1, 3, 4, 2]); - }) - .then(() => { - info("Testing swap(1, 3)"); - RequestsMenu.swapItemsAtIndices(1, 3); - RequestsMenu.refreshZebra(); - return testContents([0, 3, 1, 4, 2]); - }) - .then(() => { - info("Testing swap(1, 4)"); - RequestsMenu.swapItemsAtIndices(1, 4); - RequestsMenu.refreshZebra(); - return testContents([0, 3, 4, 1, 2]); - }) - .then(() => { - info("Testing swap(2, 0)"); - RequestsMenu.swapItemsAtIndices(2, 0); - RequestsMenu.refreshZebra(); - return testContents([2, 3, 4, 1, 0]); - }) - .then(() => { - info("Testing swap(2, 1)"); - RequestsMenu.swapItemsAtIndices(2, 1); - RequestsMenu.refreshZebra(); - return testContents([1, 3, 4, 2, 0]); - }) - .then(() => { - info("Testing swap(2, 2)"); - RequestsMenu.swapItemsAtIndices(2, 2); - RequestsMenu.refreshZebra(); - return testContents([1, 3, 4, 2, 0]); - }) - .then(() => { - info("Testing swap(2, 3)"); - RequestsMenu.swapItemsAtIndices(2, 3); - RequestsMenu.refreshZebra(); - return testContents([1, 2, 4, 3, 0]); - }) - .then(() => { - info("Testing swap(2, 4)"); - RequestsMenu.swapItemsAtIndices(2, 4); - RequestsMenu.refreshZebra(); - return testContents([1, 4, 2, 3, 0]); - }) - .then(() => { - info("Testing swap(3, 0)"); - RequestsMenu.swapItemsAtIndices(3, 0); - RequestsMenu.refreshZebra(); - return testContents([1, 4, 2, 0, 3]); - }) - .then(() => { - info("Testing swap(3, 1)"); - RequestsMenu.swapItemsAtIndices(3, 1); - RequestsMenu.refreshZebra(); - return testContents([3, 4, 2, 0, 1]); - }) - .then(() => { - info("Testing swap(3, 2)"); - RequestsMenu.swapItemsAtIndices(3, 2); - RequestsMenu.refreshZebra(); - return testContents([2, 4, 3, 0, 1]); - }) - .then(() => { - info("Testing swap(3, 3)"); - RequestsMenu.swapItemsAtIndices(3, 3); - RequestsMenu.refreshZebra(); - return testContents([2, 4, 3, 0, 1]); - }) - .then(() => { - info("Testing swap(3, 4)"); - RequestsMenu.swapItemsAtIndices(3, 4); - RequestsMenu.refreshZebra(); - return testContents([2, 3, 4, 0, 1]); - }) - .then(() => { - info("Testing swap(4, 0)"); - RequestsMenu.swapItemsAtIndices(4, 0); - RequestsMenu.refreshZebra(); - return testContents([2, 3, 0, 4, 1]); - }) - .then(() => { - info("Testing swap(4, 1)"); - RequestsMenu.swapItemsAtIndices(4, 1); - RequestsMenu.refreshZebra(); - return testContents([2, 3, 0, 1, 4]); - }) - .then(() => { - info("Testing swap(4, 2)"); - RequestsMenu.swapItemsAtIndices(4, 2); - RequestsMenu.refreshZebra(); - return testContents([4, 3, 0, 1, 2]); - }) - .then(() => { - info("Testing swap(4, 3)"); - RequestsMenu.swapItemsAtIndices(4, 3); - RequestsMenu.refreshZebra(); - return testContents([3, 4, 0, 1, 2]); - }) - .then(() => { - info("Testing swap(4, 4)"); - RequestsMenu.swapItemsAtIndices(4, 4); - RequestsMenu.refreshZebra(); - return testContents([3, 4, 0, 1, 2]); - }) - .then(() => { - info("Clearing sort."); - RequestsMenu.sortBy(); - return testContents([0, 1, 2, 3, 4]); - }) - .then(() => { - return teardown(aMonitor); - }) - .then(finish); - }); - - function testContents([a, b, c, d, e]) { - is(RequestsMenu.items.length, 5, - "There should be a total of 5 items in the requests menu."); - is(RequestsMenu.visibleItems.length, 5, - "There should be a total of 5 visbile items in the requests menu."); - is($all(".side-menu-widget-item").length, 5, - "The visible items in the requests menu are, in fact, visible!"); - - is(RequestsMenu.getItemAtIndex(0), RequestsMenu.items[0], - "The requests menu items aren't ordered correctly. First item is misplaced."); - is(RequestsMenu.getItemAtIndex(1), RequestsMenu.items[1], - "The requests menu items aren't ordered correctly. Second item is misplaced."); - is(RequestsMenu.getItemAtIndex(2), RequestsMenu.items[2], - "The requests menu items aren't ordered correctly. Third item is misplaced."); - is(RequestsMenu.getItemAtIndex(3), RequestsMenu.items[3], - "The requests menu items aren't ordered correctly. Fourth item is misplaced."); - is(RequestsMenu.getItemAtIndex(4), RequestsMenu.items[4], - "The requests menu items aren't ordered correctly. Fifth item is misplaced."); - - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(a), - "GET", STATUS_CODES_SJS + "?sts=100", { - status: 101, - statusText: "Switching Protocols", - type: "plain", - fullMimeType: "text/plain; charset=utf-8", - transferred: L10N.getStr("networkMenu.sizeUnavailable"), - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0), - time: true - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(b), - "GET", STATUS_CODES_SJS + "?sts=200", { - status: 202, - statusText: "Created", - type: "plain", - fullMimeType: "text/plain; charset=utf-8", - transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.02), - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.02), - time: true - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(c), - "GET", STATUS_CODES_SJS + "?sts=300", { - status: 303, - statusText: "See Other", - type: "plain", - fullMimeType: "text/plain; charset=utf-8", - transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.02), - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0), - time: true - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(d), - "GET", STATUS_CODES_SJS + "?sts=400", { - status: 404, - statusText: "Not Found", - type: "plain", - fullMimeType: "text/plain; charset=utf-8", - transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.02), - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.02), - time: true - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(e), - "GET", STATUS_CODES_SJS + "?sts=500", { - status: 501, - statusText: "Not Implemented", - type: "plain", - fullMimeType: "text/plain; charset=utf-8", - transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.02), - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.02), - time: true - }); - - return promise.resolve(null); - } - - aDebuggee.performRequests(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_sort-02.js b/browser/devtools/netmonitor/test/browser_net_sort-02.js deleted file mode 100644 index 7a6becf68..000000000 --- a/browser/devtools/netmonitor/test/browser_net_sort-02.js +++ /dev/null @@ -1,274 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Test if sorting columns in the network table works correctly. - */ - -function test() { - initNetMonitor(SORTING_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - // It seems that this test may be slow on debug builds. This could be because - // of the heavy dom manipulation associated with sorting. - requestLongerTimeout(2); - - let { $, $all, L10N, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 5).then(() => { - EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle")); - - isnot(RequestsMenu.selectedItem, null, - "There should be a selected item in the requests menu."); - is(RequestsMenu.selectedIndex, 0, - "The first item should be selected in the requests menu."); - is(NetMonitorView.detailsPaneHidden, false, - "The details pane should not be hidden after toggle button was pressed."); - - testHeaders(); - testContents([0, 2, 4, 3, 1]) - .then(() => { - info("Testing status sort, ascending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button")); - testHeaders("status", "ascending"); - return testContents([0, 1, 2, 3, 4]); - }) - .then(() => { - info("Testing status sort, descending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button")); - testHeaders("status", "descending"); - return testContents([4, 3, 2, 1, 0]); - }) - .then(() => { - info("Testing status sort, ascending. Checking sort loops correctly."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button")); - testHeaders("status", "ascending"); - return testContents([0, 1, 2, 3, 4]); - }) - .then(() => { - info("Testing method sort, ascending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-method-button")); - testHeaders("method", "ascending"); - return testContents([0, 1, 2, 3, 4]); - }) - .then(() => { - info("Testing method sort, descending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-method-button")); - testHeaders("method", "descending"); - return testContents([4, 3, 2, 1, 0]); - }) - .then(() => { - info("Testing method sort, ascending. Checking sort loops correctly."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-method-button")); - testHeaders("method", "ascending"); - return testContents([0, 1, 2, 3, 4]); - }) - .then(() => { - info("Testing file sort, ascending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button")); - testHeaders("file", "ascending"); - return testContents([0, 1, 2, 3, 4]); - }) - .then(() => { - info("Testing file sort, descending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button")); - testHeaders("file", "descending"); - return testContents([4, 3, 2, 1, 0]); - }) - .then(() => { - info("Testing file sort, ascending. Checking sort loops correctly."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button")); - testHeaders("file", "ascending"); - return testContents([0, 1, 2, 3, 4]); - }) - .then(() => { - info("Testing type sort, ascending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-type-button")); - testHeaders("type", "ascending"); - return testContents([0, 1, 2, 3, 4]); - }) - .then(() => { - info("Testing type sort, descending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-type-button")); - testHeaders("type", "descending"); - return testContents([4, 3, 2, 1, 0]); - }) - .then(() => { - info("Testing type sort, ascending. Checking sort loops correctly."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-type-button")); - testHeaders("type", "ascending"); - return testContents([0, 1, 2, 3, 4]); - }) - .then(() => { - info("Testing transferred sort, ascending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-transferred-button")); - testHeaders("transferred", "ascending"); - return testContents([0, 1, 2, 3, 4]); - }) - .then(() => { - info("Testing transferred sort, descending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-transferred-button")); - testHeaders("transferred", "descending"); - return testContents([4, 3, 2, 1, 0]); - }) - .then(() => { - info("Testing transferred sort, ascending. Checking sort loops correctly."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-transferred-button")); - testHeaders("transferred", "ascending"); - return testContents([0, 1, 2, 3, 4]); - }) - .then(() => { - info("Testing size sort, ascending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button")); - testHeaders("size", "ascending"); - return testContents([0, 1, 2, 3, 4]); - }) - .then(() => { - info("Testing size sort, descending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button")); - testHeaders("size", "descending"); - return testContents([4, 3, 2, 1, 0]); - }) - .then(() => { - info("Testing size sort, ascending. Checking sort loops correctly."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button")); - testHeaders("size", "ascending"); - return testContents([0, 1, 2, 3, 4]); - }) - .then(() => { - info("Testing waterfall sort, ascending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button")); - testHeaders("waterfall", "ascending"); - return testContents([0, 2, 4, 3, 1]); - }) - .then(() => { - info("Testing waterfall sort, descending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button")); - testHeaders("waterfall", "descending"); - return testContents([4, 2, 0, 1, 3]); - }) - .then(() => { - info("Testing waterfall sort, ascending. Checking sort loops correctly."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button")); - testHeaders("waterfall", "ascending"); - return testContents([0, 2, 4, 3, 1]); - }) - .then(() => { - return teardown(aMonitor); - }) - .then(finish); - }); - - function testHeaders(aSortType, aDirection) { - let doc = aMonitor.panelWin.document; - let target = doc.querySelector("#requests-menu-" + aSortType + "-button"); - let headers = doc.querySelectorAll(".requests-menu-header-button"); - - for (let header of headers) { - if (header != target) { - is(header.hasAttribute("sorted"), false, - "The " + header.id + " header should not have a 'sorted' attribute."); - is(header.hasAttribute("tooltiptext"), false, - "The " + header.id + " header should not have a 'tooltiptext' attribute."); - } else { - is(header.getAttribute("sorted"), aDirection, - "The " + header.id + " header has an incorrect 'sorted' attribute."); - is(header.getAttribute("tooltiptext"), aDirection == "ascending" - ? L10N.getStr("networkMenu.sortedAsc") - : L10N.getStr("networkMenu.sortedDesc"), - "The " + header.id + " has an incorrect 'tooltiptext' attribute."); - } - } - } - - function testContents([a, b, c, d, e]) { - isnot(RequestsMenu.selectedItem, null, - "There should still be a selected item after sorting."); - is(RequestsMenu.selectedIndex, a, - "The first item should be still selected after sorting."); - is(NetMonitorView.detailsPaneHidden, false, - "The details pane should still be visible after sorting."); - - is(RequestsMenu.items.length, 5, - "There should be a total of 5 items in the requests menu."); - is(RequestsMenu.visibleItems.length, 5, - "There should be a total of 5 visbile items in the requests menu."); - is($all(".side-menu-widget-item").length, 5, - "The visible items in the requests menu are, in fact, visible!"); - - is(RequestsMenu.getItemAtIndex(0), RequestsMenu.items[0], - "The requests menu items aren't ordered correctly. First item is misplaced."); - is(RequestsMenu.getItemAtIndex(1), RequestsMenu.items[1], - "The requests menu items aren't ordered correctly. Second item is misplaced."); - is(RequestsMenu.getItemAtIndex(2), RequestsMenu.items[2], - "The requests menu items aren't ordered correctly. Third item is misplaced."); - is(RequestsMenu.getItemAtIndex(3), RequestsMenu.items[3], - "The requests menu items aren't ordered correctly. Fourth item is misplaced."); - is(RequestsMenu.getItemAtIndex(4), RequestsMenu.items[4], - "The requests menu items aren't ordered correctly. Fifth item is misplaced."); - - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(a), - "GET1", SORTING_SJS + "?index=1", { - fuzzyUrl: true, - status: 101, - statusText: "Meh", - type: "1", - fullMimeType: "text/1", - transferred: L10N.getStr("networkMenu.sizeUnavailable"), - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0), - time: true - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(b), - "GET2", SORTING_SJS + "?index=2", { - fuzzyUrl: true, - status: 200, - statusText: "Meh", - type: "2", - fullMimeType: "text/2", - transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.01), - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.01), - time: true - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(c), - "GET3", SORTING_SJS + "?index=3", { - fuzzyUrl: true, - status: 300, - statusText: "Meh", - type: "3", - fullMimeType: "text/3", - transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.02), - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.02), - time: true - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(d), - "GET4", SORTING_SJS + "?index=4", { - fuzzyUrl: true, - status: 400, - statusText: "Meh", - type: "4", - fullMimeType: "text/4", - transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.03), - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.03), - time: true - }); - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(e), - "GET5", SORTING_SJS + "?index=5", { - fuzzyUrl: true, - status: 500, - statusText: "Meh", - type: "5", - fullMimeType: "text/5", - transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.04), - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.04), - time: true - }); - - return promise.resolve(null); - } - - aDebuggee.performRequests(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_sort-03.js b/browser/devtools/netmonitor/test/browser_net_sort-03.js deleted file mode 100644 index d4c1de33b..000000000 --- a/browser/devtools/netmonitor/test/browser_net_sort-03.js +++ /dev/null @@ -1,196 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Test if sorting columns in the network table works correctly with new requests. - */ - -function test() { - initNetMonitor(SORTING_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - // It seems that this test may be slow on debug builds. This could be because - // of the heavy dom manipulation associated with sorting. - requestLongerTimeout(2); - - let { $, $all, L10N, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 5).then(() => { - EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle")); - - isnot(RequestsMenu.selectedItem, null, - "There should be a selected item in the requests menu."); - is(RequestsMenu.selectedIndex, 0, - "The first item should be selected in the requests menu."); - is(NetMonitorView.detailsPaneHidden, false, - "The details pane should not be hidden after toggle button was pressed."); - - testHeaders(); - testContents([0, 2, 4, 3, 1], 0) - .then(() => { - info("Testing status sort, ascending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button")); - testHeaders("status", "ascending"); - return testContents([0, 1, 2, 3, 4], 0); - }) - .then(() => { - info("Performing more requests."); - aDebuggee.performRequests(); - return waitForNetworkEvents(aMonitor, 5); - }) - .then(() => { - info("Testing status sort again, ascending."); - testHeaders("status", "ascending"); - return testContents([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 0); - }) - .then(() => { - info("Testing status sort, descending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button")); - testHeaders("status", "descending"); - return testContents([9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 9); - }) - .then(() => { - info("Performing more requests."); - aDebuggee.performRequests(); - return waitForNetworkEvents(aMonitor, 5); - }) - .then(() => { - info("Testing status sort again, descending."); - testHeaders("status", "descending"); - return testContents([14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 14); - }) - .then(() => { - info("Testing status sort yet again, ascending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button")); - testHeaders("status", "ascending"); - return testContents([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], 0); - }) - .then(() => { - info("Testing status sort yet again, descending."); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button")); - testHeaders("status", "descending"); - return testContents([14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 14); - }) - .then(() => { - return teardown(aMonitor); - }) - .then(finish); - }); - - function testHeaders(aSortType, aDirection) { - let doc = aMonitor.panelWin.document; - let target = doc.querySelector("#requests-menu-" + aSortType + "-button"); - let headers = doc.querySelectorAll(".requests-menu-header-button"); - - for (let header of headers) { - if (header != target) { - is(header.hasAttribute("sorted"), false, - "The " + header.id + " header should not have a 'sorted' attribute."); - is(header.hasAttribute("tooltiptext"), false, - "The " + header.id + " header should not have a 'tooltiptext' attribute."); - } else { - is(header.getAttribute("sorted"), aDirection, - "The " + header.id + " header has an incorrect 'sorted' attribute."); - is(header.getAttribute("tooltiptext"), aDirection == "ascending" - ? L10N.getStr("networkMenu.sortedAsc") - : L10N.getStr("networkMenu.sortedDesc"), - "The " + header.id + " has an incorrect 'tooltiptext' attribute."); - } - } - } - - function testContents(aOrder, aSelection) { - isnot(RequestsMenu.selectedItem, null, - "There should still be a selected item after sorting."); - is(RequestsMenu.selectedIndex, aSelection, - "The first item should be still selected after sorting."); - is(NetMonitorView.detailsPaneHidden, false, - "The details pane should still be visible after sorting."); - - is(RequestsMenu.items.length, aOrder.length, - "There should be a specific number of items in the requests menu."); - is(RequestsMenu.visibleItems.length, aOrder.length, - "There should be a specific number of visbile items in the requests menu."); - is($all(".side-menu-widget-item").length, aOrder.length, - "The visible items in the requests menu are, in fact, visible!"); - - for (let i = 0; i < aOrder.length; i++) { - is(RequestsMenu.getItemAtIndex(i), RequestsMenu.items[i], - "The requests menu items aren't ordered correctly. Misplaced item " + i + "."); - } - - for (let i = 0, len = aOrder.length / 5; i < len; i++) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i]), - "GET1", SORTING_SJS + "?index=1", { - fuzzyUrl: true, - status: 101, - statusText: "Meh", - type: "1", - fullMimeType: "text/1", - transferred: L10N.getStr("networkMenu.sizeUnavailable"), - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0), - time: true - }); - } - for (let i = 0, len = aOrder.length / 5; i < len; i++) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len]), - "GET2", SORTING_SJS + "?index=2", { - fuzzyUrl: true, - status: 200, - statusText: "Meh", - type: "2", - fullMimeType: "text/2", - transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.01), - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.01), - time: true - }); - } - for (let i = 0, len = aOrder.length / 5; i < len; i++) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 2]), - "GET3", SORTING_SJS + "?index=3", { - fuzzyUrl: true, - status: 300, - statusText: "Meh", - type: "3", - fullMimeType: "text/3", - transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.02), - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.02), - time: true - }); - } - for (let i = 0, len = aOrder.length / 5; i < len; i++) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 3]), - "GET4", SORTING_SJS + "?index=4", { - fuzzyUrl: true, - status: 400, - statusText: "Meh", - type: "4", - fullMimeType: "text/4", - transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.03), - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.03), - time: true - }); - } - for (let i = 0, len = aOrder.length / 5; i < len; i++) { - verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 4]), - "GET5", SORTING_SJS + "?index=5", { - fuzzyUrl: true, - status: 500, - statusText: "Meh", - type: "5", - fullMimeType: "text/5", - transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.04), - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.04), - time: true - }); - } - - return promise.resolve(null); - } - - aDebuggee.performRequests(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_statistics-01.js b/browser/devtools/netmonitor/test/browser_net_statistics-01.js deleted file mode 100644 index f73b6a2a4..000000000 --- a/browser/devtools/netmonitor/test/browser_net_statistics-01.js +++ /dev/null @@ -1,72 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if the statistics view is populated correctly. - */ - -function test() { - initNetMonitor(STATISTICS_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let panel = aMonitor.panelWin; - let { document, $, $all, EVENTS, NetMonitorView } = panel; - - is(NetMonitorView.currentFrontendMode, "network-inspector-view", - "The initial frontend mode is correct."); - - is($("#primed-cache-chart").childNodes.length, 0, - "There should be no primed cache chart created yet."); - is($("#empty-cache-chart").childNodes.length, 0, - "There should be no empty cache chart created yet."); - - waitFor(panel, EVENTS.PLACEHOLDER_CHARTS_DISPLAYED).then(() => { - is($("#primed-cache-chart").childNodes.length, 1, - "There should be a placeholder primed cache chart created now."); - is($("#empty-cache-chart").childNodes.length, 1, - "There should be a placeholder empty cache chart created now."); - - is($all(".pie-chart-container[placeholder=true]").length, 2, - "Two placeholder pie chart appear to be rendered correctly."); - is($all(".table-chart-container[placeholder=true]").length, 2, - "Two placeholder table chart appear to be rendered correctly."); - - promise.all([ - waitFor(panel, EVENTS.PRIMED_CACHE_CHART_DISPLAYED), - waitFor(panel, EVENTS.EMPTY_CACHE_CHART_DISPLAYED) - ]).then(() => { - is($("#primed-cache-chart").childNodes.length, 1, - "There should be a real primed cache chart created now."); - is($("#empty-cache-chart").childNodes.length, 1, - "There should be a real empty cache chart created now."); - - Task.spawn(function*() { - yield until(() => $all(".pie-chart-container:not([placeholder=true])").length == 2); - ok(true, "Two real pie charts appear to be rendered correctly."); - - yield until(() => $all(".table-chart-container:not([placeholder=true])").length == 2); - ok(true, "Two real table charts appear to be rendered correctly.") - - teardown(aMonitor).then(finish); - }); - }); - }); - - NetMonitorView.toggleFrontendMode(); - - is(NetMonitorView.currentFrontendMode, "network-statistics-view", - "The current frontend mode is correct."); - }); -} - -function waitForTick() { - let deferred = promise.defer(); - executeSoon(deferred.resolve); - return deferred.promise; -} - -function until(predicate) { - return Task.spawn(function*() { - while (!predicate()) yield waitForTick(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_statistics-02.js b/browser/devtools/netmonitor/test/browser_net_statistics-02.js deleted file mode 100644 index b43e9a0e8..000000000 --- a/browser/devtools/netmonitor/test/browser_net_statistics-02.js +++ /dev/null @@ -1,43 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if the network inspector view is shown when the target navigates - * away while in the statistics view. - */ - -function test() { - initNetMonitor(STATISTICS_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let panel = aMonitor.panelWin; - let { document, EVENTS, NetMonitorView } = panel; - - is(NetMonitorView.currentFrontendMode, "network-inspector-view", - "The initial frontend mode is correct."); - - promise.all([ - waitFor(panel, EVENTS.PRIMED_CACHE_CHART_DISPLAYED), - waitFor(panel, EVENTS.EMPTY_CACHE_CHART_DISPLAYED) - ]).then(() => { - is(NetMonitorView.currentFrontendMode, "network-statistics-view", - "The frontend mode is currently in the statistics view."); - - waitFor(panel, EVENTS.TARGET_WILL_NAVIGATE).then(() => { - is(NetMonitorView.currentFrontendMode, "network-inspector-view", - "The frontend mode switched back to the inspector view."); - - waitFor(panel, EVENTS.TARGET_DID_NAVIGATE).then(() => { - is(NetMonitorView.currentFrontendMode, "network-inspector-view", - "The frontend mode is still in the inspector view."); - - teardown(aMonitor).then(finish); - }); - }); - - aDebuggee.location.reload(); - }); - - NetMonitorView.toggleFrontendMode(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_statistics-03.js b/browser/devtools/netmonitor/test/browser_net_statistics-03.js deleted file mode 100644 index 2200770b1..000000000 --- a/browser/devtools/netmonitor/test/browser_net_statistics-03.js +++ /dev/null @@ -1,36 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Test if the correct filtering predicates are used when filtering from - * the performance analysis view. - */ - -function test() { - initNetMonitor(FILTERING_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let panel = aMonitor.panelWin; - let { $, EVENTS, NetMonitorView } = panel; - - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button")); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button")); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-js-button")); - EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-other-button")); - testFilterButtonsCustom(aMonitor, [0, 1, 1, 1, 0, 0, 0, 0, 0, 1]); - ok(true, "The correct filtering predicates are used before entering perf. analysis mode."); - - promise.all([ - waitFor(panel, EVENTS.PRIMED_CACHE_CHART_DISPLAYED), - waitFor(panel, EVENTS.EMPTY_CACHE_CHART_DISPLAYED) - ]).then(() => { - EventUtils.sendMouseEvent({ type: "click" }, $(".pie-chart-slice")); - testFilterButtons(aMonitor, "html"); - ok(true, "The correct filtering predicate is used when exiting perf. analysis mode."); - - teardown(aMonitor).then(finish); - }); - - NetMonitorView.toggleFrontendMode(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_status-codes.js b/browser/devtools/netmonitor/test/browser_net_status-codes.js deleted file mode 100644 index b86bc35ac..000000000 --- a/browser/devtools/netmonitor/test/browser_net_status-codes.js +++ /dev/null @@ -1,203 +0,0 @@ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -/** - * Tests if requests display the correct status code and text in the UI. - */ - -let test = Task.async(function*() { - let [tab, debuggee, monitor] = yield initNetMonitor(STATUS_CODES_URL); - - info("Starting test... "); - - let { document, L10N, NetMonitorView } = monitor.panelWin; - let { RequestsMenu, NetworkDetails } = NetMonitorView; - let requestItems = []; - - RequestsMenu.lazyUpdate = false; - NetworkDetails._params.lazyEmpty = false; - - const REQUEST_DATA = [ - { // request #0 - method: "GET", - uri: STATUS_CODES_SJS + "?sts=100", - details: { - status: 101, - statusText: "Switching Protocols", - type: "plain", - fullMimeType: "text/plain; charset=utf-8", - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0), - time: true - } - }, - { // request #1 - method: "GET", - uri: STATUS_CODES_SJS + "?sts=200", - details: { - status: 202, - statusText: "Created", - type: "plain", - fullMimeType: "text/plain; charset=utf-8", - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.02), - time: true - } - }, - { // request #2 - method: "GET", - uri: STATUS_CODES_SJS + "?sts=300", - details: { - status: 303, - statusText: "See Other", - type: "plain", - fullMimeType: "text/plain; charset=utf-8", - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0), - time: true - } - }, - { // request #3 - method: "GET", - uri: STATUS_CODES_SJS + "?sts=400", - details: { - status: 404, - statusText: "Not Found", - type: "plain", - fullMimeType: "text/plain; charset=utf-8", - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.02), - time: true - } - }, - { // request #4 - method: "GET", - uri: STATUS_CODES_SJS + "?sts=500", - details: { - status: 501, - statusText: "Not Implemented", - type: "plain", - fullMimeType: "text/plain; charset=utf-8", - size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.02), - time: true - } - } - ]; - - debuggee.performRequests(); - yield waitForNetworkEvents(monitor, 5); - - info("Performing tests"); - yield verifyRequests(); - yield testTab(0, testSummary); - yield testTab(2, testParams); - - yield teardown(monitor); - finish(); - - /** - * A helper that verifies all requests show the correct information and caches - * RequestsMenu items to requestItems array. - */ - function* verifyRequests() { - info("Verifying requests contain correct information."); - let index = 0; - for (let request of REQUEST_DATA) { - let item = RequestsMenu.getItemAtIndex(index); - requestItems[index] = item; - - info("Verifying request #" + index); - yield verifyRequestItemTarget(item, request.method, request.uri, request.details); - - index++; - } - } - - /** - * A helper that opens a given tab of request details pane, selects and passes - * all requests to the given test function. - * - * @param Number tab - * The index of NetworkDetails tab to activate. - * @param Function testFn(requestItem) - * A function that should perform all necessary tests. It's called once - * for every item of REQUEST_DATA with that item being selected in the - * NetworkMonitor. - */ - function* testTab(tab, testFn) { - info("Testing tab #" + tab); - EventUtils.sendMouseEvent({ type: "mousedown" }, - document.querySelectorAll("#details-pane tab")[tab]); - - let counter = 0; - for (let item of REQUEST_DATA) { - info("Waiting tab #" + tab + " to update with request #" + counter); - yield chooseRequest(counter); - - info("Tab updated. Performing checks"); - yield testFn(item); - - counter++; - } - } - - /** - * A function that tests "Summary" contains correct information. - */ - function* testSummary(data) { - let tab = document.querySelectorAll("#details-pane tab")[0]; - let tabpanel = document.querySelectorAll("#details-pane tabpanel")[0]; - - let { method, uri, details: { status, statusText } } = data; - is(tabpanel.querySelector("#headers-summary-url-value").getAttribute("value"), - uri, "The url summary value is incorrect."); - is(tabpanel.querySelector("#headers-summary-method-value").getAttribute("value"), - method, "The method summary value is incorrect."); - is(tabpanel.querySelector("#headers-summary-status-circle").getAttribute("code"), - status, "The status summary code is incorrect."); - is(tabpanel.querySelector("#headers-summary-status-value").getAttribute("value"), - status + " " + statusText, "The status summary value is incorrect."); - } - - /** - * A function that tests "Params" tab contains correct information. - */ - function* testParams(data) { - let tab = document.querySelectorAll("#details-pane tab")[2]; - let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2]; - let statusParamValue = data.uri.split("=").pop(); - let statusParamShownValue = "\"" + statusParamValue + "\""; - - is(tabpanel.querySelectorAll(".variables-view-scope").length, 1, - "There should be 1 param scope displayed in this tabpanel."); - is(tabpanel.querySelectorAll(".variable-or-property").length, 1, - "There should be 1 param value displayed in this tabpanel."); - is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0, - "The empty notice should not be displayed in this tabpanel."); - - let paramsScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; - - is(paramsScope.querySelector(".name").getAttribute("value"), - L10N.getStr("paramsQueryString"), - "The params scope doesn't have the correct title."); - - is(paramsScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"), - "sts", "The param name was incorrect."); - is(paramsScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"), - statusParamShownValue, "The param value was incorrect."); - - is(tabpanel.querySelector("#request-params-box") - .hasAttribute("hidden"), false, - "The request params box should not be hidden."); - is(tabpanel.querySelector("#request-post-data-textarea-box") - .hasAttribute("hidden"), true, - "The request post data textarea box should be hidden."); - } - - /** - * A helper that clicks on a specified request and returns a promise resolved - * when NetworkDetails has been populated with the data of the given request. - */ - function chooseRequest(index) { - EventUtils.sendMouseEvent({ type: "mousedown" }, requestItems[index].target); - return waitFor(monitor.panelWin, monitor.panelWin.EVENTS.TAB_UPDATED); - } -}); diff --git a/browser/devtools/netmonitor/test/browser_net_timeline_ticks.js b/browser/devtools/netmonitor/test/browser_net_timeline_ticks.js deleted file mode 100644 index c6fa32439..000000000 --- a/browser/devtools/netmonitor/test/browser_net_timeline_ticks.js +++ /dev/null @@ -1,141 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if timeline correctly displays interval divisions. - */ - -function test() { - initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { document, L10N, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - // Disable transferred size column support for this test. - // Without this, the waterfall only has enough room for one division, which - // would remove most of the value of this test. - document.querySelector("#requests-menu-transferred-header-box").hidden = true; - document.querySelector("#requests-menu-item-template .requests-menu-transferred").hidden = true; - - RequestsMenu.lazyUpdate = false; - - ok(document.querySelector("#requests-menu-waterfall-label"), - "An timeline label should be displayed when the frontend is opened."); - ok(document.querySelectorAll(".requests-menu-timings-division").length == 0, - "No tick labels should be displayed when the frontend is opened."); - - ok(!RequestsMenu._canvas, - "No canvas should be created when the frontend is opened."); - ok(!RequestsMenu._ctx, - "No 2d context should be created when the frontend is opened."); - - waitForNetworkEvents(aMonitor, 1).then(() => { - ok(!document.querySelector("#requests-menu-waterfall-label"), - "The timeline label should be hidden after the first request."); - ok(document.querySelectorAll(".requests-menu-timings-division").length >= 3, - "There should be at least 3 tick labels in the network requests header."); - - is(document.querySelectorAll(".requests-menu-timings-division")[0] - .getAttribute("value"), L10N.getFormatStr("networkMenu.millisecond", 0), - "The first tick label has an incorrect value"); - is(document.querySelectorAll(".requests-menu-timings-division")[1] - .getAttribute("value"), L10N.getFormatStr("networkMenu.millisecond", 80), - "The second tick label has an incorrect value"); - is(document.querySelectorAll(".requests-menu-timings-division")[2] - .getAttribute("value"), L10N.getFormatStr("networkMenu.millisecond", 160), - "The third tick label has an incorrect value"); - - is(document.querySelectorAll(".requests-menu-timings-division")[0] - .style.transform, "translateX(0px)", - "The first tick label has an incorrect translation"); - is(document.querySelectorAll(".requests-menu-timings-division")[1] - .style.transform, "translateX(80px)", - "The second tick label has an incorrect translation"); - is(document.querySelectorAll(".requests-menu-timings-division")[2] - .style.transform, "translateX(160px)", - "The third tick label has an incorrect translation"); - - ok(RequestsMenu._canvas, - "A canvas should be created after the first request."); - ok(RequestsMenu._ctx, - "A 2d context should be created after the first request."); - - let imageData = RequestsMenu._ctx.getImageData(0, 0, 161, 1); - ok(imageData, "The image data should have been created."); - - let data = imageData.data; - ok(data, "The image data should contain a pixel array."); - - ok( hasPixelAt(0), "The tick at 0 is should not be empty."); - ok(!hasPixelAt(1), "The tick at 1 is should be empty."); - ok(!hasPixelAt(19), "The tick at 19 is should be empty."); - ok( hasPixelAt(20), "The tick at 20 is should not be empty."); - ok(!hasPixelAt(21), "The tick at 21 is should be empty."); - ok(!hasPixelAt(39), "The tick at 39 is should be empty."); - ok( hasPixelAt(40), "The tick at 40 is should not be empty."); - ok(!hasPixelAt(41), "The tick at 41 is should be empty."); - ok(!hasPixelAt(59), "The tick at 59 is should be empty."); - ok( hasPixelAt(60), "The tick at 60 is should not be empty."); - ok(!hasPixelAt(61), "The tick at 61 is should be empty."); - ok(!hasPixelAt(79), "The tick at 79 is should be empty."); - ok( hasPixelAt(80), "The tick at 80 is should not be empty."); - ok(!hasPixelAt(81), "The tick at 81 is should be empty."); - ok(!hasPixelAt(159), "The tick at 159 is should be empty."); - ok( hasPixelAt(160), "The tick at 160 is should not be empty."); - ok(!hasPixelAt(161), "The tick at 161 is should be empty."); - - ok(isPixelBrighterAtThan(0, 20), - "The tick at 0 should be brighter than the one at 20"); - ok(isPixelBrighterAtThan(40, 20), - "The tick at 40 should be brighter than the one at 20"); - ok(isPixelBrighterAtThan(40, 60), - "The tick at 40 should be brighter than the one at 60"); - ok(isPixelBrighterAtThan(80, 60), - "The tick at 80 should be brighter than the one at 60"); - - ok(isPixelBrighterAtThan(80, 100), - "The tick at 80 should be brighter than the one at 100"); - ok(isPixelBrighterAtThan(120, 100), - "The tick at 120 should be brighter than the one at 100"); - ok(isPixelBrighterAtThan(120, 140), - "The tick at 120 should be brighter than the one at 140"); - ok(isPixelBrighterAtThan(160, 140), - "The tick at 160 should be brighter than the one at 140"); - - ok(isPixelEquallyBright(20, 60), - "The tick at 20 should be equally bright to the one at 60"); - ok(isPixelEquallyBright(100, 140), - "The tick at 100 should be equally bright to the one at 140"); - - ok(isPixelEquallyBright(40, 120), - "The tick at 40 should be equally bright to the one at 120"); - - ok(isPixelEquallyBright(0, 80), - "The tick at 80 should be equally bright to the one at 160"); - ok(isPixelEquallyBright(80, 160), - "The tick at 80 should be equally bright to the one at 160"); - - function hasPixelAt(x) { - let i = (x | 0) * 4; - return data[i] && data[i + 1] && data[i + 2] && data[i + 3]; - } - - function isPixelBrighterAtThan(x1, x2) { - let i = (x1 | 0) * 4; - let j = (x2 | 0) * 4; - return data[i + 3] > data [j + 3]; - } - - function isPixelEquallyBright(x1, x2) { - let i = (x1 | 0) * 4; - let j = (x2 | 0) * 4; - return data[i + 3] == data [j + 3]; - } - - teardown(aMonitor).then(finish); - }); - - aDebuggee.location.reload(); - }); -} diff --git a/browser/devtools/netmonitor/test/browser_net_timing-division.js b/browser/devtools/netmonitor/test/browser_net_timing-division.js deleted file mode 100644 index fa537dd08..000000000 --- a/browser/devtools/netmonitor/test/browser_net_timing-division.js +++ /dev/null @@ -1,58 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests if timing intervals are divided againts seconds when appropriate. - */ - -function test() { - initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => { - info("Starting test... "); - - let { $all, NetMonitorView } = aMonitor.panelWin; - let { RequestsMenu } = NetMonitorView; - - RequestsMenu.lazyUpdate = false; - - waitForNetworkEvents(aMonitor, 2).then(() => { - let millisecondDivs = $all(".requests-menu-timings-division[division-scale=millisecond]"); - let secondDivs = $all(".requests-menu-timings-division[division-scale=second]"); - let minuteDivs = $all(".requests-menu-timings-division[division-scale=minute]"); - - info("Number of millisecond divisions: " + millisecondDivs.length); - info("Number of second divisions: " + secondDivs.length); - info("Number of minute divisions: " + minuteDivs.length); - - for (let div of millisecondDivs) { - info("Millisecond division: " + div.getAttribute("value")); - } - for (let div of secondDivs) { - info("Second division: " + div.getAttribute("value")); - } - for (let div of minuteDivs) { - info("Minute division: " + div.getAttribute("value")); - } - - is(RequestsMenu.itemCount, 2, - "There should be only two requests made."); - - let firstRequest = RequestsMenu.getItemAtIndex(0); - let lastRequest = RequestsMenu.getItemAtIndex(1); - - info("First request happened at: " + - firstRequest.attachment.responseHeaders.headers.find(e => e.name == "Date").value); - info("Last request happened at: " + - lastRequest.attachment.responseHeaders.headers.find(e => e.name == "Date").value); - - ok(secondDivs.length, - "There should be at least one division on the seconds time scale."); - ok(secondDivs[0].getAttribute("value").match(/\d+\.\d{2}\s\w+/), - "The division on the seconds time scale looks legit."); - - teardown(aMonitor).then(finish); - }); - - // Timeout needed for having enough divisions on the time scale. - aDebuggee.performRequests(2, null, 3000); - }); -} diff --git a/browser/devtools/netmonitor/test/head.js b/browser/devtools/netmonitor/test/head.js deleted file mode 100644 index 3f1b0898b..000000000 --- a/browser/devtools/netmonitor/test/head.js +++ /dev/null @@ -1,494 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components; - -let { Services } = Cu.import("resource://gre/modules/Services.jsm", {}); -let { Task } = Cu.import("resource://gre/modules/Task.jsm", {}); -let { Promise: promise } = Cu.import("resource://gre/modules/Promise.jsm", {}); -let { gDevTools } = Cu.import("resource:///modules/devtools/gDevTools.jsm", {}); -let { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); -let { CurlUtils } = Cu.import("resource:///modules/devtools/Curl.jsm", {}); -let TargetFactory = devtools.TargetFactory; -let Toolbox = devtools.Toolbox; - -const EXAMPLE_URL = "http://example.com/browser/browser/devtools/netmonitor/test/"; - -const SIMPLE_URL = EXAMPLE_URL + "html_simple-test-page.html"; -const NAVIGATE_URL = EXAMPLE_URL + "html_navigate-test-page.html"; -const CONTENT_TYPE_URL = EXAMPLE_URL + "html_content-type-test-page.html"; -const CONTENT_TYPE_WITHOUT_CACHE_URL = EXAMPLE_URL + "html_content-type-without-cache-test-page.html"; -const CYRILLIC_URL = EXAMPLE_URL + "html_cyrillic-test-page.html"; -const STATUS_CODES_URL = EXAMPLE_URL + "html_status-codes-test-page.html"; -const POST_DATA_URL = EXAMPLE_URL + "html_post-data-test-page.html"; -const POST_RAW_URL = EXAMPLE_URL + "html_post-raw-test-page.html"; -const POST_RAW_WITH_HEADERS_URL = EXAMPLE_URL + "html_post-raw-with-headers-test-page.html"; -const PARAMS_URL = EXAMPLE_URL + "html_params-test-page.html"; -const JSONP_URL = EXAMPLE_URL + "html_jsonp-test-page.html"; -const JSON_LONG_URL = EXAMPLE_URL + "html_json-long-test-page.html"; -const JSON_MALFORMED_URL = EXAMPLE_URL + "html_json-malformed-test-page.html"; -const JSON_CUSTOM_MIME_URL = EXAMPLE_URL + "html_json-custom-mime-test-page.html"; -const JSON_TEXT_MIME_URL = EXAMPLE_URL + "html_json-text-mime-test-page.html"; -const SORTING_URL = EXAMPLE_URL + "html_sorting-test-page.html"; -const FILTERING_URL = EXAMPLE_URL + "html_filter-test-page.html"; -const INFINITE_GET_URL = EXAMPLE_URL + "html_infinite-get-page.html"; -const CUSTOM_GET_URL = EXAMPLE_URL + "html_custom-get-page.html"; -const SINGLE_GET_URL = EXAMPLE_URL + "html_single-get-page.html"; -const STATISTICS_URL = EXAMPLE_URL + "html_statistics-test-page.html"; -const CURL_URL = EXAMPLE_URL + "html_copy-as-curl.html"; -const CURL_UTILS_URL = EXAMPLE_URL + "html_curl-utils.html"; - -const SIMPLE_SJS = EXAMPLE_URL + "sjs_simple-test-server.sjs"; -const CONTENT_TYPE_SJS = EXAMPLE_URL + "sjs_content-type-test-server.sjs"; -const STATUS_CODES_SJS = EXAMPLE_URL + "sjs_status-codes-test-server.sjs"; -const SORTING_SJS = EXAMPLE_URL + "sjs_sorting-test-server.sjs"; -const HTTPS_REDIRECT_SJS = EXAMPLE_URL + "sjs_https-redirect-test-server.sjs"; -const CORS_SJS_PATH = "/browser/browser/devtools/netmonitor/test/sjs_cors-test-server.sjs"; - -const TEST_IMAGE = EXAMPLE_URL + "test-image.png"; -const TEST_IMAGE_DATA_URI = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg=="; - -const FRAME_SCRIPT_UTILS_URL = "chrome://browser/content/devtools/frame-script-utils.js" - -gDevTools.testing = true; -SimpleTest.registerCleanupFunction(() => { - gDevTools.testing = false; -}); - -// All tests are asynchronous. -waitForExplicitFinish(); - -const gEnableLogging = Services.prefs.getBoolPref("devtools.debugger.log"); -// To enable logging for try runs, just set the pref to true. -Services.prefs.setBoolPref("devtools.debugger.log", false); - -// Uncomment this pref to dump all devtools emitted events to the console. -// Services.prefs.setBoolPref("devtools.dump.emit", true); - -// Always reset some prefs to their original values after the test finishes. -const gDefaultFilters = Services.prefs.getCharPref("devtools.netmonitor.filters"); - -registerCleanupFunction(() => { - info("finish() was called, cleaning up..."); - - Services.prefs.setBoolPref("devtools.debugger.log", gEnableLogging); - Services.prefs.setCharPref("devtools.netmonitor.filters", gDefaultFilters); - Services.prefs.clearUserPref("devtools.cache.disabled"); - Services.prefs.clearUserPref("devtools.dump.emit"); -}); - -function addTab(aUrl, aWindow) { - info("Adding tab: " + aUrl); - - let deferred = promise.defer(); - let targetWindow = aWindow || window; - let targetBrowser = targetWindow.gBrowser; - - targetWindow.focus(); - let tab = targetBrowser.selectedTab = targetBrowser.addTab(aUrl); - let browser = tab.linkedBrowser; - - browser.addEventListener("load", function onLoad() { - browser.removeEventListener("load", onLoad, true); - deferred.resolve(tab); - }, true); - - return deferred.promise; -} - -function removeTab(aTab, aWindow) { - info("Removing tab."); - - let targetWindow = aWindow || window; - let targetBrowser = targetWindow.gBrowser; - - targetBrowser.removeTab(aTab); -} - -function waitForNavigation(aTarget) { - let deferred = promise.defer(); - aTarget.once("will-navigate", () => { - aTarget.once("navigate", () => { - deferred.resolve(); - }); - }); - return deferred.promise; -} - -function reconfigureTab(aTarget, aOptions) { - let deferred = promise.defer(); - aTarget.activeTab.reconfigure(aOptions, deferred.resolve); - return deferred.promise; -}; - -function toggleCache(aTarget, aDisabled) { - let options = { cacheDisabled: aDisabled, performReload: true }; - let navigationFinished = waitForNavigation(aTarget); - - // Disable the cache for any toolbox that it is opened from this point on. - Services.prefs.setBoolPref("devtools.cache.disabled", aDisabled); - - return reconfigureTab(aTarget, options).then(() => navigationFinished); -} - -function initNetMonitor(aUrl, aWindow) { - info("Initializing a network monitor pane."); - - return Task.spawn(function*() { - let tab = yield addTab(aUrl); - info("Net tab added successfully: " + aUrl); - - let target = TargetFactory.forTab(tab); - - yield target.makeRemote(); - info("Target remoted."); - - yield toggleCache(target, true); - info("Cache disabled when the current and all future toolboxes are open."); - - let toolbox = yield gDevTools.showToolbox(target, "netmonitor"); - info("Netork monitor pane shown successfully."); - - let debuggee = tab.linkedBrowser.contentWindow.wrappedJSObject; - let monitor = toolbox.getCurrentPanel(); - return [tab, debuggee, monitor]; - }); -} - -function restartNetMonitor(aMonitor, aNewUrl) { - info("Restarting the specified network monitor."); - - let deferred = promise.defer(); - let tab = aMonitor.target.tab; - let url = aNewUrl || tab.linkedBrowser.contentWindow.wrappedJSObject.location.href; - - aMonitor.once("destroyed", () => initNetMonitor(url).then(deferred.resolve)); - removeTab(tab); - - return deferred.promise; -} - -function teardown(aMonitor) { - info("Destroying the specified network monitor."); - - let deferred = promise.defer(); - let tab = aMonitor.target.tab; - - aMonitor.once("destroyed", () => executeSoon(deferred.resolve)); - removeTab(tab); - - return deferred.promise; -} - -function waitForNetworkEvents(aMonitor, aGetRequests, aPostRequests = 0) { - let deferred = promise.defer(); - - let panel = aMonitor.panelWin; - let events = panel.EVENTS; - let menu = panel.NetMonitorView.RequestsMenu; - - let progress = {}; - let genericEvents = 0; - let postEvents = 0; - - let awaitedEventsToListeners = [ - ["UPDATING_REQUEST_HEADERS", onGenericEvent], - ["RECEIVED_REQUEST_HEADERS", onGenericEvent], - ["UPDATING_REQUEST_COOKIES", onGenericEvent], - ["RECEIVED_REQUEST_COOKIES", onGenericEvent], - ["UPDATING_REQUEST_POST_DATA", onPostEvent], - ["RECEIVED_REQUEST_POST_DATA", onPostEvent], - ["UPDATING_RESPONSE_HEADERS", onGenericEvent], - ["RECEIVED_RESPONSE_HEADERS", onGenericEvent], - ["UPDATING_RESPONSE_COOKIES", onGenericEvent], - ["RECEIVED_RESPONSE_COOKIES", onGenericEvent], - ["STARTED_RECEIVING_RESPONSE", onGenericEvent], - ["UPDATING_RESPONSE_CONTENT", onGenericEvent], - ["RECEIVED_RESPONSE_CONTENT", onGenericEvent], - ["UPDATING_EVENT_TIMINGS", onGenericEvent], - ["RECEIVED_EVENT_TIMINGS", onGenericEvent] - ]; - - function initProgressForURL(url) { - if (progress[url]) return; - progress[url] = {}; - awaitedEventsToListeners.forEach(([e]) => progress[url][e] = 0); - } - - function updateProgressForURL(url, event) { - initProgressForURL(url); - progress[url][Object.keys(events).find(e => events[e] == event)] = 1; - } - - function onGenericEvent(event, actor) { - genericEvents++; - maybeResolve(event, actor); - } - - function onPostEvent(event, actor) { - postEvents++; - maybeResolve(event, actor); - } - - function maybeResolve(event, actor) { - info("> Network events progress: " + - genericEvents + "/" + ((aGetRequests + aPostRequests) * 13) + ", " + - postEvents + "/" + (aPostRequests * 2) + ", " + - "got " + event + " for " + actor); - - let url = menu.getItemByValue(actor).attachment.url; - updateProgressForURL(url, event); - info("> Current state: " + JSON.stringify(progress, null, 2)); - - // There are 15 updates which need to be fired for a request to be - // considered finished. The "requestPostData" packet isn't fired for - // non-POST requests. - if (genericEvents == (aGetRequests + aPostRequests) * 13 && - postEvents == aPostRequests * 2) { - - awaitedEventsToListeners.forEach(([e, l]) => panel.off(events[e], l)); - executeSoon(deferred.resolve); - } - } - - awaitedEventsToListeners.forEach(([e, l]) => panel.on(events[e], l)); - return deferred.promise; -} - -function verifyRequestItemTarget(aRequestItem, aMethod, aUrl, aData = {}) { - info("> Verifying: " + aMethod + " " + aUrl + " " + aData.toSource()); - // This bloats log sizes significantly in automation (bug 992485) - //info("> Request: " + aRequestItem.attachment.toSource()); - - let requestsMenu = aRequestItem.ownerView; - let widgetIndex = requestsMenu.indexOfItem(aRequestItem); - let visibleIndex = requestsMenu.visibleItems.indexOf(aRequestItem); - - info("Widget index of item: " + widgetIndex); - info("Visible index of item: " + visibleIndex); - - let { fuzzyUrl, status, statusText, type, fullMimeType, transferred, size, time } = aData; - let { attachment, target } = aRequestItem - - let uri = Services.io.newURI(aUrl, null, null).QueryInterface(Ci.nsIURL); - let name = uri.fileName || "/"; - let query = uri.query; - let hostPort = uri.hostPort; - - if (fuzzyUrl) { - ok(attachment.method.startsWith(aMethod), "The attached method is incorrect."); - ok(attachment.url.startsWith(aUrl), "The attached url is incorrect."); - } else { - is(attachment.method, aMethod, "The attached method is incorrect."); - is(attachment.url, aUrl, "The attached url is incorrect."); - } - - is(target.querySelector(".requests-menu-method").getAttribute("value"), - aMethod, "The displayed method is incorrect."); - - if (fuzzyUrl) { - ok(target.querySelector(".requests-menu-file").getAttribute("value").startsWith( - name + (query ? "?" + query : "")), "The displayed file is incorrect."); - ok(target.querySelector(".requests-menu-file").getAttribute("tooltiptext").startsWith( - name + (query ? "?" + query : "")), "The tooltip file is incorrect."); - } else { - is(target.querySelector(".requests-menu-file").getAttribute("value"), - name + (query ? "?" + query : ""), "The displayed file is incorrect."); - is(target.querySelector(".requests-menu-file").getAttribute("tooltiptext"), - name + (query ? "?" + query : ""), "The tooltip file is incorrect."); - } - - is(target.querySelector(".requests-menu-domain").getAttribute("value"), - hostPort, "The displayed domain is incorrect."); - is(target.querySelector(".requests-menu-domain").getAttribute("tooltiptext"), - hostPort, "The tooltip domain is incorrect."); - - if (status !== undefined) { - let value = target.querySelector(".requests-menu-status").getAttribute("code"); - let codeValue = target.querySelector(".requests-menu-status-code").getAttribute("value"); - let tooltip = target.querySelector(".requests-menu-status-and-method").getAttribute("tooltiptext"); - info("Displayed status: " + value); - info("Displayed code: " + codeValue); - info("Tooltip status: " + tooltip); - is(value, status, "The displayed status is incorrect."); - is(codeValue, status, "The displayed status code is incorrect."); - is(tooltip, status + " " + statusText, "The tooltip status is incorrect."); - } - if (type !== undefined) { - let value = target.querySelector(".requests-menu-type").getAttribute("value"); - let tooltip = target.querySelector(".requests-menu-type").getAttribute("tooltiptext"); - info("Displayed type: " + value); - info("Tooltip type: " + tooltip); - is(value, type, "The displayed type is incorrect."); - is(tooltip, fullMimeType, "The tooltip type is incorrect."); - } - if (transferred !== undefined) { - let value = target.querySelector(".requests-menu-transferred").getAttribute("value"); - let tooltip = target.querySelector(".requests-menu-transferred").getAttribute("tooltiptext"); - info("Displayed transferred size: " + value); - info("Tooltip transferred size: " + tooltip); - is(value, transferred, "The displayed transferred size is incorrect."); - is(tooltip, transferred, "The tooltip transferred size is incorrect."); - } - if (size !== undefined) { - let value = target.querySelector(".requests-menu-size").getAttribute("value"); - let tooltip = target.querySelector(".requests-menu-size").getAttribute("tooltiptext"); - info("Displayed size: " + value); - info("Tooltip size: " + tooltip); - is(value, size, "The displayed size is incorrect."); - is(tooltip, size, "The tooltip size is incorrect."); - } - if (time !== undefined) { - let value = target.querySelector(".requests-menu-timings-total").getAttribute("value"); - let tooltip = target.querySelector(".requests-menu-timings-total").getAttribute("tooltiptext"); - info("Displayed time: " + value); - info("Tooltip time: " + tooltip); - ok(~~(value.match(/[0-9]+/)) >= 0, "The displayed time is incorrect."); - ok(~~(tooltip.match(/[0-9]+/)) >= 0, "The tooltip time is incorrect."); - } - - if (visibleIndex != -1) { - if (visibleIndex % 2 == 0) { - ok(aRequestItem.target.hasAttribute("even"), - "Unexpected 'even' attribute for " + aRequestItem.value); - ok(!aRequestItem.target.hasAttribute("odd"), - "Unexpected 'odd' attribute for " + aRequestItem.value); - } else { - ok(!aRequestItem.target.hasAttribute("even"), - "Unexpected 'even' attribute for " + aRequestItem.value); - ok(aRequestItem.target.hasAttribute("odd"), - "Unexpected 'odd' attribute for " + aRequestItem.value); - } - } -} - -/** - * Helper function for waiting for an event to fire before resolving a promise. - * Example: waitFor(aMonitor.panelWin, aMonitor.panelWin.EVENTS.TAB_UPDATED); - * - * @param object subject - * The event emitter object that is being listened to. - * @param string eventName - * The name of the event to listen to. - * @return object - * Returns a promise that resolves upon firing of the event. - */ -function waitFor (subject, eventName) { - let deferred = promise.defer(); - subject.once(eventName, deferred.resolve); - return deferred.promise; -} - -/** - * Tests if a button for a filter of given type is the only one checked. - * - * @param string aFilterType - * The type of the filter that should be the only one checked. - */ -function testFilterButtons(aMonitor, aFilterType) { - let doc = aMonitor.panelWin.document; - let target = doc.querySelector("#requests-menu-filter-" + aFilterType + "-button"); - let buttons = doc.querySelectorAll(".requests-menu-footer-button"); - - // Only target should be checked. - let checkStatus = [(button == target) ? 1 : 0 for (button of buttons)] - testFilterButtonsCustom(aMonitor, checkStatus); -} - -/** - * Tests if filter buttons have 'checked' attributes set correctly. - * - * @param array aIsChecked - * An array specifying if a button at given index should have a - * 'checked' attribute. For example, if the third item of the array - * evaluates to true, the third button should be checked. - */ -function testFilterButtonsCustom(aMonitor, aIsChecked) { - let doc = aMonitor.panelWin.document; - let buttons = doc.querySelectorAll(".requests-menu-footer-button"); - for (let i = 0; i < aIsChecked.length; i++) { - let button = buttons[i]; - if (aIsChecked[i]) { - is(button.hasAttribute("checked"), true, - "The " + button.id + " button should have a 'checked' attribute."); - } else { - is(button.hasAttribute("checked"), false, - "The " + button.id + " button should not have a 'checked' attribute."); - } - } -} - -/** - * Loads shared/frame-script-utils.js in the specified tab. - * - * @param tab - * Optional tab to load the frame script in. Defaults to the current tab. - */ -function loadCommonFrameScript(tab) { - let browser = tab ? tab.linkedBrowser : gBrowser.selectedBrowser; - - browser.messageManager.loadFrameScript(FRAME_SCRIPT_UTILS_URL, false); -} - -/** - * Perform the specified requests in the context of the page content. - * - * @param Array requests - * An array of objects specifying the requests to perform. See - * shared/frame-script-utils.js for more information. - * - * @return A promise that resolves once the requests complete. - */ -function performRequestsInContent(requests) { - info("Performing requests in the context of the content."); - return executeInContent("devtools:test:xhr", requests) -} - -/** - * Send an async message to the frame script (chrome -> content) and wait for a - * response message with the same name (content -> chrome). - * - * @param String name - * The message name. Should be one of the messages defined - * shared/frame-script-utils.js - * @param Object data - * Optional data to send along - * @param Object objects - * Optional CPOW objects to send along - * @param Boolean expectResponse - * If set to false, don't wait for a response with the same name from the - * content script. Defaults to true. - * - * @return Promise - * Resolves to the response data if a response is expected, immediately - * resolves otherwise - */ -function executeInContent(name, data={}, objects={}, expectResponse=true) { - let mm = gBrowser.selectedBrowser.messageManager; - - mm.sendAsyncMessage(name, data, objects); - if (expectResponse) { - return waitForContentMessage(name); - } else { - return promise.resolve(); - } -} - -/** - * Wait for a content -> chrome message on the message manager (the window - * messagemanager is used). - * @param {String} name The message name - * @return {Promise} A promise that resolves to the response data when the - * message has been received - */ -function waitForContentMessage(name) { - let mm = gBrowser.selectedBrowser.messageManager; - - let def = promise.defer(); - mm.addMessageListener(name, function onMessage(msg) { - mm.removeMessageListener(name, onMessage); - def.resolve(msg); - }); - return def.promise; -} diff --git a/browser/devtools/netmonitor/test/html_content-type-test-page.html b/browser/devtools/netmonitor/test/html_content-type-test-page.html deleted file mode 100644 index 23ecf1f44..000000000 --- a/browser/devtools/netmonitor/test/html_content-type-test-page.html +++ /dev/null @@ -1,48 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>Content type test</p> - - <script type="text/javascript"> - function get(aAddress, aCallback) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", aAddress, true); - - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - aCallback(); - } - }; - xhr.send(null); - } - - function performRequests() { - get("sjs_content-type-test-server.sjs?fmt=xml", function() { - get("sjs_content-type-test-server.sjs?fmt=css", function() { - get("sjs_content-type-test-server.sjs?fmt=js", function() { - get("sjs_content-type-test-server.sjs?fmt=json", function() { - get("sjs_content-type-test-server.sjs?fmt=bogus", function() { - get("test-image.png", function() { - // Done. - }); - }); - }); - }); - }); - }); - } - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_content-type-without-cache-test-page.html b/browser/devtools/netmonitor/test/html_content-type-without-cache-test-page.html deleted file mode 100644 index 40dad0c70..000000000 --- a/browser/devtools/netmonitor/test/html_content-type-without-cache-test-page.html +++ /dev/null @@ -1,48 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>Content type test</p> - - <script type="text/javascript"> - function get(aAddress, aCallback) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", aAddress, true); - - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - aCallback(); - } - }; - xhr.send(null); - } - - function performRequests() { - get("sjs_content-type-test-server.sjs?fmt=xml", function() { - get("sjs_content-type-test-server.sjs?fmt=css", function() { - get("sjs_content-type-test-server.sjs?fmt=js", function() { - get("sjs_content-type-test-server.sjs?fmt=json", function() { - get("sjs_content-type-test-server.sjs?fmt=bogus", function() { - get("test-image.png?v=" + Math.random(), function() { - // Done. - }); - }); - }); - }); - }); - }); - } - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_copy-as-curl.html b/browser/devtools/netmonitor/test/html_copy-as-curl.html deleted file mode 100644 index 3ddcfbced..000000000 --- a/browser/devtools/netmonitor/test/html_copy-as-curl.html +++ /dev/null @@ -1,30 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>Performing a GET request</p> - - <script type="text/javascript"> - function performRequest(aUrl) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", aUrl, true); - xhr.setRequestHeader("Accept-Language", window.navigator.language); - xhr.setRequestHeader("X-Custom-Header-1", "Custom value"); - xhr.setRequestHeader("X-Custom-Header-2", "8.8.8.8"); - xhr.setRequestHeader("X-Custom-Header-3", "Mon, 3 Mar 2014 11:11:11 GMT"); - xhr.send(null); - } - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_curl-utils.html b/browser/devtools/netmonitor/test/html_curl-utils.html deleted file mode 100644 index 8ff7ecdf0..000000000 --- a/browser/devtools/netmonitor/test/html_curl-utils.html +++ /dev/null @@ -1,102 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>Performing requests</p> - - <p> - <canvas width="100" height="100"></canvas> - </p> - - <hr/> - - <form method="post" action="#" enctype="multipart/form-data" target="target" id="post-form"> - <input type="text" name="param1" value="value1"/> - <input type="text" name="param2" value="value2"/> - <input type="text" name="param3" value="value3"/> - <input type="submit"/> - </form> - <iframe name="target"></iframe> - - <script type="text/javascript"> - - function ajaxGet(aUrl, aCallback) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", aUrl + "?param1=value1¶m2=value2¶m3=value3", true); - xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); - xhr.onload = function() { - aCallback(); - }; - xhr.send(); - } - - function ajaxPost(aUrl, aCallback) { - var xhr = new XMLHttpRequest(); - xhr.open("POST", aUrl, true); - xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); - xhr.onload = function() { - aCallback(); - }; - var params = "param1=value1¶m2=value2¶m3=value3"; - xhr.send(params); - } - - function ajaxMultipart(aUrl, aCallback) { - var xhr = new XMLHttpRequest(); - xhr.open("POST", aUrl, true); - xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); - xhr.onload = function() { - aCallback(); - }; - - getCanvasElem().toBlob((blob) => { - var formData = new FormData(); - formData.append("param1", "value1"); - formData.append("file", blob, "filename.png"); - xhr.send(formData); - }); - } - - function submitForm() { - var form = document.querySelector("#post-form"); - form.submit(); - } - - function getCanvasElem() { - return document.querySelector("canvas"); - } - - function initCanvas() { - var canvas = getCanvasElem(); - var ctx = canvas.getContext("2d"); - ctx.fillRect(0,0,100,100); - ctx.clearRect(20,20,60,60); - ctx.strokeRect(25,25,50,50); - } - - function performRequests(aUrl) { - ajaxGet(aUrl, () => { - ajaxPost(aUrl, () => { - ajaxMultipart(aUrl, () => { - submitForm(); - }); - }); - }); - } - - initCanvas(); - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_custom-get-page.html b/browser/devtools/netmonitor/test/html_custom-get-page.html deleted file mode 100644 index 19e40f93a..000000000 --- a/browser/devtools/netmonitor/test/html_custom-get-page.html +++ /dev/null @@ -1,44 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>Performing a custom number of GETs</p> - - <script type="text/javascript"> - function get(aAddress, aCallback) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", aAddress, true); - - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - aCallback(); - } - }; - xhr.send(null); - } - - // Use a count parameter to defeat caching. - var count = 0; - - function performRequests(aTotal, aUrl, aTimeout = 0) { - if (!aTotal) { - return; - } - get(aUrl || "request_" + (count++), function() { - setTimeout(performRequests.bind(this, --aTotal, aUrl, aTimeout), aTimeout); - }); - } - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_cyrillic-test-page.html b/browser/devtools/netmonitor/test/html_cyrillic-test-page.html deleted file mode 100644 index 8735ac674..000000000 --- a/browser/devtools/netmonitor/test/html_cyrillic-test-page.html +++ /dev/null @@ -1,39 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>Cyrillic type test</p> - <p>Братан, ты вообще качаешься?</p> - - <script type="text/javascript"> - function get(aAddress, aCallback) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", aAddress, true); - - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - aCallback(); - } - }; - xhr.send(null); - } - - function performRequests() { - get("sjs_content-type-test-server.sjs?fmt=txt", function() { - // Done. - }); - } - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_filter-test-page.html b/browser/devtools/netmonitor/test/html_filter-test-page.html deleted file mode 100644 index eb5d02ed9..000000000 --- a/browser/devtools/netmonitor/test/html_filter-test-page.html +++ /dev/null @@ -1,60 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>Filtering test</p> - - <script type="text/javascript"> - function get(aAddress, aCallback) { - var xhr = new XMLHttpRequest(); - // Use a random parameter to defeat caching. - xhr.open("GET", aAddress + "&" + Math.random(), true); - - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - aCallback(); - } - }; - xhr.send(null); - } - - function performRequests(aOptions) { - var options = JSON.parse(aOptions); - get("sjs_content-type-test-server.sjs?fmt=html&res=" + options.htmlContent, function() { - get("sjs_content-type-test-server.sjs?fmt=css", function() { - get("sjs_content-type-test-server.sjs?fmt=js", function() { - if (!options.getMedia) { - return; - } - get("sjs_content-type-test-server.sjs?fmt=font", function() { - get("sjs_content-type-test-server.sjs?fmt=image", function() { - get("sjs_content-type-test-server.sjs?fmt=audio", function() { - get("sjs_content-type-test-server.sjs?fmt=video", function() { - if (!options.getFlash) { - return; - } - get("sjs_content-type-test-server.sjs?fmt=flash", function() { - // Done. - }); - }); - }); - }); - }); - }); - }); - }); - } - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_infinite-get-page.html b/browser/devtools/netmonitor/test/html_infinite-get-page.html deleted file mode 100644 index f51b718ad..000000000 --- a/browser/devtools/netmonitor/test/html_infinite-get-page.html +++ /dev/null @@ -1,41 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>Infinite GETs</p> - - <script type="text/javascript"> - function get(aAddress, aCallback) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", aAddress, true); - - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - aCallback(); - } - }; - xhr.send(null); - } - - // Use a count parameter to defeat caching. - var count = 0; - - (function performRequests() { - get("request_" + (count++), function() { - setTimeout(performRequests, 50); - }); - })(); - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_json-custom-mime-test-page.html b/browser/devtools/netmonitor/test/html_json-custom-mime-test-page.html deleted file mode 100644 index 646fc60ea..000000000 --- a/browser/devtools/netmonitor/test/html_json-custom-mime-test-page.html +++ /dev/null @@ -1,38 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>JSONP test</p> - - <script type="text/javascript"> - function get(aAddress, aCallback) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", aAddress, true); - - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - aCallback(); - } - }; - xhr.send(null); - } - - function performRequests() { - get("sjs_content-type-test-server.sjs?fmt=json-custom-mime", function() { - // Done. - }); - } - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_json-long-test-page.html b/browser/devtools/netmonitor/test/html_json-long-test-page.html deleted file mode 100644 index b538b4c27..000000000 --- a/browser/devtools/netmonitor/test/html_json-long-test-page.html +++ /dev/null @@ -1,38 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>JSON long string test</p> - - <script type="text/javascript"> - function get(aAddress, aCallback) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", aAddress, true); - - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - aCallback(); - } - }; - xhr.send(null); - } - - function performRequests() { - get("sjs_content-type-test-server.sjs?fmt=json-long", function() { - // Done. - }); - } - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_json-malformed-test-page.html b/browser/devtools/netmonitor/test/html_json-malformed-test-page.html deleted file mode 100644 index 0c8627ab5..000000000 --- a/browser/devtools/netmonitor/test/html_json-malformed-test-page.html +++ /dev/null @@ -1,38 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>JSON malformed test</p> - - <script type="text/javascript"> - function get(aAddress, aCallback) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", aAddress, true); - - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - aCallback(); - } - }; - xhr.send(null); - } - - function performRequests() { - get("sjs_content-type-test-server.sjs?fmt=json-malformed", function() { - // Done. - }); - } - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_json-text-mime-test-page.html b/browser/devtools/netmonitor/test/html_json-text-mime-test-page.html deleted file mode 100644 index 2c64e2531..000000000 --- a/browser/devtools/netmonitor/test/html_json-text-mime-test-page.html +++ /dev/null @@ -1,38 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>JSON text test</p> - - <script type="text/javascript"> - function get(aAddress, aCallback) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", aAddress, true); - - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - aCallback(); - } - }; - xhr.send(null); - } - - function performRequests() { - get("sjs_content-type-test-server.sjs?fmt=json-text-mime", function() { - // Done. - }); - } - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_jsonp-test-page.html b/browser/devtools/netmonitor/test/html_jsonp-test-page.html deleted file mode 100644 index 78c0da08b..000000000 --- a/browser/devtools/netmonitor/test/html_jsonp-test-page.html +++ /dev/null @@ -1,40 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>JSONP test</p> - - <script type="text/javascript"> - function get(aAddress, aCallback) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", aAddress, true); - - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - aCallback(); - } - }; - xhr.send(null); - } - - function performRequests() { - get("sjs_content-type-test-server.sjs?fmt=jsonp&jsonp=$_0123Fun", function() { - get("sjs_content-type-test-server.sjs?fmt=jsonp2&jsonp=$_4567Sad", function() { - // Done. - }); - }); - } - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_navigate-test-page.html b/browser/devtools/netmonitor/test/html_navigate-test-page.html deleted file mode 100644 index 23f00f3df..000000000 --- a/browser/devtools/netmonitor/test/html_navigate-test-page.html +++ /dev/null @@ -1,18 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>Navigation test</p> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_params-test-page.html b/browser/devtools/netmonitor/test/html_params-test-page.html deleted file mode 100644 index de1394b8c..000000000 --- a/browser/devtools/netmonitor/test/html_params-test-page.html +++ /dev/null @@ -1,57 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>Request params type test</p> - - <script type="text/javascript"> - function post(aAddress, aQuery, aContentType, aPostBody) { - var xhr = new XMLHttpRequest(); - xhr.open("POST", aAddress + aQuery, true); - xhr.setRequestHeader("content-type", aContentType); - xhr.send(aPostBody); - } - - function performRequests() { - var urlencoded = "application/x-www-form-urlencoded"; - - setTimeout(function() { - post("baz", "?a", urlencoded, '{ "foo": "bar" }'); - - setTimeout(function() { - post("baz", "?a=b", urlencoded, '{ "foo": "bar" }'); - - setTimeout(function() { - post("baz", "?a=b", urlencoded, '?foo=bar'); - - setTimeout(function() { - post("baz", "?a", undefined, '{ "foo": "bar" }'); - - setTimeout(function() { - post("baz", "?a=b", undefined, '{ "foo": "bar" }'); - - setTimeout(function() { - post("baz", "?a=b", undefined, '?foo=bar'); - - // Done. - }, 10); - }, 10); - }, 10); - }, 10); - }, 10); - }, 10); - } - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_post-data-test-page.html b/browser/devtools/netmonitor/test/html_post-data-test-page.html deleted file mode 100644 index 8dedc7b60..000000000 --- a/browser/devtools/netmonitor/test/html_post-data-test-page.html +++ /dev/null @@ -1,77 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - <style> - input { - display: block; - margin: 12px; - } - </style> - </head> - - <body> - <p>POST data test</p> - <form enctype="multipart/form-data" method="post" name="form-name"> - <input type="text" name="text" placeholder="text" value="Some text..."/> - <input type="email" name="email" placeholder="email"/> - <input type="range" name="range" value="42"/> - <input type="button" value="Post me!" onclick="window.form()"> - </form> - - <script type="text/javascript"> - function post(aAddress, aMessage, aCallback) { - var xhr = new XMLHttpRequest(); - xhr.open("POST", aAddress, true); - xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - - var data = ""; - for (var i in aMessage) { - data += "&" + i + "=" + aMessage[i]; - } - - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - aCallback(); - } - }; - xhr.send(data); - } - - function form(aAddress, aForm, aCallback) { - var formData = new FormData(document.forms.namedItem(aForm)); - formData.append("Custom field", "Extra data"); - - var xhr = new XMLHttpRequest(); - xhr.open("POST", aAddress, true); - - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - aCallback(); - } - }; - xhr.send(formData); - } - - function performRequests() { - var url = "sjs_simple-test-server.sjs"; - var url1 = url + "?foo=bar&baz=42&type=urlencoded"; - var url2 = url + "?foo=bar&baz=42&type=multipart"; - - post(url1, { foo: "bar", baz: 123 }, function() { - form(url2, "form-name", function() { - // Done. - }); - }); - } - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_post-raw-test-page.html b/browser/devtools/netmonitor/test/html_post-raw-test-page.html deleted file mode 100644 index b4456348c..000000000 --- a/browser/devtools/netmonitor/test/html_post-raw-test-page.html +++ /dev/null @@ -1,40 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>POST raw test</p> - - <script type="text/javascript"> - function post(aAddress, aMessage, aCallback) { - var xhr = new XMLHttpRequest(); - xhr.open("POST", aAddress, true); - xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded"); - - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - aCallback(); - } - }; - xhr.send(aMessage); - } - - function performRequests() { - var rawData = "foo=bar&baz=123"; - post("sjs_simple-test-server.sjs", rawData, function() { - // Done. - }); - } - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_post-raw-with-headers-test-page.html b/browser/devtools/netmonitor/test/html_post-raw-with-headers-test-page.html deleted file mode 100644 index 3bb8f9071..000000000 --- a/browser/devtools/netmonitor/test/html_post-raw-with-headers-test-page.html +++ /dev/null @@ -1,45 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>POST raw with headers test</p> - - <script type="text/javascript"> - function post(aAddress, aMessage, aCallback) { - var xhr = new XMLHttpRequest(); - xhr.open("POST", aAddress, true); - - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - aCallback(); - } - }; - xhr.send(aMessage); - } - - function performRequests() { - var rawData = [ - "content-type: application/x-www-form-urlencoded\r", - "custom-header: hello world!\r", - "\r", - "\r", - "foo=bar&baz=123" - ]; - post("sjs_simple-test-server.sjs", rawData.join("\n"), function() { - // Done. - }); - } - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_simple-test-page.html b/browser/devtools/netmonitor/test/html_simple-test-page.html deleted file mode 100644 index 846681dbd..000000000 --- a/browser/devtools/netmonitor/test/html_simple-test-page.html +++ /dev/null @@ -1,18 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>Simple test</p> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_single-get-page.html b/browser/devtools/netmonitor/test/html_single-get-page.html deleted file mode 100644 index 0055d4ee0..000000000 --- a/browser/devtools/netmonitor/test/html_single-get-page.html +++ /dev/null @@ -1,36 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>Performing a custom number of GETs</p> - - <script type="text/javascript"> - function get(aAddress, aCallback) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", aAddress, true); - - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - aCallback(); - } - }; - xhr.send(null); - } - - (function performRequests() { - get("request_0", function() {}); - })(); - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_sorting-test-page.html b/browser/devtools/netmonitor/test/html_sorting-test-page.html deleted file mode 100644 index 582d84aea..000000000 --- a/browser/devtools/netmonitor/test/html_sorting-test-page.html +++ /dev/null @@ -1,47 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>Sorting test</p> - - <script type="text/javascript"> - function get(aAddress, aIndex, aCallback) { - var xhr = new XMLHttpRequest(); - // Use a random parameter to defeat caching. - xhr.open("GET" + aIndex, aAddress + "?index=" + aIndex + "&" + Math.random(), true); - - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - aCallback(); - } - }; - xhr.send(null); - } - - function performRequests() { - get("sjs_sorting-test-server.sjs", 1, function() { - get("sjs_sorting-test-server.sjs", 5, function() { - get("sjs_sorting-test-server.sjs", 2, function() { - get("sjs_sorting-test-server.sjs", 4, function() { - get("sjs_sorting-test-server.sjs", 3, function() { - // Done. - }); - }); - }); - }); - }); - } - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_statistics-test-page.html b/browser/devtools/netmonitor/test/html_statistics-test-page.html deleted file mode 100644 index b4b15b82b..000000000 --- a/browser/devtools/netmonitor/test/html_statistics-test-page.html +++ /dev/null @@ -1,40 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>Statistics test</p> - - <script type="text/javascript"> - function get(aAddress) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", aAddress, true); - xhr.send(null); - } - - get("sjs_content-type-test-server.sjs?sts=304&fmt=txt"); - get("sjs_content-type-test-server.sjs?sts=304&fmt=xml"); - get("sjs_content-type-test-server.sjs?sts=304&fmt=html"); - get("sjs_content-type-test-server.sjs?sts=304&fmt=css"); - get("sjs_content-type-test-server.sjs?sts=304&fmt=js"); - get("sjs_content-type-test-server.sjs?sts=304&fmt=json"); - get("sjs_content-type-test-server.sjs?sts=304&fmt=jsonp"); - get("sjs_content-type-test-server.sjs?sts=304&fmt=font"); - get("sjs_content-type-test-server.sjs?sts=304&fmt=image"); - get("sjs_content-type-test-server.sjs?sts=304&fmt=audio"); - get("sjs_content-type-test-server.sjs?sts=304&fmt=video"); - get("sjs_content-type-test-server.sjs?sts=304&fmt=flash"); - get("test-image.png?v=" + Math.random()); - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/html_status-codes-test-page.html b/browser/devtools/netmonitor/test/html_status-codes-test-page.html deleted file mode 100644 index b7320bbe5..000000000 --- a/browser/devtools/netmonitor/test/html_status-codes-test-page.html +++ /dev/null @@ -1,46 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!doctype html> - -<html> - <head> - <meta charset="utf-8"/> - <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="0" /> - <title>Network Monitor test page</title> - </head> - - <body> - <p>Status codes test</p> - - <script type="text/javascript"> - function get(aAddress, aCallback) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", aAddress, true); - - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - aCallback(); - } - }; - xhr.send(null); - } - - function performRequests() { - get("sjs_status-codes-test-server.sjs?sts=100", function() { - get("sjs_status-codes-test-server.sjs?sts=200", function() { - get("sjs_status-codes-test-server.sjs?sts=300", function() { - get("sjs_status-codes-test-server.sjs?sts=400", function() { - get("sjs_status-codes-test-server.sjs?sts=500", function() { - // Done. - }); - }); - }); - }); - }); - } - </script> - </body> - -</html> diff --git a/browser/devtools/netmonitor/test/sjs_content-type-test-server.sjs b/browser/devtools/netmonitor/test/sjs_content-type-test-server.sjs deleted file mode 100644 index fe429278f..000000000 --- a/browser/devtools/netmonitor/test/sjs_content-type-test-server.sjs +++ /dev/null @@ -1,191 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -const { classes: Cc, interfaces: Ci } = Components; - -function handleRequest(request, response) { - response.processAsync(); - - let params = request.queryString.split("&"); - let format = (params.filter((s) => s.contains("fmt="))[0] || "").split("=")[1]; - let status = (params.filter((s) => s.contains("sts="))[0] || "").split("=")[1] || 200; - - let cachedCount = 0; - let cacheExpire = 60; // seconds - - function setCacheHeaders() { - if (status != 304) { - response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); - response.setHeader("Pragma", "no-cache"); - response.setHeader("Expires", "0"); - return; - } - // Spice things up a little! - if (cachedCount % 2) { - response.setHeader("Cache-Control", "max-age=" + cacheExpire, false); - } else { - response.setHeader("Expires", Date(Date.now() + cacheExpire * 1000), false); - } - cachedCount++; - } - - let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); - timer.initWithCallback(() => { - // to avoid garbage collection - timer = null; - switch (format) { - case "txt": { - response.setStatusLine(request.httpVersion, status, "DA DA DA"); - response.setHeader("Content-Type", "text/plain", false); - setCacheHeaders(); - response.write("Братан, ты вообще качаешься?"); - response.finish(); - break; - } - case "xml": { - response.setStatusLine(request.httpVersion, status, "OK"); - response.setHeader("Content-Type", "text/xml; charset=utf-8", false); - setCacheHeaders(); - response.write("<label value='greeting'>Hello XML!</label>"); - response.finish(); - break; - } - case "html": { - let content = params.filter((s) => s.contains("res="))[0].split("=")[1]; - response.setStatusLine(request.httpVersion, status, "OK"); - response.setHeader("Content-Type", "text/html; charset=utf-8", false); - setCacheHeaders(); - response.write(content || "<p>Hello HTML!</p>"); - response.finish(); - break; - } - case "html-long": { - let str = new Array(102400 /* 100 KB in bytes */).join("."); - response.setStatusLine(request.httpVersion, status, "OK"); - response.setHeader("Content-Type", "text/html; charset=utf-8", false); - setCacheHeaders(); - response.write("<p>" + str + "</p>"); - response.finish(); - break; - } - case "css": { - response.setStatusLine(request.httpVersion, status, "OK"); - response.setHeader("Content-Type", "text/css; charset=utf-8", false); - setCacheHeaders(); - response.write("body:pre { content: 'Hello CSS!' }"); - response.finish(); - break; - } - case "js": { - response.setStatusLine(request.httpVersion, status, "OK"); - response.setHeader("Content-Type", "application/javascript; charset=utf-8", false); - setCacheHeaders(); - response.write("function() { return 'Hello JS!'; }"); - response.finish(); - break; - } - case "json": { - response.setStatusLine(request.httpVersion, status, "OK"); - response.setHeader("Content-Type", "application/json; charset=utf-8", false); - setCacheHeaders(); - response.write("{ \"greeting\": \"Hello JSON!\" }"); - response.finish(); - break; - } - case "jsonp": { - let fun = params.filter((s) => s.contains("jsonp="))[0].split("=")[1]; - response.setStatusLine(request.httpVersion, status, "OK"); - response.setHeader("Content-Type", "text/json; charset=utf-8", false); - setCacheHeaders(); - response.write(fun + "({ \"greeting\": \"Hello JSONP!\" })"); - response.finish(); - break; - } - case "jsonp2": { - let fun = params.filter((s) => s.contains("jsonp="))[0].split("=")[1]; - response.setStatusLine(request.httpVersion, status, "OK"); - response.setHeader("Content-Type", "text/json; charset=utf-8", false); - setCacheHeaders(); - response.write(" " + fun + " ( { \"greeting\": \"Hello weird JSONP!\" } ) ; "); - response.finish(); - break; - } - case "json-long": { - let str = "{ \"greeting\": \"Hello long string JSON!\" },"; - response.setStatusLine(request.httpVersion, status, "OK"); - response.setHeader("Content-Type", "text/json; charset=utf-8", false); - setCacheHeaders(); - response.write("[" + new Array(2048).join(str).slice(0, -1) + "]"); - response.finish(); - break; - } - case "json-malformed": { - response.setStatusLine(request.httpVersion, status, "OK"); - response.setHeader("Content-Type", "text/json; charset=utf-8", false); - setCacheHeaders(); - response.write("{ \"greeting\": \"Hello malformed JSON!\" },"); - response.finish(); - break; - } - case "json-text-mime": { - response.setStatusLine(request.httpVersion, status, "OK"); - response.setHeader("Content-Type", "text/plain; charset=utf-8", false); - setCacheHeaders(); - response.write("{ \"greeting\": \"Hello third-party JSON!\" }"); - response.finish(); - break; - } - case "json-custom-mime": { - response.setStatusLine(request.httpVersion, status, "OK"); - response.setHeader("Content-Type", "text/x-bigcorp-json; charset=utf-8", false); - setCacheHeaders(); - response.write("{ \"greeting\": \"Hello oddly-named JSON!\" }"); - response.finish(); - break; - } - case "font": { - response.setStatusLine(request.httpVersion, status, "OK"); - response.setHeader("Content-Type", "font/woff", false); - setCacheHeaders(); - response.finish(); - break; - } - case "image": { - response.setStatusLine(request.httpVersion, status, "OK"); - response.setHeader("Content-Type", "image/png", false); - setCacheHeaders(); - response.finish(); - break; - } - case "audio": { - response.setStatusLine(request.httpVersion, status, "OK"); - response.setHeader("Content-Type", "audio/ogg", false); - setCacheHeaders(); - response.finish(); - break; - } - case "video": { - response.setStatusLine(request.httpVersion, status, "OK"); - response.setHeader("Content-Type", "video/webm", false); - setCacheHeaders(); - response.finish(); - break; - } - case "flash": { - response.setStatusLine(request.httpVersion, status, "OK"); - response.setHeader("Content-Type", "application/x-shockwave-flash", false); - setCacheHeaders(); - response.finish(); - break; - } - default: { - response.setStatusLine(request.httpVersion, 404, "Not Found"); - response.setHeader("Content-Type", "text/html; charset=utf-8", false); - setCacheHeaders(); - response.write("<blink>Not Found</blink>"); - response.finish(); - break; - } - } - }, 10, Ci.nsITimer.TYPE_ONE_SHOT); // Make sure this request takes a few ms. -} diff --git a/browser/devtools/netmonitor/test/sjs_cors-test-server.sjs b/browser/devtools/netmonitor/test/sjs_cors-test-server.sjs deleted file mode 100644 index 5cdac7799..000000000 --- a/browser/devtools/netmonitor/test/sjs_cors-test-server.sjs +++ /dev/null @@ -1,16 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -function handleRequest(request, response) { - response.setStatusLine(request.httpVersion, 200, "Och Aye"); - - response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); - response.setHeader("Pragma", "no-cache"); - response.setHeader("Expires", "0"); - - response.setHeader("Access-Control-Allow-Origin", "*", false); - - response.setHeader("Content-Type", "text/plain; charset=utf-8", false); - - response.write("Access-Control-Allow-Origin: *"); -} diff --git a/browser/devtools/netmonitor/test/sjs_https-redirect-test-server.sjs b/browser/devtools/netmonitor/test/sjs_https-redirect-test-server.sjs deleted file mode 100644 index 14ea34559..000000000 --- a/browser/devtools/netmonitor/test/sjs_https-redirect-test-server.sjs +++ /dev/null @@ -1,19 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -function handleRequest(request, response) { - response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); - response.setHeader("Pragma", "no-cache"); - response.setHeader("Expires", "0"); - - response.setHeader("Access-Control-Allow-Origin", "*", false); - - if (request.scheme === "http") { - response.setStatusLine(request.httpVersion, 302, "Found"); - response.setHeader("Location", "https://" + request.host + request.path); - } else { - response.setStatusLine(request.httpVersion, 200, "OK"); - response.write("Page was accessed over HTTPS!"); - } - -} diff --git a/browser/devtools/netmonitor/test/sjs_simple-test-server.sjs b/browser/devtools/netmonitor/test/sjs_simple-test-server.sjs deleted file mode 100644 index 9a3d44b6d..000000000 --- a/browser/devtools/netmonitor/test/sjs_simple-test-server.sjs +++ /dev/null @@ -1,17 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -function handleRequest(request, response) { - response.setStatusLine(request.httpVersion, 200, "Och Aye"); - - response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); - response.setHeader("Pragma", "no-cache"); - response.setHeader("Expires", "0"); - - response.setHeader("Set-Cookie", "bob=true; Max-Age=10; HttpOnly", true); - response.setHeader("Set-Cookie", "tom=cool; Max-Age=10; HttpOnly", true); - - response.setHeader("Content-Type", "text/plain; charset=utf-8", false); - response.setHeader("Foo-Bar", "baz", false); - response.write("Hello world!"); -} diff --git a/browser/devtools/netmonitor/test/sjs_sorting-test-server.sjs b/browser/devtools/netmonitor/test/sjs_sorting-test-server.sjs deleted file mode 100644 index d672f61b1..000000000 --- a/browser/devtools/netmonitor/test/sjs_sorting-test-server.sjs +++ /dev/null @@ -1,26 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -const { classes: Cc, interfaces: Ci } = Components; - -function handleRequest(request, response) { - response.processAsync(); - - let params = request.queryString.split("&"); - let index = params.filter((s) => s.contains("index="))[0].split("=")[1]; - - let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); - timer.initWithCallback(() => { - // to avoid garbage collection - timer = null; - response.setStatusLine(request.httpVersion, index == 1 ? 101 : index * 100, "Meh"); - - response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); - response.setHeader("Pragma", "no-cache"); - response.setHeader("Expires", "0"); - - response.setHeader("Content-Type", "text/" + index, false); - response.write(new Array(index * 10).join(index)); // + 0.01 KB - response.finish(); - }, 10, Ci.nsITimer.TYPE_ONE_SHOT); // Make sure this request takes a few ms. -} diff --git a/browser/devtools/netmonitor/test/sjs_status-codes-test-server.sjs b/browser/devtools/netmonitor/test/sjs_status-codes-test-server.sjs deleted file mode 100644 index bce661220..000000000 --- a/browser/devtools/netmonitor/test/sjs_status-codes-test-server.sjs +++ /dev/null @@ -1,42 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -const { classes: Cc, interfaces: Ci } = Components; - -function handleRequest(request, response) { - response.processAsync(); - - let params = request.queryString.split("&"); - let status = params.filter((s) => s.contains("sts="))[0].split("=")[1]; - - let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); - timer.initWithCallback(() => { - // to avoid garbage collection - timer = null; - switch (status) { - case "100": - response.setStatusLine(request.httpVersion, 101, "Switching Protocols"); - break; - case "200": - response.setStatusLine(request.httpVersion, 202, "Created"); - break; - case "300": - response.setStatusLine(request.httpVersion, 303, "See Other"); - break; - case "400": - response.setStatusLine(request.httpVersion, 404, "Not Found"); - break; - case "500": - response.setStatusLine(request.httpVersion, 501, "Not Implemented"); - break; - } - - response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); - response.setHeader("Pragma", "no-cache"); - response.setHeader("Expires", "0"); - - response.setHeader("Content-Type", "text/plain; charset=utf-8", false); - response.write("Hello status code " + status + "!"); - response.finish(); - }, 10, Ci.nsITimer.TYPE_ONE_SHOT); // Make sure this request takes a few ms. -} diff --git a/browser/devtools/netmonitor/test/test-image.png b/browser/devtools/netmonitor/test/test-image.png Binary files differdeleted file mode 100644 index 769c63634..000000000 --- a/browser/devtools/netmonitor/test/test-image.png +++ /dev/null |