зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1847584 - Consistently throttle visibility:hidden frames. r=smaug
Before this patch OOP frames were being throttled but in-process ones weren't. Depends on D185643 Differential Revision: https://phabricator.services.mozilla.com/D185794
This commit is contained in:
Родитель
638ebb3abe
Коммит
b23a02e026
|
@ -7084,6 +7084,12 @@ bool Document::ShouldThrottleFrameRequests() const {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (mPresShell->IsUnderHiddenEmbedderElement()) {
|
||||
// For display: none and visibility: hidden we always throttle, for
|
||||
// consistency with OOP iframes.
|
||||
return true;
|
||||
}
|
||||
|
||||
Element* el = GetEmbedderElement();
|
||||
if (!el) {
|
||||
// If we're not in-process, our refresh driver is throttled separately (via
|
||||
|
@ -7101,7 +7107,7 @@ bool Document::ShouldThrottleFrameRequests() const {
|
|||
// acceptable / unlikely to be human-perceivable, though we could improve on
|
||||
// it if needed by adding an intersection margin or something of that sort.
|
||||
const IntersectionInput input = DOMIntersectionObserver::ComputeInput(
|
||||
*el->OwnerDoc(), /* aRoot = */ nullptr, /* aMargin = */ nullptr);
|
||||
*el->OwnerDoc(), /* aRoot = */ nullptr, /* aRootMargin = */ nullptr);
|
||||
const IntersectionOutput output =
|
||||
DOMIntersectionObserver::Intersect(input, *el);
|
||||
return !output.Intersects();
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
<iframe id="display-none-http" style="display: none" src="https://example.com/tests/dom/base/test/file_bug1639328.html"></iframe>
|
||||
<iframe id="display-none-https" style="display: none" src="https://example.com/tests/dom/base/test/file_bug1639328.html"></iframe>
|
||||
<iframe id="display-none-same-origin" style="display: none" src="file_bug1639328.html"></iframe>
|
||||
<iframe id="vis-hidden-http" style="visibility: hidden" src="https://example.com/tests/dom/base/test/file_bug1639328.html"></iframe>
|
||||
<iframe id="vis-hidden-https" style="visibility: hidden" src="https://example.com/tests/dom/base/test/file_bug1639328.html"></iframe>
|
||||
<iframe id="vis-hidden-same-origin" style="visibility: hidden" src="file_bug1639328.html"></iframe>
|
||||
<script>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
|
@ -55,19 +58,30 @@ async function checkFrame(frame, shouldThrottle) {
|
|||
is(message.throttledFrameRequests, shouldThrottle, frame.id);
|
||||
}
|
||||
|
||||
function shouldThrottle(frame) {
|
||||
return frame.style.display == "none" || frame.style.visibility == "hidden";
|
||||
}
|
||||
|
||||
onload = async function() {
|
||||
await SimpleTest.promiseFocus(window);
|
||||
await ticks(2);
|
||||
is(SpecialPowers.DOMWindowUtils.effectivelyThrottlesFrameRequests, false, "Should not be throttling main page");
|
||||
for (let frame of document.querySelectorAll("iframe")) {
|
||||
let shouldThrottle = frame.style.display == "none";
|
||||
await checkFrame(frame, shouldThrottle);
|
||||
info("Switching display of " + frame.id);
|
||||
frame.style.display = shouldThrottle ? "" : "none";
|
||||
await checkFrame(frame, !shouldThrottle);
|
||||
info("And switching display back for " + frame.id);
|
||||
frame.style.display = shouldThrottle ? "none" : "";
|
||||
await checkFrame(frame, shouldThrottle);
|
||||
let originalShouldThrottle = shouldThrottle(frame);
|
||||
await checkFrame(frame, originalShouldThrottle);
|
||||
for (let prop of ["display", "visibility"]) {
|
||||
info(`Switching ${prop} of ${frame.id}`);
|
||||
let orig = frame.style[prop];
|
||||
let throttledValue = prop == "display" ? "none" : "hidden";
|
||||
frame.style[prop] = orig == throttledValue ? "" : throttledValue;
|
||||
if (orig != throttledValue) {
|
||||
is(shouldThrottle(frame), true, `Should throttle for ${prop}: ${throttledValue}`);
|
||||
}
|
||||
await checkFrame(frame, shouldThrottle(frame));
|
||||
info(`Switching ${prop} back for ${frame.id}`);
|
||||
frame.style[prop] = orig;
|
||||
await checkFrame(frame, originalShouldThrottle);
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
</style>
|
||||
<iframe class="visible"></iframe>
|
||||
<iframe class="display-none" data-throttled-expected></iframe>
|
||||
<iframe class="vis-hidden"></iframe>
|
||||
<iframe class="vis-hidden" data-throttled-expected></iframe>
|
||||
<iframe class="transparent"></iframe>
|
||||
<iframe class="zero-size"></iframe>
|
||||
<div class="scroller">
|
||||
|
|
Загрузка…
Ссылка в новой задаче