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

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 Test that setVisible() changes a process's priority.
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 8 <script type="application/javascript" src="../browserElementTestHelpers.js"></script>
michael@0 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 10 </head>
michael@0 11 <body>
michael@0 12
michael@0 13 <script type="application/javascript;version=1.7">
michael@0 14 "use strict";
michael@0 15
michael@0 16 SimpleTest.waitForExplicitFinish();
michael@0 17 browserElementTestHelpers.setEnabledPref(true);
michael@0 18 browserElementTestHelpers.addPermission();
michael@0 19 browserElementTestHelpers.enableProcessPriorityManager();
michael@0 20
michael@0 21 function runTest() {
michael@0 22 var iframe = document.createElement('iframe');
michael@0 23 iframe.setAttribute('mozbrowser', true);
michael@0 24 iframe.src = browserElementTestHelpers.emptyPage1;
michael@0 25
michael@0 26 var childID = null;
michael@0 27 expectOnlyOneProcessCreated().then(function(chid) {
michael@0 28 childID = chid;
michael@0 29 return Promise.all(
michael@0 30 [expectPriorityChange(childID, 'FOREGROUND'),
michael@0 31 expectMozbrowserEvent(iframe, 'loadend')]);
michael@0 32 }).then(function() {
michael@0 33 // Mark the frame as not visible. This should cause its priority to drop
michael@0 34 // to BACKGROUND.
michael@0 35 var p = expectPriorityChange(childID, 'BACKGROUND');
michael@0 36 iframe.setVisible(false);
michael@0 37 return p;
michael@0 38 }).then(function() {
michael@0 39 // Mark the frame as visible again. This should cause its priority change
michael@0 40 // back to FOREGROUND.
michael@0 41 var p = expectPriorityChange(childID, 'FOREGROUND');
michael@0 42 iframe.setVisible(true);
michael@0 43 return p;
michael@0 44 }).then(SimpleTest.finish);
michael@0 45
michael@0 46 document.body.appendChild(iframe);
michael@0 47 }
michael@0 48
michael@0 49 addEventListener('testready', runTest);
michael@0 50 </script>
michael@0 51 </body>
michael@0 52 </html>

mercurial