Backed out changeset 5a021b9f8790 (bug 1578973) for browser-chrome failures at browser/base/content/test/forms/browser_selectpopup.js

This commit is contained in:
Coroiu Cristina 2019-09-13 03:55:26 +03:00
Родитель e29b81501a
Коммит 8d4d7a884d
6 изменённых файлов: 12 добавлений и 113 удалений

Просмотреть файл

@ -1591,44 +1591,17 @@ nsIContent::IMEState nsGenericHTMLFormElement::GetDesiredIMEState() {
return state;
}
static bool IsSameOriginAsTop(const BindContext& aContext,
const nsGenericHTMLFormElement* aElement) {
MOZ_ASSERT(aElement);
BrowsingContext* browsingContext = aContext.OwnerDoc().GetBrowsingContext();
if (!browsingContext) {
return false;
}
nsPIDOMWindowOuter* topWindow = browsingContext->Top()->GetDOMWindow();
if (!topWindow) {
// If we don't have a DOMWindow, We are not in same origin.
return false;
}
Document* topLevelDocument = topWindow->GetExtantDoc();
if (!topLevelDocument) {
return false;
}
return NS_SUCCEEDED(
nsContentUtils::CheckSameOrigin(topLevelDocument, aElement));
}
nsresult nsGenericHTMLFormElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// An autofocus event has to be launched if the autofocus attribute is
// specified and the element accepts the autofocus attribute and only if the
// target document is in the same origin as the top level document.
// https://html.spec.whatwg.org/multipage/interaction.html#the-autofocus-attribute:same-origin
// In addition, the document should not be already loaded and the
// "browser.autofocus" preference should be 'true'.
// specified and the element accept the autofocus attribute. In addition,
// the document should not be already loaded and the "browser.autofocus"
// preference should be 'true'.
if (IsAutofocusable() && HasAttr(kNameSpaceID_None, nsGkAtoms::autofocus) &&
StaticPrefs::browser_autofocus() && IsInUncomposedDoc() &&
IsSameOriginAsTop(aContext, this)) {
StaticPrefs::browser_autofocus() && IsInUncomposedDoc()) {
aContext.OwnerDoc().SetAutoFocusElement(this);
}

Просмотреть файл

@ -0,0 +1,4 @@
[no-cross-origin-autofocus.html]
[Autofocus shouldn't work in cross-origin iframe]
expected: FAIL

Просмотреть файл

@ -0,0 +1,4 @@
[no-sandboxed-automatic-features.html]
[If the sandboxed automatic features browsing context flag is set, autofocus in the browsing context should not be handled.]
expected: FAIL

Просмотреть файл

@ -1,18 +0,0 @@
<!DOCTYPE html>
<script src="/common/get-host-info.sub.js"></script>
<iframe id="iframe" width="200" height="100"></iframe>
<script>
iframe.src =
get_host_info().ORIGIN + "/html/semantics/forms/autofocus/resources/grand-child-autofocus.html";
window.addEventListener("message", event => {
if (event.data == "grand_child_loaded") {
parent.postMessage("ready", "*");
} else if (event.data == "report_focus_state") {
frames[0].postMessage("report_focus_state", "*");
} else if (event.data == "grand_child_is_focused" ||
event.data == "grand_child_is_not_focused") {
parent.postMessage(event.data, "*");
}
});
</script>

Просмотреть файл

@ -1,18 +0,0 @@
<!DOCTYPE html>
<input id="target" value="This should be focused!" autofocus></input>
<script>
let got_focus = false;
target.addEventListener("focus", () => got_focus = true);
window.addEventListener("load", () => {
parent.postMessage("grand_child_loaded", "*");
});
window.addEventListener("message", event => {
if (event.data == "report_focus_state") {
let msg = got_focus ? "grand_child_is_focused" : "grand_child_is_not_focused";
parent.postMessage(msg, "*");
}
});
</script>

Просмотреть файл

@ -1,46 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<meta name="assert" content="`autofocus` should work in the same origin iframe even if there is a cross-origin iframe between the parent and the same origin iframe">
<title>autofocus in the same origin grand child iframe</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/common/get-host-info.sub.js"></script>
</head>
<body>
<h1>Autofocus should work in the same origin grand child iframe.</h1>
<iframe id="child" width="200" height="100"></iframe>
<script>
let parent_loaded = false;
let grand_child_loaded = false;
async_test(function(t) {
function pingChildIfBothFramesLoaded() {
if (parent_loaded && grand_child_loaded)
frames[0].postMessage("report_focus_state", "*");
}
window.addEventListener("load", t.step_func(event => {
parent_loaded = true;
pingChildIfBothFramesLoaded();
}));
window.addEventListener("message", t.step_func(event => {
if (event.data == "ready") {
grand_child_loaded = true;
pingChildIfBothFramesLoaded();
} else if (event.data == "grand_child_is_focused") {
t.done();
} else if (event.data == "grand_child_is_not_focused") {
assert_unreached("The iframe shouldn't get focus");
}
}));
document.getElementById("child").src =
get_host_info().HTTP_NOTSAMESITE_ORIGIN + "/html/semantics/forms/autofocus/resources/child-iframe.html";
}, "Autofocus should work in the same origin grand child iframe");
</script>
</body>
</html>