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