Bug 1924993 - [devtools] Debugger tests wait before typing in conditional panel r...
[gecko.git] / devtools / client / netmonitor / test / browser_net_data_uri.js
blob14895b2ce3a455a84da5afdf302b0b3c14640953
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 "use strict";
6 /**
7 * Tests that navigation request to a data uri is correctly logged in the
8 * network monitor.
9 */
10 add_task(async function test_navigation_to_data_uri() {
11 const URL = "data:text/html,Hello from data-url!";
12 const { monitor } = await initNetMonitor(URL, {
13 requestCount: 1,
14 waitForLoad: false,
15 });
16 info("Starting test... ");
18 const { document, store, windowRequire } = monitor.panelWin;
19 const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
21 store.dispatch(Actions.batchEnable(false));
23 const wait = waitForNetworkEvents(monitor, 1);
24 reloadBrowser({ waitForLoad: false });
25 await wait;
27 const firstItem = document.querySelectorAll(".request-list-item")[0];
29 is(
30 firstItem.querySelector(".requests-list-url").innerText,
31 URL,
32 "The url in the displayed request is correct"
34 is(
35 firstItem.querySelector(".requests-list-scheme").innerText,
36 "data",
37 "The scheme in the displayed request is correct"
39 is(
40 firstItem.querySelector(".requests-list-file").innerText,
41 URL,
42 "The file in the displayed request is correct"
44 ok(hasValidSize(firstItem), "The request shows a valid size");
46 await teardown(monitor);
47 });
49 /**
50 * Tests that requests to data URIs made from a content page are logged in the
51 * network monitor.
53 add_task(async function test_content_request_to_data_uri() {
54 const IMAGE_URL =
55 "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
56 const URL = `https://example.com/document-builder.sjs?html=
57 <h1>Test page for content data uri request</h1>
58 <img src="${IMAGE_URL}"></iframe>`;
60 const { monitor } = await initNetMonitor(URL, {
61 requestCount: 1,
62 waitForLoad: false,
63 });
64 info("Starting test... ");
66 const { document, store, windowRequire } = monitor.panelWin;
67 const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
69 store.dispatch(Actions.batchEnable(false));
71 const wait = waitForNetworkEvents(monitor, 2);
72 reloadBrowser({ waitForLoad: false });
73 await wait;
75 const firstItem = document.querySelectorAll(".request-list-item")[1];
77 is(
78 firstItem.querySelector(".requests-list-url").innerText,
79 IMAGE_URL,
80 "The url in the displayed request is correct"
82 is(
83 firstItem.querySelector(".requests-list-scheme").innerText,
84 "data",
85 "The scheme in the displayed request is correct"
87 is(
88 firstItem.querySelector(".requests-list-file").innerText,
89 IMAGE_URL,
90 "The file in the displayed request is correct"
92 ok(hasValidSize(firstItem), "The request shows a valid size");
94 await teardown(monitor);
95 });