|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 Test that a regular (not mozapptype=critical) frame that's expecting a system |
|
5 message gets priority BACKGROUND_PERCEIVABLE when it's in the background. |
|
6 --> |
|
7 <head> |
|
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <script type="application/javascript" src="../browserElementTestHelpers.js"></script> |
|
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
11 </head> |
|
12 <body> |
|
13 |
|
14 <script type="application/javascript;version=1.7"> |
|
15 "use strict"; |
|
16 |
|
17 SimpleTest.waitForExplicitFinish(); |
|
18 browserElementTestHelpers.setEnabledPref(true); |
|
19 browserElementTestHelpers.addPermission(); |
|
20 browserElementTestHelpers.enableProcessPriorityManager(); |
|
21 SpecialPowers.addPermission("embed-apps", true, document); |
|
22 |
|
23 // Give our origin permission to open browsers, and remove it when the test is complete. |
|
24 var principal = SpecialPowers.wrap(document).nodePrincipal; |
|
25 SpecialPowers.addPermission("browser", true, { url: SpecialPowers.wrap(principal.URI).spec, |
|
26 appId: principal.appId, |
|
27 isInBrowserElement: true }); |
|
28 |
|
29 addEventListener('unload', function() { |
|
30 var principal = SpecialPowers.wrap(document).nodePrincipal; |
|
31 SpecialPowers.removePermission("browser", { url: SpecialPowers.wrap(principal.URI).spec, |
|
32 appId: principal.appId, |
|
33 isInBrowserElement: true }); |
|
34 }); |
|
35 |
|
36 function runTest() { |
|
37 var iframe = document.createElement('iframe'); |
|
38 iframe.setAttribute('mozbrowser', true); |
|
39 iframe.setAttribute('expecting-system-message', true); |
|
40 iframe.setAttribute('mozapp', 'http://example.org/manifest.webapp'); |
|
41 |
|
42 iframe.src = browserElementTestHelpers.emptyPage1; |
|
43 |
|
44 var childID = null; |
|
45 expectOnlyOneProcessCreated().then(function(chid) { |
|
46 childID = chid; |
|
47 return Promise.all( |
|
48 [expectPriorityChange(childID, 'FOREGROUND'), |
|
49 expectMozbrowserEvent(iframe, 'loadend')]); |
|
50 }).then(function() { |
|
51 var p = expectPriorityChange(childID, 'BACKGROUND_PERCEIVABLE'); |
|
52 iframe.setVisible(false); |
|
53 return p; |
|
54 }).then(SimpleTest.finish); |
|
55 |
|
56 document.body.appendChild(iframe); |
|
57 } |
|
58 |
|
59 addEventListener('testready', function() { |
|
60 // We don't want this wake lock to time out during the test; if it did, then |
|
61 // we might see BACKGROUND priority instead of BACKGROUND_PERCEIVABLE. So |
|
62 // set the timeout to a large value. |
|
63 SpecialPowers.pushPrefEnv( |
|
64 {set: [["dom.ipc.systemMessageCPULockTimeoutSec", 99999]]}, |
|
65 runTest); |
|
66 }); |
|
67 |
|
68 </script> |
|
69 </body> |
|
70 </html> |