|
3 | 3 |
|
4 | 4 | "use strict"; |
5 | 5 |
|
6 | | -// XXX Remove this when the file is migrated to the new frontend. |
7 | | -/* eslint-disable no-undef */ |
8 | | - |
9 | 6 | // See Bug 595223. |
10 | 7 |
|
11 | | -const PREF = "devtools.webconsole.persistlog"; |
12 | 8 | const TEST_FILE = "test-network.html"; |
13 | 9 |
|
14 | 10 | var hud; |
15 | 11 |
|
16 | 12 | add_task(async function () { |
17 | | - Services.prefs.setBoolPref(PREF, true); |
| 13 | + // Display network requests |
| 14 | + await pushPref("devtools.webconsole.filter.net", true); |
| 15 | + |
| 16 | + await addTab("about:blank"); |
| 17 | + hud = await openConsole(); |
| 18 | + await clearOutput(hud); |
18 | 19 |
|
19 | 20 | const jar = getJar(getRootDirectory(gTestPath)); |
20 | 21 | const dir = jar |
21 | 22 | ? extractJarToTmp(jar) |
22 | 23 | : getChromeDir(getResolvedURI(gTestPath)); |
23 | | - |
24 | 24 | dir.append(TEST_FILE); |
25 | 25 | const uri = Services.io.newFileURI(dir); |
26 | 26 |
|
27 | | - // Open tab with correct remote type so we don't switch processes when we load |
28 | | - // the file:// URI, otherwise we won't get the same web console. |
29 | | - const remoteType = E10SUtils.getRemoteTypeForURI( |
30 | | - uri.spec, |
31 | | - gMultiProcessBrowser, |
32 | | - gFissionBrowser |
| 27 | + const onConsoleMessage = waitForMessageByType( |
| 28 | + hud, |
| 29 | + "running network console logging tests", |
| 30 | + ".console-api" |
| 31 | + ); |
| 32 | + const onHTMLFileMessage = waitForMessageByType( |
| 33 | + hud, |
| 34 | + "test-network.html", |
| 35 | + ".network" |
| 36 | + ); |
| 37 | + const onImageFileMessage = waitForMessageByType( |
| 38 | + hud, |
| 39 | + "test-image.png", |
| 40 | + ".network" |
| 41 | + ); |
| 42 | + const onJSFileMessage = waitForMessageByType( |
| 43 | + hud, |
| 44 | + "testscript.js?foo", |
| 45 | + ".network" |
33 | 46 | ); |
34 | | - await loadTab("about:blank", remoteType); |
35 | 47 |
|
36 | | - hud = await openConsole(); |
37 | | - await clearOutput(hud); |
| 48 | + navigateTo(uri.spec); |
38 | 49 |
|
39 | | - await navigateTo(uri.spec); |
| 50 | + await onConsoleMessage; |
| 51 | + ok(true, "console message is displayed"); |
40 | 52 |
|
41 | | - await testMessages(); |
| 53 | + let message = await onHTMLFileMessage; |
| 54 | + ok( |
| 55 | + message.node.querySelector(".url").innerText.startsWith("file://"), |
| 56 | + "HTML file request is displayed" |
| 57 | + ); |
42 | 58 |
|
43 | | - Services.prefs.clearUserPref(PREF); |
44 | | - hud = null; |
45 | | -}); |
| 59 | + message = await onImageFileMessage; |
| 60 | + ok( |
| 61 | + message.node.querySelector(".url").innerText.startsWith("file://"), |
| 62 | + "image file request is displayed" |
| 63 | + ); |
46 | 64 |
|
47 | | -function testMessages() { |
48 | | - return waitForMessagesByType({ |
49 | | - webconsole: hud, |
50 | | - messages: [ |
51 | | - { |
52 | | - text: "running network console logging tests", |
53 | | - typeSelector: ".console-api", |
54 | | - category: CATEGORY_WEBDEV, |
55 | | - severity: SEVERITY_LOG, |
56 | | - }, |
57 | | - { |
58 | | - text: "test-network.html", |
59 | | - typeSelector: ".network", |
60 | | - category: CATEGORY_NETWORK, |
61 | | - severity: SEVERITY_LOG, |
62 | | - }, |
63 | | - { |
64 | | - text: "test-image.png", |
65 | | - typeSelector: ".network", |
66 | | - category: CATEGORY_NETWORK, |
67 | | - severity: SEVERITY_LOG, |
68 | | - }, |
69 | | - { |
70 | | - text: "testscript.js", |
71 | | - typeSelector: ".network", |
72 | | - category: CATEGORY_NETWORK, |
73 | | - severity: SEVERITY_LOG, |
74 | | - }, |
75 | | - ], |
76 | | - }); |
77 | | -} |
| 65 | + message = await onJSFileMessage; |
| 66 | + ok( |
| 67 | + message.node.querySelector(".url").innerText.startsWith("file://"), |
| 68 | + "JS file request is displayed" |
| 69 | + ); |
| 70 | +}); |
0 commit comments