michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests if image responses show a thumbnail in the requests menu. michael@0: */ michael@0: michael@0: function test() { michael@0: initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL).then(([aTab, aDebuggee, aMonitor]) => { michael@0: info("Starting test... "); michael@0: michael@0: let { $, $all, EVENTS, ACTIVITY_TYPE, NetMonitorView, NetMonitorController } = aMonitor.panelWin; michael@0: let { RequestsMenu } = NetMonitorView; michael@0: michael@0: promise.all([ michael@0: waitForNetworkEvents(aMonitor, 6), michael@0: waitFor(aMonitor.panelWin, EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED) michael@0: ]).then(() => { michael@0: info("Checking the image thumbnail when all items are shown."); michael@0: checkImageThumbnail(); michael@0: michael@0: RequestsMenu.sortBy("size"); michael@0: info("Checking the image thumbnail when all items are sorted."); michael@0: checkImageThumbnail(); michael@0: michael@0: RequestsMenu.filterOn("images"); michael@0: info("Checking the image thumbnail when only images are shown."); michael@0: checkImageThumbnail(); michael@0: michael@0: info("Reloading the debuggee and performing all requests again..."); michael@0: reloadAndPerformRequests(); michael@0: michael@0: return promise.all([ michael@0: waitForNetworkEvents(aMonitor, 7), // 6 + 1 michael@0: waitFor(aMonitor.panelWin, EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED) michael@0: ]); michael@0: }).then(() => { michael@0: info("Checking the image thumbnail after a reload."); michael@0: checkImageThumbnail(); michael@0: michael@0: teardown(aMonitor).then(finish); michael@0: }); michael@0: michael@0: function reloadAndPerformRequests() { michael@0: NetMonitorController.triggerActivity(ACTIVITY_TYPE.RELOAD.WITH_CACHE_ENABLED).then(() => { michael@0: aDebuggee.performRequests(); michael@0: }); michael@0: } michael@0: michael@0: function checkImageThumbnail() { michael@0: is($all(".requests-menu-icon[type=thumbnail]").length, 1, michael@0: "There should be only one image request with a thumbnail displayed."); michael@0: is($(".requests-menu-icon[type=thumbnail]").src, TEST_IMAGE_DATA_URI, michael@0: "The image requests-menu-icon thumbnail is displayed correctly."); michael@0: is($(".requests-menu-icon[type=thumbnail]").hidden, false, michael@0: "The image requests-menu-icon thumbnail should not be hidden."); michael@0: } michael@0: michael@0: aDebuggee.performRequests(); michael@0: }); michael@0: }