Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=830258 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <meta charset="utf-8"> |
michael@0 | 8 | <title>Test for Bug 830258</title> |
michael@0 | 9 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 11 | <script type="application/javascript;version=1.7"> |
michael@0 | 12 | |
michael@0 | 13 | /** Test for Bug 830258 **/ |
michael@0 | 14 | |
michael@0 | 15 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 16 | |
michael@0 | 17 | var url1 = 'http://test1.example.com/tests/dom/apps/tests/file_app.sjs?apptype=hosted&getmanifest=true'; |
michael@0 | 18 | var url2 = 'http://test2.example.com/tests/dom/apps/tests/file_app.sjs?apptype=hosted&getmanifest=true'; |
michael@0 | 19 | |
michael@0 | 20 | var gGenerator = runTest(); |
michael@0 | 21 | |
michael@0 | 22 | function go() { |
michael@0 | 23 | SpecialPowers.pushPermissions( |
michael@0 | 24 | [{ "type": "webapps-manage", "allow": 1, "context": document }], |
michael@0 | 25 | function() { gGenerator.next() }); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | function continueTest() { |
michael@0 | 29 | try { |
michael@0 | 30 | gGenerator.next(); |
michael@0 | 31 | } catch (e if e instanceof StopIteration) { |
michael@0 | 32 | SimpleTest.finish(); |
michael@0 | 33 | } |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | function mozAppsError() { |
michael@0 | 37 | ok(false, "mozApps error: " + this.error.name); |
michael@0 | 38 | SimpleTest.finish(); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | function runTest() { |
michael@0 | 42 | // Set up. |
michael@0 | 43 | SpecialPowers.setAllAppsLaunchable(true); |
michael@0 | 44 | SpecialPowers.autoConfirmAppInstall(continueTest); |
michael@0 | 45 | yield undefined; |
michael@0 | 46 | |
michael@0 | 47 | let request = navigator.mozApps.install(url1); |
michael@0 | 48 | request.onerror = mozAppsError; |
michael@0 | 49 | request.onsuccess = continueTest; |
michael@0 | 50 | yield undefined; |
michael@0 | 51 | let app1 = request.result; |
michael@0 | 52 | ok(app1, "App1 is non-null"); |
michael@0 | 53 | |
michael@0 | 54 | request = navigator.mozApps.install(url2); |
michael@0 | 55 | request.onerror = mozAppsError; |
michael@0 | 56 | request.onsuccess = continueTest; |
michael@0 | 57 | yield undefined; |
michael@0 | 58 | let app2 = request.result; |
michael@0 | 59 | ok(app2, "App2 is non-null"); |
michael@0 | 60 | |
michael@0 | 61 | request = navigator.mozApps.mgmt.uninstall(app1); |
michael@0 | 62 | request.onsuccess = function() { |
michael@0 | 63 | ok(true, "Succeed to uninstall the app1 as expected"); |
michael@0 | 64 | continueTest(); |
michael@0 | 65 | }; |
michael@0 | 66 | request.onerror = function() { |
michael@0 | 67 | ok(false, "Fail to uninstall the app1"); |
michael@0 | 68 | continueTest(); |
michael@0 | 69 | }; |
michael@0 | 70 | yield undefined; |
michael@0 | 71 | |
michael@0 | 72 | request = navigator.mozApps.mgmt.uninstall(app1); |
michael@0 | 73 | request.onsuccess = function() { |
michael@0 | 74 | ok(false, "Shouldn't be able to uninstall the app1 again"); |
michael@0 | 75 | continueTest(); |
michael@0 | 76 | }; |
michael@0 | 77 | request.onerror = function() { |
michael@0 | 78 | is(this.error.name, "NOT_INSTALLED", "Error name should be 'NOT_INSTALLED'"); |
michael@0 | 79 | continueTest(); |
michael@0 | 80 | }; |
michael@0 | 81 | yield undefined; |
michael@0 | 82 | |
michael@0 | 83 | request = navigator.mozApps.mgmt.uninstall(app2); |
michael@0 | 84 | request.onsuccess = function() { |
michael@0 | 85 | ok(true, "Succeed to uninstall the app2 as expected"); |
michael@0 | 86 | continueTest(); |
michael@0 | 87 | }; |
michael@0 | 88 | request.onerror = function() { |
michael@0 | 89 | ok(false, "Fail to uninstall the app2"); |
michael@0 | 90 | continueTest(); |
michael@0 | 91 | }; |
michael@0 | 92 | yield undefined; |
michael@0 | 93 | } |
michael@0 | 94 | </script> |
michael@0 | 95 | </head> |
michael@0 | 96 | <body onload="go()"> |
michael@0 | 97 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=830258">Mozilla Bug 830258</a> |
michael@0 | 98 | <p id="display"></p> |
michael@0 | 99 | <div id="content" style="display: none"> |
michael@0 | 100 | |
michael@0 | 101 | </div> |
michael@0 | 102 | <pre id="test"> |
michael@0 | 103 | </pre> |
michael@0 | 104 | </body> |
michael@0 | 105 | </html> |