tenfourfox/dom/browser-element/mochitest/priority/test_MultipleFrames.html
Cameron Kaiser c9b2922b70 hello FPR
2017-04-19 00:56:45 -07:00

60 lines
1.8 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
Test that when we remove one of a process's frames from the DOM, the process's
priority is recomputed.
-->
<head>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="../browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript;version=1.7">
"use strict";
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addPermission();
browserElementTestHelpers.enableProcessPriorityManager();
function runTest() {
var iframe = document.createElement('iframe');
iframe.setAttribute('mozbrowser', true);
iframe.src = 'file_MultipleFrames.html';
var childID = null;
var iframe2;
Promise.all([
expectProcessCreated('FOREGROUND').then(function(chid) {
childID = chid;
}),
new Promise(function(resolve, reject) {
iframe.addEventListener('mozbrowseropenwindow', function(e) {
iframe2 = e.detail.frameElement;
var p = expectMozbrowserEvent(iframe2, 'loadend');
document.body.appendChild(iframe2);
resolve(p);
});
})
]).then(function() {
// At this point, the child process has been set to FOREGROUND, and the popup
// opened by file_MultipleFrames has finished loading.
//
// Now setVisible(false) the popup frame and remove the popup frame from the
// DOM. This should cause the process to take on BACKGROUND priority.
var p = expectPriorityChange(childID, 'BACKGROUND');
iframe.setVisible(false);
document.body.removeChild(iframe2);
return p;
}).then(SimpleTest.finish);
document.body.appendChild(iframe);
}
addEventListener('testready', runTest);
</script>
</body>
</html>