test_migration.js (2217B)
1 /** 2 * Any copyright is dedicated to the Public Domain. 3 * http://creativecommons.org/publicdomain/zero/1.0/ 4 * 5 * All images in schema_15_profile.zip are from https://github.com/mdn/sw-test/ 6 * and are CC licensed by https://www.flickr.com/photos/legofenris/. 7 */ 8 9 add_task(async function testSteps() { 10 create_test_profile("schema_15_profile.zip"); 11 12 const cache = await caches.open("xpcshell-test"); 13 ok(cache, "cache exists"); 14 15 const requestList = await cache.keys(); 16 17 ok(requestList.length, "should have at least one request in cache"); 18 for (const request of requestList) { 19 ok(request, "each request in list should be non-null"); 20 Assert.strictEqual( 21 request.redirect, 22 "follow", 23 'request.redirect should default to "follow"' 24 ); 25 Assert.strictEqual( 26 request.cache, 27 "default", 28 'request.cache should have been updated to "default"' + request.cache 29 ); 30 Assert.strictEqual( 31 request.mode, 32 "navigate", 33 'request.mode should have been updated to "navigate"' 34 ); 35 Assert.strictEqual( 36 request.referrerPolicy, 37 "no-referrer-when-downgrade", 38 'request.referrerPolicy should have been updated to "no-referrer-when-downgrade"' 39 ); 40 } 41 42 const responseList = await Promise.all( 43 requestList.map(function (request) { 44 return cache.match(request); 45 }) 46 ); 47 48 ok(responseList.length, "should have at least one response in cache"); 49 for (const response of responseList) { 50 ok(response, "each response should be non-null"); 51 // reponse.url is a empty string in current test file. It should test for 52 // not being a empty string once thet test file is updated. 53 Assert.strictEqual( 54 typeof response.url, 55 "string", 56 "each response.url should be a string" 57 ); 58 // reponse.redirected may be changed once test file is updated. It should 59 // be false since current reponse.url is a empty string. 60 Assert.strictEqual( 61 response.redirected, 62 false, 63 "each response.redirected should be false" 64 ); 65 Assert.equal( 66 response.headers.get("Content-Type"), 67 "text/plain;charset=UTF-8", 68 "the response should have the correct header" 69 ); 70 } 71 });