1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/netmonitor/test/browser_net_icon-preview.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests if image responses show a thumbnail in the requests menu. 1.9 + */ 1.10 + 1.11 +function test() { 1.12 + initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL).then(([aTab, aDebuggee, aMonitor]) => { 1.13 + info("Starting test... "); 1.14 + 1.15 + let { $, $all, EVENTS, ACTIVITY_TYPE, NetMonitorView, NetMonitorController } = aMonitor.panelWin; 1.16 + let { RequestsMenu } = NetMonitorView; 1.17 + 1.18 + promise.all([ 1.19 + waitForNetworkEvents(aMonitor, 6), 1.20 + waitFor(aMonitor.panelWin, EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED) 1.21 + ]).then(() => { 1.22 + info("Checking the image thumbnail when all items are shown."); 1.23 + checkImageThumbnail(); 1.24 + 1.25 + RequestsMenu.sortBy("size"); 1.26 + info("Checking the image thumbnail when all items are sorted."); 1.27 + checkImageThumbnail(); 1.28 + 1.29 + RequestsMenu.filterOn("images"); 1.30 + info("Checking the image thumbnail when only images are shown."); 1.31 + checkImageThumbnail(); 1.32 + 1.33 + info("Reloading the debuggee and performing all requests again..."); 1.34 + reloadAndPerformRequests(); 1.35 + 1.36 + return promise.all([ 1.37 + waitForNetworkEvents(aMonitor, 7), // 6 + 1 1.38 + waitFor(aMonitor.panelWin, EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED) 1.39 + ]); 1.40 + }).then(() => { 1.41 + info("Checking the image thumbnail after a reload."); 1.42 + checkImageThumbnail(); 1.43 + 1.44 + teardown(aMonitor).then(finish); 1.45 + }); 1.46 + 1.47 + function reloadAndPerformRequests() { 1.48 + NetMonitorController.triggerActivity(ACTIVITY_TYPE.RELOAD.WITH_CACHE_ENABLED).then(() => { 1.49 + aDebuggee.performRequests(); 1.50 + }); 1.51 + } 1.52 + 1.53 + function checkImageThumbnail() { 1.54 + is($all(".requests-menu-icon[type=thumbnail]").length, 1, 1.55 + "There should be only one image request with a thumbnail displayed."); 1.56 + is($(".requests-menu-icon[type=thumbnail]").src, TEST_IMAGE_DATA_URI, 1.57 + "The image requests-menu-icon thumbnail is displayed correctly."); 1.58 + is($(".requests-menu-icon[type=thumbnail]").hidden, false, 1.59 + "The image requests-menu-icon thumbnail should not be hidden."); 1.60 + } 1.61 + 1.62 + aDebuggee.performRequests(); 1.63 + }); 1.64 +}