1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/commandline/test/browser_cmd_appcache_valid.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,173 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Tests that the appcache commands works as they should 1.8 + 1.9 +const TEST_URI = "http://sub1.test2.example.com/browser/browser/devtools/" + 1.10 + "commandline/test/browser_cmd_appcache_valid_index.html"; 1.11 + 1.12 +function test() { 1.13 + return Task.spawn(spawnTest).then(finish, helpers.handleError); 1.14 +} 1.15 + 1.16 +function spawnTest() { 1.17 + let options = yield helpers.openTab(TEST_URI); 1.18 + yield helpers.openToolbar(options); 1.19 + 1.20 + info("adding cache listener."); 1.21 + 1.22 + // Wait for site to be cached. 1.23 + yield helpers.listenOnce(gBrowser.contentWindow.applicationCache, 'cached'); 1.24 + 1.25 + // Pages containing an appcache the notification bar gives options to allow 1.26 + // or deny permission for the app to save data offline. Let's click Allow. 1.27 + let notificationID = "offline-app-requested-sub1.test2.example.com"; 1.28 + let notification = PopupNotifications.getNotification(notificationID, gBrowser.selectedBrowser); 1.29 + 1.30 + if (notification) { 1.31 + info("Authorizing offline storage."); 1.32 + notification.mainAction.callback(); 1.33 + } else { 1.34 + info("No notification box is available."); 1.35 + } 1.36 + 1.37 + info("Site now cached, running tests."); 1.38 + yield helpers.audit(options, [ 1.39 + { 1.40 + setup: 'appcache', 1.41 + check: { 1.42 + input: 'appcache', 1.43 + markup: 'IIIIIIII', 1.44 + status: 'ERROR', 1.45 + args: {} 1.46 + }, 1.47 + }, 1.48 + 1.49 + { 1.50 + setup: function() { 1.51 + Services.prefs.setBoolPref("browser.cache.disk.enable", false); 1.52 + return helpers.setInput(options, 'appcache list', 13); 1.53 + }, 1.54 + check: { 1.55 + input: 'appcache list', 1.56 + markup: 'VVVVVVVVVVVVV', 1.57 + status: 'VALID', 1.58 + args: {}, 1.59 + }, 1.60 + exec: { 1.61 + output: [ /cache is disabled/ ] 1.62 + }, 1.63 + post: function(output) { 1.64 + Services.prefs.setBoolPref("browser.cache.disk.enable", true); 1.65 + } 1.66 + }, 1.67 + 1.68 + { 1.69 + setup: 'appcache list', 1.70 + check: { 1.71 + input: 'appcache list', 1.72 + markup: 'VVVVVVVVVVVVV', 1.73 + status: 'VALID', 1.74 + args: {}, 1.75 + }, 1.76 + exec: { 1.77 + output: [ /index/, /page1/, /page2/, /page3/ ] 1.78 + }, 1.79 + }, 1.80 + 1.81 + { 1.82 + setup: 'appcache list page', 1.83 + check: { 1.84 + input: 'appcache list page', 1.85 + markup: 'VVVVVVVVVVVVVVVVVV', 1.86 + status: 'VALID', 1.87 + args: { 1.88 + search: { value: 'page' }, 1.89 + } 1.90 + }, 1.91 + exec: { 1.92 + output: [ /page1/, /page2/, /page3/ ] 1.93 + }, 1.94 + post: function(output, text) { 1.95 + ok(!text.contains("index"), "index is not contained in output"); 1.96 + } 1.97 + }, 1.98 + 1.99 + { 1.100 + setup: 'appcache validate', 1.101 + check: { 1.102 + input: 'appcache validate', 1.103 + markup: 'VVVVVVVVVVVVVVVVV', 1.104 + status: 'VALID', 1.105 + args: {} 1.106 + }, 1.107 + exec: { 1.108 + output: [ /successfully/ ] 1.109 + }, 1.110 + }, 1.111 + 1.112 + { 1.113 + setup: 'appcache validate ' + TEST_URI, 1.114 + check: { 1.115 + input: 'appcache validate ' + TEST_URI, 1.116 + // appcache validate http://sub1.test2.example.com/browser/browser/devtools/commandline/test/browser_cmd_appcache_valid_index.html 1.117 + markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV', 1.118 + status: 'VALID', 1.119 + args: { 1.120 + uri: { 1.121 + value: TEST_URI 1.122 + }, 1.123 + } 1.124 + }, 1.125 + exec: { 1.126 + output: [ /successfully/ ] 1.127 + }, 1.128 + }, 1.129 + 1.130 + { 1.131 + setup: 'appcache clear', 1.132 + check: { 1.133 + input: 'appcache clear', 1.134 + markup: 'VVVVVVVVVVVVVV', 1.135 + status: 'VALID', 1.136 + args: {}, 1.137 + }, 1.138 + exec: { 1.139 + output: [ /successfully/ ] 1.140 + }, 1.141 + }, 1.142 + 1.143 + { 1.144 + setup: 'appcache list', 1.145 + check: { 1.146 + input: 'appcache list', 1.147 + markup: 'VVVVVVVVVVVVV', 1.148 + status: 'VALID', 1.149 + args: {}, 1.150 + }, 1.151 + exec: { 1.152 + output: [ /no results/ ] 1.153 + }, 1.154 + post: function(output, text) { 1.155 + ok(!text.contains("index"), "index is not contained in output"); 1.156 + ok(!text.contains("page1"), "page1 is not contained in output"); 1.157 + ok(!text.contains("page2"), "page1 is not contained in output"); 1.158 + ok(!text.contains("page3"), "page1 is not contained in output"); 1.159 + } 1.160 + }, 1.161 + 1.162 + { 1.163 + setup: 'appcache viewentry --key ' + TEST_URI, 1.164 + check: { 1.165 + input: 'appcache viewentry --key ' + TEST_URI, 1.166 + // appcache viewentry --key http://sub1.test2.example.com/browser/browser/devtools/commandline/test/browser_cmd_appcache_valid_index.html 1.167 + markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV', 1.168 + status: 'VALID', 1.169 + args: {} 1.170 + }, 1.171 + }, 1.172 + ]); 1.173 + 1.174 + yield helpers.closeToolbar(options); 1.175 + yield helpers.closeTab(options); 1.176 +}