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.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Tests if image responses show a thumbnail in the requests menu.
     6  */
     8 function test() {
     9   initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL).then(([aTab, aDebuggee, aMonitor]) => {
    10     info("Starting test... ");
    12     let { $, $all, EVENTS, ACTIVITY_TYPE, NetMonitorView, NetMonitorController } = aMonitor.panelWin;
    13     let { RequestsMenu } = NetMonitorView;
    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();
    22       RequestsMenu.sortBy("size");
    23       info("Checking the image thumbnail when all items are sorted.");
    24       checkImageThumbnail();
    26       RequestsMenu.filterOn("images");
    27       info("Checking the image thumbnail when only images are shown.");
    28       checkImageThumbnail();
    30       info("Reloading the debuggee and performing all requests again...");
    31       reloadAndPerformRequests();
    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();
    41       teardown(aMonitor).then(finish);
    42     });
    44     function reloadAndPerformRequests() {
    45       NetMonitorController.triggerActivity(ACTIVITY_TYPE.RELOAD.WITH_CACHE_ENABLED).then(() => {
    46         aDebuggee.performRequests();
    47       });
    48     }
    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     }
    59     aDebuggee.performRequests();
    60   });
    61 }

mercurial