michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Tests that the appcache commands works as they should michael@0: michael@0: const TEST_URI = "http://sub1.test2.example.com/browser/browser/devtools/" + michael@0: "commandline/test/browser_cmd_appcache_valid_index.html"; michael@0: michael@0: function test() { michael@0: return Task.spawn(spawnTest).then(finish, helpers.handleError); michael@0: } michael@0: michael@0: function spawnTest() { michael@0: let options = yield helpers.openTab(TEST_URI); michael@0: yield helpers.openToolbar(options); michael@0: michael@0: info("adding cache listener."); michael@0: michael@0: // Wait for site to be cached. michael@0: yield helpers.listenOnce(gBrowser.contentWindow.applicationCache, 'cached'); michael@0: michael@0: // Pages containing an appcache the notification bar gives options to allow michael@0: // or deny permission for the app to save data offline. Let's click Allow. michael@0: let notificationID = "offline-app-requested-sub1.test2.example.com"; michael@0: let notification = PopupNotifications.getNotification(notificationID, gBrowser.selectedBrowser); michael@0: michael@0: if (notification) { michael@0: info("Authorizing offline storage."); michael@0: notification.mainAction.callback(); michael@0: } else { michael@0: info("No notification box is available."); michael@0: } michael@0: michael@0: info("Site now cached, running tests."); michael@0: yield helpers.audit(options, [ michael@0: { michael@0: setup: 'appcache', michael@0: check: { michael@0: input: 'appcache', michael@0: markup: 'IIIIIIII', michael@0: status: 'ERROR', michael@0: args: {} michael@0: }, michael@0: }, michael@0: michael@0: { michael@0: setup: function() { michael@0: Services.prefs.setBoolPref("browser.cache.disk.enable", false); michael@0: return helpers.setInput(options, 'appcache list', 13); michael@0: }, michael@0: check: { michael@0: input: 'appcache list', michael@0: markup: 'VVVVVVVVVVVVV', michael@0: status: 'VALID', michael@0: args: {}, michael@0: }, michael@0: exec: { michael@0: output: [ /cache is disabled/ ] michael@0: }, michael@0: post: function(output) { michael@0: Services.prefs.setBoolPref("browser.cache.disk.enable", true); michael@0: } michael@0: }, michael@0: michael@0: { michael@0: setup: 'appcache list', michael@0: check: { michael@0: input: 'appcache list', michael@0: markup: 'VVVVVVVVVVVVV', michael@0: status: 'VALID', michael@0: args: {}, michael@0: }, michael@0: exec: { michael@0: output: [ /index/, /page1/, /page2/, /page3/ ] michael@0: }, michael@0: }, michael@0: michael@0: { michael@0: setup: 'appcache list page', michael@0: check: { michael@0: input: 'appcache list page', michael@0: markup: 'VVVVVVVVVVVVVVVVVV', michael@0: status: 'VALID', michael@0: args: { michael@0: search: { value: 'page' }, michael@0: } michael@0: }, michael@0: exec: { michael@0: output: [ /page1/, /page2/, /page3/ ] michael@0: }, michael@0: post: function(output, text) { michael@0: ok(!text.contains("index"), "index is not contained in output"); michael@0: } michael@0: }, michael@0: michael@0: { michael@0: setup: 'appcache validate', michael@0: check: { michael@0: input: 'appcache validate', michael@0: markup: 'VVVVVVVVVVVVVVVVV', michael@0: status: 'VALID', michael@0: args: {} michael@0: }, michael@0: exec: { michael@0: output: [ /successfully/ ] michael@0: }, michael@0: }, michael@0: michael@0: { michael@0: setup: 'appcache validate ' + TEST_URI, michael@0: check: { michael@0: input: 'appcache validate ' + TEST_URI, michael@0: // appcache validate http://sub1.test2.example.com/browser/browser/devtools/commandline/test/browser_cmd_appcache_valid_index.html michael@0: markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV', michael@0: status: 'VALID', michael@0: args: { michael@0: uri: { michael@0: value: TEST_URI michael@0: }, michael@0: } michael@0: }, michael@0: exec: { michael@0: output: [ /successfully/ ] michael@0: }, michael@0: }, michael@0: michael@0: { michael@0: setup: 'appcache clear', michael@0: check: { michael@0: input: 'appcache clear', michael@0: markup: 'VVVVVVVVVVVVVV', michael@0: status: 'VALID', michael@0: args: {}, michael@0: }, michael@0: exec: { michael@0: output: [ /successfully/ ] michael@0: }, michael@0: }, michael@0: michael@0: { michael@0: setup: 'appcache list', michael@0: check: { michael@0: input: 'appcache list', michael@0: markup: 'VVVVVVVVVVVVV', michael@0: status: 'VALID', michael@0: args: {}, michael@0: }, michael@0: exec: { michael@0: output: [ /no results/ ] michael@0: }, michael@0: post: function(output, text) { michael@0: ok(!text.contains("index"), "index is not contained in output"); michael@0: ok(!text.contains("page1"), "page1 is not contained in output"); michael@0: ok(!text.contains("page2"), "page1 is not contained in output"); michael@0: ok(!text.contains("page3"), "page1 is not contained in output"); michael@0: } michael@0: }, michael@0: michael@0: { michael@0: setup: 'appcache viewentry --key ' + TEST_URI, michael@0: check: { michael@0: input: 'appcache viewentry --key ' + TEST_URI, michael@0: // appcache viewentry --key http://sub1.test2.example.com/browser/browser/devtools/commandline/test/browser_cmd_appcache_valid_index.html michael@0: markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV', michael@0: status: 'VALID', michael@0: args: {} michael@0: }, michael@0: }, michael@0: ]); michael@0: michael@0: yield helpers.closeToolbar(options); michael@0: yield helpers.closeTab(options); michael@0: }