browser/devtools/commandline/test/browser_cmd_appcache_valid.js

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/ */
     4 // Tests that the appcache commands works as they should
     6 const TEST_URI = "http://sub1.test2.example.com/browser/browser/devtools/" +
     7                  "commandline/test/browser_cmd_appcache_valid_index.html";
     9 function test() {
    10   return Task.spawn(spawnTest).then(finish, helpers.handleError);
    11 }
    13 function spawnTest() {
    14   let options = yield helpers.openTab(TEST_URI);
    15   yield helpers.openToolbar(options);
    17   info("adding cache listener.");
    19   // Wait for site to be cached.
    20   yield helpers.listenOnce(gBrowser.contentWindow.applicationCache, 'cached');
    22   // Pages containing an appcache the notification bar gives options to allow
    23   // or deny permission for the app to save data offline. Let's click Allow.
    24   let notificationID = "offline-app-requested-sub1.test2.example.com";
    25   let notification = PopupNotifications.getNotification(notificationID, gBrowser.selectedBrowser);
    27   if (notification) {
    28     info("Authorizing offline storage.");
    29     notification.mainAction.callback();
    30   } else {
    31     info("No notification box is available.");
    32   }
    34   info("Site now cached, running tests.");
    35   yield helpers.audit(options, [
    36     {
    37       setup: 'appcache',
    38       check: {
    39         input:  'appcache',
    40         markup: 'IIIIIIII',
    41         status: 'ERROR',
    42         args: {}
    43       },
    44     },
    46     {
    47       setup: function() {
    48         Services.prefs.setBoolPref("browser.cache.disk.enable", false);
    49         return helpers.setInput(options, 'appcache list', 13);
    50       },
    51       check: {
    52         input:  'appcache list',
    53         markup: 'VVVVVVVVVVVVV',
    54         status: 'VALID',
    55         args: {},
    56       },
    57       exec: {
    58         output: [ /cache is disabled/ ]
    59       },
    60       post: function(output) {
    61         Services.prefs.setBoolPref("browser.cache.disk.enable", true);
    62       }
    63     },
    65     {
    66       setup: 'appcache list',
    67       check: {
    68         input:  'appcache list',
    69         markup: 'VVVVVVVVVVVVV',
    70         status: 'VALID',
    71         args: {},
    72       },
    73       exec: {
    74         output: [ /index/, /page1/, /page2/, /page3/ ]
    75       },
    76     },
    78     {
    79       setup: 'appcache list page',
    80       check: {
    81         input:  'appcache list page',
    82         markup: 'VVVVVVVVVVVVVVVVVV',
    83         status: 'VALID',
    84         args: {
    85           search: { value: 'page' },
    86         }
    87       },
    88       exec: {
    89         output: [ /page1/, /page2/, /page3/ ]
    90       },
    91       post: function(output, text) {
    92         ok(!text.contains("index"), "index is not contained in output");
    93       }
    94     },
    96     {
    97       setup: 'appcache validate',
    98       check: {
    99         input:  'appcache validate',
   100         markup: 'VVVVVVVVVVVVVVVVV',
   101         status: 'VALID',
   102         args: {}
   103       },
   104       exec: {
   105         output: [ /successfully/ ]
   106       },
   107     },
   109     {
   110       setup: 'appcache validate ' + TEST_URI,
   111       check: {
   112         input:  'appcache validate ' + TEST_URI,
   113               // appcache validate http://sub1.test2.example.com/browser/browser/devtools/commandline/test/browser_cmd_appcache_valid_index.html
   114         markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV',
   115         status: 'VALID',
   116         args: {
   117           uri: {
   118             value: TEST_URI
   119           },
   120         }
   121       },
   122       exec: {
   123         output: [ /successfully/ ]
   124       },
   125     },
   127     {
   128       setup: 'appcache clear',
   129       check: {
   130         input:  'appcache clear',
   131         markup: 'VVVVVVVVVVVVVV',
   132         status: 'VALID',
   133         args: {},
   134       },
   135       exec: {
   136         output: [ /successfully/ ]
   137       },
   138     },
   140     {
   141       setup: 'appcache list',
   142       check: {
   143         input:  'appcache list',
   144         markup: 'VVVVVVVVVVVVV',
   145         status: 'VALID',
   146         args: {},
   147       },
   148       exec: {
   149         output: [ /no results/ ]
   150       },
   151       post: function(output, text) {
   152         ok(!text.contains("index"), "index is not contained in output");
   153         ok(!text.contains("page1"), "page1 is not contained in output");
   154         ok(!text.contains("page2"), "page1 is not contained in output");
   155         ok(!text.contains("page3"), "page1 is not contained in output");
   156       }
   157     },
   159     {
   160       setup: 'appcache viewentry --key ' + TEST_URI,
   161       check: {
   162         input:  'appcache viewentry --key ' + TEST_URI,
   163               // appcache viewentry --key http://sub1.test2.example.com/browser/browser/devtools/commandline/test/browser_cmd_appcache_valid_index.html
   164         markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV',
   165         status: 'VALID',
   166         args: {}
   167       },
   168     },
   169   ]);
   171   yield helpers.closeToolbar(options);
   172   yield helpers.closeTab(options);
   173 }

mercurial