|
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 popup in the requests menu when hovered. |
|
6 */ |
|
7 |
|
8 function test() { |
|
9 initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL).then(([aTab, aDebuggee, aMonitor]) => { |
|
10 info("Starting test... "); |
|
11 |
|
12 let { $, 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 after a few requests were made..."); |
|
20 let requestItem = RequestsMenu.items[5]; |
|
21 let requestTooltip = requestItem.attachment.tooltip; |
|
22 ok(requestTooltip, "There should be a tooltip instance for the image request."); |
|
23 |
|
24 let anchor = $(".requests-menu-file", requestItem.target); |
|
25 return showTooltipOn(requestTooltip, anchor); |
|
26 }).then(aTooltip => { |
|
27 ok(true, |
|
28 "An tooltip was successfully opened for the image request."); |
|
29 is(aTooltip.content.querySelector("image").src, TEST_IMAGE_DATA_URI, |
|
30 "The tooltip's image content is displayed correctly."); |
|
31 |
|
32 info("Reloading the debuggee and performing all requests again..."); |
|
33 reloadAndPerformRequests(); |
|
34 |
|
35 return promise.all([ |
|
36 waitForNetworkEvents(aMonitor, 7), // 6 + 1 |
|
37 waitFor(aMonitor.panelWin, EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED) |
|
38 ]); |
|
39 }).then(() => { |
|
40 info("Checking the image thumbnail after a reload."); |
|
41 let requestItem = RequestsMenu.items[6]; |
|
42 let requestTooltip = requestItem.attachment.tooltip; |
|
43 ok(requestTooltip, "There should be a tooltip instance for the image request."); |
|
44 |
|
45 let anchor = $(".requests-menu-file", requestItem.target); |
|
46 return showTooltipOn(requestTooltip, anchor); |
|
47 }).then(aTooltip => { |
|
48 ok(true, |
|
49 "An tooltip was successfully opened for the image request."); |
|
50 is(aTooltip.content.querySelector("image").src, TEST_IMAGE_DATA_URI, |
|
51 "The tooltip's image content is displayed correctly."); |
|
52 |
|
53 teardown(aMonitor).then(finish); |
|
54 }); |
|
55 |
|
56 function reloadAndPerformRequests() { |
|
57 NetMonitorController.triggerActivity(ACTIVITY_TYPE.RELOAD.WITH_CACHE_ENABLED).then(() => { |
|
58 aDebuggee.performRequests(); |
|
59 }); |
|
60 } |
|
61 |
|
62 /** |
|
63 * @return a promise that resolves when the tooltip is shown |
|
64 */ |
|
65 function showTooltipOn(tooltip, element) { |
|
66 return Task.spawn(function*() { |
|
67 let isTarget = yield tooltip.isValidHoverTarget(element); |
|
68 let onShown = tooltip.once("shown"); |
|
69 tooltip.show(); |
|
70 yield onShown; |
|
71 return tooltip; |
|
72 }); |
|
73 } |
|
74 |
|
75 aDebuggee.performRequests(); |
|
76 }); |
|
77 } |