зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1882670 - Cancel the loading=lazy iframe when it's load via a different way r=emilio,webdriver-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D218143
This commit is contained in:
Родитель
d524f0f5e5
Коммит
93b336b8f9
|
@ -10049,6 +10049,14 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
|
|||
contentPolicyType == nsIContentPolicy::TYPE_INTERNAL_FRAME,
|
||||
"DoURILoad thinks this is a frame and InternalLoad does not");
|
||||
|
||||
if (auto* iframe = HTMLIFrameElement::FromNodeOrNull(
|
||||
mBrowsingContext->GetEmbedderElement())) {
|
||||
// Per spec, reload doesn't cacel lazy loading iframes.
|
||||
if (!(aLoadState->LoadType() & LOAD_RELOAD_NORMAL)) {
|
||||
iframe->CancelLazyLoading(true /* aClearLazyLoadState */);
|
||||
}
|
||||
}
|
||||
|
||||
if (StaticPrefs::dom_block_external_protocol_in_iframes()) {
|
||||
// Only allow URLs able to return data in iframes.
|
||||
if (nsContentUtils::IsExternalProtocol(aLoadState->URI())) {
|
||||
|
|
|
@ -349,16 +349,7 @@ void HTMLIFrameElement::SetLazyLoading() {
|
|||
}
|
||||
|
||||
void HTMLIFrameElement::StopLazyLoading() {
|
||||
if (!mLazyLoading) {
|
||||
return;
|
||||
}
|
||||
|
||||
mLazyLoading = false;
|
||||
|
||||
Document* doc = OwnerDoc();
|
||||
if (auto* obs = doc->GetLazyLoadObserver()) {
|
||||
obs->Unobserve(*this);
|
||||
}
|
||||
CancelLazyLoading(false /* aClearLazyLoadState */);
|
||||
|
||||
LoadSrc();
|
||||
|
||||
|
@ -381,4 +372,20 @@ void HTMLIFrameElement::NodeInfoChanged(Document* aOldDoc) {
|
|||
}
|
||||
}
|
||||
|
||||
void HTMLIFrameElement::CancelLazyLoading(bool aClearLazyLoadState) {
|
||||
if (!mLazyLoading) {
|
||||
return;
|
||||
}
|
||||
|
||||
Document* doc = OwnerDoc();
|
||||
if (auto* obs = doc->GetLazyLoadObserver()) {
|
||||
obs->Unobserve(*this);
|
||||
}
|
||||
|
||||
mLazyLoading = false;
|
||||
|
||||
if (aClearLazyLoadState) {
|
||||
mLazyLoadState.Clear();
|
||||
}
|
||||
}
|
||||
} // namespace mozilla::dom
|
||||
|
|
|
@ -160,6 +160,7 @@ class HTMLIFrameElement final : public nsGenericHTMLFrameElement {
|
|||
|
||||
void SetLazyLoading();
|
||||
void StopLazyLoading();
|
||||
void CancelLazyLoading(bool aClearLazyLoadState);
|
||||
|
||||
const LazyLoadFrameResumptionState& GetLazyLoadFrameResumptionState() const {
|
||||
return mLazyLoadState;
|
||||
|
|
|
@ -154,17 +154,24 @@ void nsGenericHTMLFrameElement::SwapFrameLoaders(
|
|||
}
|
||||
|
||||
void nsGenericHTMLFrameElement::LoadSrc() {
|
||||
// Waiting for lazy load, do nothing.
|
||||
if (mLazyLoading) {
|
||||
return;
|
||||
}
|
||||
|
||||
EnsureFrameLoader();
|
||||
|
||||
if (!mFrameLoader) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mLazyLoading) {
|
||||
// Waiting for lazy load, do nothing.
|
||||
if (!mFrameLoader->GetExtantBrowsingContext()) {
|
||||
// We still want to initialize the frame loader for the browsing
|
||||
// context to exist, so that it can be found by name and such.
|
||||
nsContentUtils::AddScriptRunner(
|
||||
NewRunnableMethod("InitializeLazyFrameLoader", mFrameLoader.get(),
|
||||
&nsFrameLoader::GetBrowsingContext));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bool origSrc = !mSrcLoadHappened;
|
||||
mSrcLoadHappened = true;
|
||||
mFrameLoader->LoadFrame(origSrc);
|
||||
|
|
|
@ -1547,20 +1547,6 @@
|
|||
"expectations": ["FAIL"],
|
||||
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[frame.spec] Frame specs Frame Management should support lazy frames",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
"parameters": ["cdp", "firefox"],
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[frame.spec] Frame specs Frame Management should support lazy frames",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
"parameters": ["firefox", "webDriverBiDi"],
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[frame.spec] Frame specs Frame.evaluate should throw for detached frames",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
|
@ -2594,13 +2580,6 @@
|
|||
"expectations": ["FAIL"],
|
||||
"comment": "Firefox does not support multiple sessions in BiDi."
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[oopif.spec] OOPIF should support lazy OOP frames",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
"parameters": ["firefox", "webDriverBiDi"],
|
||||
"expectations": ["FAIL", "TIMEOUT"],
|
||||
"comment": "https://bugzilla.mozilla.org/show_bug.cgi?id=1878166"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[oopif.spec] OOPIF should support wait for navigation for transitions from local to OOPIF",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[iframe-loading-lazy-nav-form-submit.html]
|
||||
[Navigating iframe loading='lazy' before it is loaded: form submit]
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[iframe-loading-lazy-nav-link-click-fragment.html]
|
||||
[Navigating iframe loading='lazy' before it is loaded: link click (fragment)]
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[iframe-loading-lazy-nav-link-click.html]
|
||||
[Navigating iframe loading='lazy' before it is loaded: link click]
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[iframe-loading-lazy-nav-location-assign.html]
|
||||
[Navigating iframe loading='lazy' before it is loaded: location.assign]
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[iframe-loading-lazy-nav-location-replace.html]
|
||||
[Navigating iframe loading='lazy' before it is loaded: location.replace]
|
||||
expected: FAIL
|
|
@ -1,5 +0,0 @@
|
|||
[iframe-loading-lazy-nav-meta-refresh.optional.html]
|
||||
expected:
|
||||
if (os == "mac") and debug: CRASH
|
||||
[Navigating iframe loading='lazy' before it is loaded: meta refresh]
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[iframe-loading-lazy-nav-window-open.html]
|
||||
[Navigating iframe loading='lazy' before it is loaded: location.replace]
|
||||
expected: FAIL
|
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Navigating to a cross-origin for iframe loading='lazy' before it is loaded: location.replace</title>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
<iframe src="support/blank.htm?src" loading="lazy" hidden></iframe>
|
||||
<script>
|
||||
const iframe = document.querySelector('iframe');
|
||||
iframe.setAttribute(
|
||||
"data-src",
|
||||
`${get_host_info().HTTP_NOTSAMESITE_ORIGIN}/html/semantics/embedded-content/the-iframe-element/support/blank.htm?nav`
|
||||
);
|
||||
|
||||
const iframeLoaded = new Promise(resolve => {
|
||||
iframe.onload = resolve;
|
||||
});
|
||||
iframe.contentWindow.location.replace(iframe.dataset.src);
|
||||
iframe.hidden = false;
|
||||
</script>
|
||||
<!-- Loading testharness.js here is intentional to reproduce a bug in WebKit. -->
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({single_test: true});
|
||||
iframeLoaded.then(() => {
|
||||
// Need a timeout to detect failure when there are two navigations.
|
||||
step_timeout(() => {
|
||||
assert_throws_dom(
|
||||
"SecurityError", // Use the SecurityError to assert this is a cross-origin iframe
|
||||
() => {
|
||||
iframe.contentWindow.location.href
|
||||
},
|
||||
"The iframe should load the cross-site url via locaiton.replace");
|
||||
done();
|
||||
}, 1000);
|
||||
});
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче