|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests if image responses show a thumbnail in the requests menu. |
|
6 */ |
|
7 |
|
8 function test() { |
|
9 initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL).then(([aTab, aDebuggee, aMonitor]) => { |
|
10 info("Starting test... "); |
|
11 |
|
12 let { $, $all, EVENTS, ACTIVITY_TYPE, NetMonitorView, NetMonitorController } = aMonitor.panelWin; |
|
13 let { RequestsMenu } = NetMonitorView; |
|
14 |
|
15 promise.all([ |
|
16 waitForNetworkEvents(aMonitor, 6), |
|
17 waitFor(aMonitor.panelWin, EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED) |
|
18 ]).then(() => { |
|
19 info("Checking the image thumbnail when all items are shown."); |
|
20 checkImageThumbnail(); |
|
21 |
|
22 RequestsMenu.sortBy("size"); |
|
23 info("Checking the image thumbnail when all items are sorted."); |
|
24 checkImageThumbnail(); |
|
25 |
|
26 RequestsMenu.filterOn("images"); |
|
27 info("Checking the image thumbnail when only images are shown."); |
|
28 checkImageThumbnail(); |
|
29 |
|
30 info("Reloading the debuggee and performing all requests again..."); |
|
31 reloadAndPerformRequests(); |
|
32 |
|
33 return promise.all([ |
|
34 waitForNetworkEvents(aMonitor, 7), // 6 + 1 |
|
35 waitFor(aMonitor.panelWin, EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED) |
|
36 ]); |
|
37 }).then(() => { |
|
38 info("Checking the image thumbnail after a reload."); |
|
39 checkImageThumbnail(); |
|
40 |
|
41 teardown(aMonitor).then(finish); |
|
42 }); |
|
43 |
|
44 function reloadAndPerformRequests() { |
|
45 NetMonitorController.triggerActivity(ACTIVITY_TYPE.RELOAD.WITH_CACHE_ENABLED).then(() => { |
|
46 aDebuggee.performRequests(); |
|
47 }); |
|
48 } |
|
49 |
|
50 function checkImageThumbnail() { |
|
51 is($all(".requests-menu-icon[type=thumbnail]").length, 1, |
|
52 "There should be only one image request with a thumbnail displayed."); |
|
53 is($(".requests-menu-icon[type=thumbnail]").src, TEST_IMAGE_DATA_URI, |
|
54 "The image requests-menu-icon thumbnail is displayed correctly."); |
|
55 is($(".requests-menu-icon[type=thumbnail]").hidden, false, |
|
56 "The image requests-menu-icon thumbnail should not be hidden."); |
|
57 } |
|
58 |
|
59 aDebuggee.performRequests(); |
|
60 }); |
|
61 } |