browser/devtools/netmonitor/test/browser_net_icon-preview.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial