|
1 SimpleTest.waitForExplicitFinish(); |
|
2 SpecialPowers.setAllAppsLaunchable(true); |
|
3 |
|
4 var fileTestOnCurrentOrigin = 'http://example.org/tests/dom/tests/mochitest/webapps/file_bug_779982.html'; |
|
5 |
|
6 var gData = [ |
|
7 // APP 1 |
|
8 { |
|
9 app: 'http://example.org/manifest.webapp', |
|
10 action: 'getSelf', |
|
11 isnull: false, |
|
12 src: fileTestOnCurrentOrigin, |
|
13 message: 'getSelf() for app should return something' |
|
14 }, |
|
15 { |
|
16 app: 'http://example.org/manifest.webapp', |
|
17 action: 'checkInstalled', |
|
18 isnull: false, |
|
19 src: fileTestOnCurrentOrigin, |
|
20 message: 'checkInstalled() for app should return true' |
|
21 }, |
|
22 { |
|
23 app: 'http://example.org/manifest.webapp', |
|
24 action: 'checkInstalledWrong', |
|
25 isnull: true, |
|
26 src: fileTestOnCurrentOrigin, |
|
27 message: 'checkInstalled() for browser should return true' |
|
28 }, |
|
29 // Browser |
|
30 { |
|
31 browser: true, |
|
32 action: 'getSelf', |
|
33 isnull: true, |
|
34 src: fileTestOnCurrentOrigin, |
|
35 message: 'getSelf() for browser should return null' |
|
36 }, |
|
37 { |
|
38 browser: true, |
|
39 action: 'checkInstalled', |
|
40 isnull: false, |
|
41 src: fileTestOnCurrentOrigin, |
|
42 message: 'checkInstalled() for browser should return true' |
|
43 }, |
|
44 { |
|
45 browser: true, |
|
46 action: 'checkInstalledWrong', |
|
47 isnull: true, |
|
48 src: fileTestOnCurrentOrigin, |
|
49 message: 'checkInstalled() for browser should return true' |
|
50 }, |
|
51 ]; |
|
52 |
|
53 function runTest() { |
|
54 for (var i in gData) { |
|
55 var iframe = document.createElement('iframe'); |
|
56 var data = gData[i]; |
|
57 |
|
58 if (data.app) { |
|
59 iframe.setAttribute('mozbrowser', ''); |
|
60 iframe.setAttribute('mozapp', data.app); |
|
61 } else if (data.browser) { |
|
62 iframe.setAttribute('mozbrowser', ''); |
|
63 } |
|
64 |
|
65 if (data.app || data.browser) { |
|
66 iframe.addEventListener('mozbrowsershowmodalprompt', function(e) { |
|
67 is(e.detail.message, 'success', data.message); |
|
68 |
|
69 i++; |
|
70 if (i >= gData.length) { |
|
71 SimpleTest.finish(); |
|
72 } else { |
|
73 gTestRunner.next(); |
|
74 } |
|
75 }); |
|
76 } |
|
77 |
|
78 iframe.src = data.src + '?' + data.action + '&' + data.isnull; |
|
79 document.getElementById('content').appendChild(iframe); |
|
80 |
|
81 yield undefined; |
|
82 } |
|
83 } |
|
84 |
|
85 var gTestRunner = runTest(); |
|
86 |
|
87 SpecialPowers.pushPrefEnv({"set": [["dom.mozBrowserFramesEnabled", true]]}, function() { |
|
88 SpecialPowers.pushPermissions([{'type': 'browser', 'allow': true, 'context': document}, {'type': 'embed-apps', 'allow': true, 'context': document}], function() {gTestRunner.next() }); |
|
89 }); |