dom/browser-element/mochitest/priority/test_ExpectingSystemMessage2.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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>
    14 <script type="application/javascript;version=1.7">
    15 "use strict";
    17 SimpleTest.waitForExplicitFinish();
    18 browserElementTestHelpers.setEnabledPref(true);
    19 browserElementTestHelpers.addPermission();
    20 browserElementTestHelpers.enableProcessPriorityManager();
    21 SpecialPowers.addPermission("embed-apps", true, document);
    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 });
    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 });
    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');
    42   iframe.src = browserElementTestHelpers.emptyPage1;
    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);
    56   document.body.appendChild(iframe);
    57 }
    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 });
    68 </script>
    69 </body>
    70 </html>

mercurial