test_not_intercept_plugin.html (2090B)
1 <!-- 2 Any copyright is dedicated to the Public Domain. 3 http://creativecommons.org/publicdomain/zero/1.0/ 4 --> 5 <!DOCTYPE HTML> 6 <html> 7 <head> 8 <title>Bug 1187766 - Test loading plugins scenarios with fetch interception.</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 11 </head> 12 <body> 13 <p id="display"></p> 14 <div id="content" style="display: none"></div> 15 <pre id="test"></pre> 16 <script src="utils.js"></script> 17 <script class="testbody" type="text/javascript"> 18 SimpleTest.requestCompleteLog(); 19 20 var registration; 21 function simpleRegister() { 22 var p = navigator.serviceWorker.register("./fetch/plugin/worker.js", { scope: "./fetch/plugin/" }); 23 return p.then(function(swr) { 24 registration = swr; 25 return waitForState(swr.installing, 'activated'); 26 }); 27 } 28 29 function unregister() { 30 return registration.unregister().then(function(success) { 31 ok(success, "Service worker should be unregistered successfully"); 32 }, function(e) { 33 dump("SW unregistration error: " + e + "\n"); 34 }); 35 } 36 37 function testPlugins() { 38 var p = new Promise(function(resolve, reject) { 39 window.onmessage = function(e) { 40 if (e.data.status == "ok") { 41 ok(e.data.result, e.data.message); 42 } else if (e.data.status == "done") { 43 window.onmessage = null; 44 w.close(); 45 resolve(); 46 } 47 } 48 }); 49 50 var w = window.open("fetch/plugin/plugins.html"); 51 return p; 52 } 53 54 function runTest() { 55 simpleRegister() 56 .then(testPlugins) 57 .then(unregister) 58 .then(function() { 59 SimpleTest.finish(); 60 }).catch(function(e) { 61 ok(false, "Some test failed with error " + e); 62 SimpleTest.finish(); 63 }); 64 } 65 66 SimpleTest.waitForExplicitFinish(); 67 SpecialPowers.pushPrefEnv({"set": [ 68 ["dom.serviceWorkers.exemptFromPerDomainMax", true], 69 ["dom.serviceWorkers.enabled", true], 70 ["dom.serviceWorkers.testing.enabled", true], 71 ]}, runTest); 72 </script> 73 </pre> 74 </body> 75 </html>