Backed out changeset 12893215ed66 (bug 1696323) for OS X build bustages on BrowserBridgeChild.cpp. CLOSED TREE

This commit is contained in:
imoraru 2021-04-29 13:09:17 +03:00
Родитель 75f46fe3cf
Коммит 6349660632
14 изменённых файлов: 42 добавлений и 297 удалений

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

@ -418,7 +418,7 @@ nsFocusManager::GetFocusedContentBrowsingContext(
nsresult nsFocusManager::SetFocusedWindowWithCallerType(
mozIDOMWindowProxy* aWindowToFocus, CallerType aCallerType,
uint64_t aActionId) {
LOGFOCUS(("<<SetFocusedWindow begin actionid: %lu>>", aActionId));
LOGFOCUS(("<<SetFocusedWindow begin>>"));
nsCOMPtr<nsPIDOMWindowOuter> windowToFocus =
nsPIDOMWindowOuter::From(aWindowToFocus);
@ -446,7 +446,7 @@ nsresult nsFocusManager::SetFocusedWindowWithCallerType(
RaiseWindow(rootWindow, aCallerType, aActionId);
}
LOGFOCUS(("<<SetFocusedWindow end actionid: %lu>>", aActionId));
LOGFOCUS(("<<SetFocusedWindow end>>"));
return NS_OK;
}
@ -670,8 +670,8 @@ void nsFocusManager::WindowRaised(mozIDOMWindowProxy* aWindow,
BrowsingContext* bc = window->GetBrowsingContext();
if (MOZ_LOG_TEST(gFocusLog, LogLevel::Debug)) {
LOGFOCUS(("Window %p Raised [Currently: %p %p] actionid: %lu", aWindow,
mActiveWindow.get(), mFocusedWindow.get(), aActionId));
LOGFOCUS(("Window %p Raised [Currently: %p %p]", aWindow,
mActiveWindow.get(), mFocusedWindow.get()));
Document* doc = window->GetExtantDoc();
if (doc && doc->GetDocumentURI()) {
LOGFOCUS((" Raised Window: %p %s", aWindow,
@ -1011,8 +1011,8 @@ void nsFocusManager::WindowHidden(mozIDOMWindowProxy* aWindow,
nsCOMPtr<nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(aWindow);
if (MOZ_LOG_TEST(gFocusLog, LogLevel::Debug)) {
LOGFOCUS(("Window %p Hidden [Currently: %p %p] actionid: %lu", window.get(),
mActiveWindow.get(), mFocusedWindow.get(), aActionId));
LOGFOCUS(("Window %p Hidden [Currently: %p %p]", window.get(),
mActiveWindow.get(), mFocusedWindow.get()));
nsAutoCString spec;
Document* doc = window->GetExtantDoc();
if (doc && doc->GetDocumentURI()) {
@ -1475,16 +1475,6 @@ void nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags,
// called during reflow, calling GetBrowsingContext() could cause frame
// loader initialization at a time when it isn't safe.
if (BrowsingContext* bc = flo->GetExtantBrowsingContext()) {
// If focus is already in the subtree rooted at bc, return early
// to match the single-process focus semantics. Otherwise, we'd
// blur and immediately refocus whatever is focused.
BrowsingContext* walk = focusedBrowsingContext;
while (walk) {
if (walk == bc) {
return;
}
walk = walk->GetParent();
}
browsingContextToFocus = bc;
}
}
@ -1678,9 +1668,8 @@ void nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags,
mFocusedElement.get()));
LOGFOCUS(
(" In Active Window: %d Moves to different BrowsingContext: %d "
"SendFocus: %d actionid: %lu",
isElementInActiveWindow, focusMovesToDifferentBC, sendFocusEvent,
aActionId));
"SendFocus: %d",
isElementInActiveWindow, focusMovesToDifferentBC, sendFocusEvent));
if (sendFocusEvent) {
Maybe<BlurredElementInfo> blurredInfo;
@ -2202,7 +2191,7 @@ bool nsFocusManager::BlurImpl(BrowsingContext* aBrowsingContextToClear,
BrowsingContext* aAncestorBrowsingContextToFocus,
bool aIsLeavingDocument, bool aAdjustWidget,
Element* aElementToFocus, uint64_t aActionId) {
LOGFOCUS(("<<Blur begin actionid: %lu>>", aActionId));
LOGFOCUS(("<<Blur begin>>"));
// hold a reference to the focused content, which may be null
RefPtr<Element> element = mFocusedElement;
@ -2235,8 +2224,7 @@ bool nsFocusManager::BlurImpl(BrowsingContext* aBrowsingContextToClear,
// Unclear if this ever happens.
LOGFOCUS(
("Ignored an attempt to null out focused BrowsingContext when "
"docShell is null due to a stale action id %lu.",
aActionId));
"docShell is null due to a stale action id."));
return true;
}
@ -2258,8 +2246,7 @@ bool nsFocusManager::BlurImpl(BrowsingContext* aBrowsingContextToClear,
// Unclear if this ever happens.
LOGFOCUS(
("Ignored an attempt to null out focused BrowsingContext when "
"presShell is null due to a stale action id %lu.",
aActionId));
"presShell is null due to a stale action id."));
return true;
}
mFocusedElement = nullptr;
@ -2316,10 +2303,10 @@ bool nsFocusManager::BlurImpl(BrowsingContext* aBrowsingContextToClear,
if (RefPtr<BrowserParent> browserParent =
windowGlobalParent->GetBrowserParent()) {
browserParent->Deactivate(windowBeingLowered, aActionId);
LOGFOCUS(("%s remote browser deactivated %p, %d, actionid: %lu",
LOGFOCUS(("%s remote browser deactivated %p, %d",
aContext == topLevelBrowsingContext ? "Top-level"
: "OOP iframe",
browserParent.get(), windowBeingLowered, aActionId));
browserParent.get(), windowBeingLowered));
}
}
});
@ -2328,8 +2315,8 @@ bool nsFocusManager::BlurImpl(BrowsingContext* aBrowsingContextToClear,
// Same as above but for out-of-process iframes
if (BrowserBridgeChild* bbc = BrowserBridgeChild::GetFrom(element)) {
bbc->Deactivate(windowBeingLowered, aActionId);
LOGFOCUS(("Out-of-process iframe deactivated %p, %d, actionid: %lu", bbc,
windowBeingLowered, aActionId));
LOGFOCUS(("Out-of-process iframe deactivated %p, %d", bbc,
windowBeingLowered));
}
}
@ -2414,14 +2401,13 @@ void nsFocusManager::ActivateRemoteFrameIfNeeded(Element& aElement,
uint64_t aActionId) {
if (BrowserParent* remote = BrowserParent::GetFrom(&aElement)) {
remote->Activate(aActionId);
LOGFOCUS(("Remote browser activated %p, actionid: %lu", remote, aActionId));
LOGFOCUS(("Remote browser activated %p", remote));
}
// Same as above but for out-of-process iframes
if (BrowserBridgeChild* bbc = BrowserBridgeChild::GetFrom(&aElement)) {
bbc->Activate(aActionId);
LOGFOCUS(
("Out-of-process iframe activated %p, actionid: %lu", bbc, aActionId));
LOGFOCUS(("Out-of-process iframe activated %p", bbc));
}
}
@ -2430,7 +2416,7 @@ void nsFocusManager::Focus(
bool aIsNewDocument, bool aFocusChanged, bool aWindowRaised,
bool aAdjustWidget, uint64_t aActionId,
const Maybe<BlurredElementInfo>& aBlurredElementInfo) {
LOGFOCUS(("<<Focus begin actionid: %lu>>", aActionId));
LOGFOCUS(("<<Focus begin>>"));
if (!aWindow) {
return;
@ -2471,8 +2457,7 @@ void nsFocusManager::Focus(
aActionId, mActionIdForFocusedBrowsingContextInContent)) {
// Unclear if this ever happens.
LOGFOCUS(
("Ignored an attempt to focus an element due to stale action id %lu.",
aActionId));
("Ignored an attempt to focus an element due to stale action id."));
return;
}
}
@ -2511,9 +2496,8 @@ void nsFocusManager::Focus(
if (docm) {
LOGCONTENT(" from %s", docm->GetRootElement());
}
LOGFOCUS(
(" [Newdoc: %d FocusChanged: %d Raised: %d Flags: %x actionid: %lu]",
aIsNewDocument, aFocusChanged, aWindowRaised, aFlags, aActionId));
LOGFOCUS((" [Newdoc: %d FocusChanged: %d Raised: %d Flags: %x]",
aIsNewDocument, aFocusChanged, aWindowRaised, aFlags));
}
if (aIsNewDocument) {
@ -4817,8 +4801,8 @@ void nsFocusManager::SetFocusedBrowsingContextFromOtherProcess(
// Unclear if this ever happens.
LOGFOCUS(
("Ignored an attempt to set an in-process BrowsingContext [%p] as "
"focused from another process due to stale action id %lu.",
aContext, aActionId));
"focused from another process due to stale action id.",
aContext));
return;
}
if (aContext->IsInProcess()) {
@ -4830,8 +4814,8 @@ void nsFocusManager::SetFocusedBrowsingContextFromOtherProcess(
// was in-flight. Let's just ignore this.
LOGFOCUS(
("Ignored an attempt to set an in-process BrowsingContext [%p] as "
"focused from another process, actionid: %lu.",
aContext, aActionId));
"focused from another process.",
aContext));
return;
}
mFocusedBrowsingContextInContent = aContext;
@ -4881,8 +4865,8 @@ void nsFocusManager::SetActiveBrowsingContextInContent(
mActionIdForActiveBrowsingContextInContent)) {
LOGFOCUS(
("Ignored an attempt to set an in-process BrowsingContext [%p] as "
"the active browsing context due to a stale action id %lu.",
aContext, aActionId));
"the active browsing context due to a stale action id.",
aContext));
return;
}
@ -4925,8 +4909,8 @@ void nsFocusManager::SetActiveBrowsingContextFromOtherProcess(
mActionIdForActiveBrowsingContextInContent)) {
LOGFOCUS(
("Ignored an attempt to set active BrowsingContext [%p] from "
"another process due to a stale action id %lu.",
aContext, aActionId));
"another process due to a stale action id.",
aContext));
return;
}
if (aContext->IsInProcess()) {
@ -4938,8 +4922,8 @@ void nsFocusManager::SetActiveBrowsingContextFromOtherProcess(
// was in-flight. Let's just ignore this.
LOGFOCUS(
("Ignored an attempt to set an in-process BrowsingContext [%p] as "
"active from another process. actionid: %lu",
aContext, aActionId));
"active from another process.",
aContext));
return;
}
mActiveBrowsingContextInContentSetFromOtherProcess = true;
@ -4956,8 +4940,8 @@ void nsFocusManager::UnsetActiveBrowsingContextFromOtherProcess(
mActionIdForActiveBrowsingContextInContent)) {
LOGFOCUS(
("Ignored an attempt to unset the active BrowsingContext [%p] from "
"another process due to stale action id: %lu.",
aContext, aActionId));
"another process due to stale action id.",
aContext));
return;
}
if (mActiveBrowsingContextInContent == aContext) {
@ -4967,8 +4951,8 @@ void nsFocusManager::UnsetActiveBrowsingContextFromOtherProcess(
} else {
LOGFOCUS(
("Ignored an attempt to unset the active BrowsingContext [%p] from "
"another process. actionid: %lu",
aContext, aActionId));
"another process.",
aContext));
}
}
@ -4977,17 +4961,12 @@ void nsFocusManager::ReviseActiveBrowsingContext(
uint64_t aNewActionId) {
MOZ_ASSERT(XRE_IsContentProcess());
if (mActionIdForActiveBrowsingContextInContent == aOldActionId) {
LOGFOCUS(
("Revising the active BrowsingContext [%p]. old actionid: %lu, new "
"actionid: %lu",
aContext, aOldActionId, aNewActionId));
mActiveBrowsingContextInContent = aContext;
mActionIdForActiveBrowsingContextInContent = aNewActionId;
} else {
LOGFOCUS(
("Ignored a stale attempt to revise the active BrowsingContext [%p]. "
"old actionid: %lu, new actionid: %lu",
aContext, aOldActionId, aNewActionId));
("Ignored a stale attempt to revise the active BrowsingContext [%p].",
aContext));
}
}
@ -4996,18 +4975,13 @@ void nsFocusManager::ReviseFocusedBrowsingContext(
uint64_t aNewActionId) {
MOZ_ASSERT(XRE_IsContentProcess());
if (mActionIdForFocusedBrowsingContextInContent == aOldActionId) {
LOGFOCUS(
("Revising the focused BrowsingContext [%p]. old actionid: %lu, new "
"actionid: %lu",
aContext, aOldActionId, aNewActionId));
mFocusedBrowsingContextInContent = aContext;
mActionIdForFocusedBrowsingContextInContent = aNewActionId;
mFocusedElement = nullptr;
} else {
LOGFOCUS(
("Ignored a stale attempt to revise the focused BrowsingContext [%p]. "
"old actionid: %lu, new actionid: %lu",
aContext, aOldActionId, aNewActionId));
("Ignored a stale attempt to revise the focused BrowsingContext [%p].",
aContext));
}
}
@ -5037,7 +5011,6 @@ BrowsingContext* nsFocusManager::GetActiveBrowsingContextInChrome() {
}
void nsFocusManager::InsertNewFocusActionId(uint64_t aActionId) {
LOGFOCUS(("InsertNewFocusActionId %lu", aActionId));
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(!mPendingActiveBrowsingContextActions.Contains(aActionId));
mPendingActiveBrowsingContextActions.AppendElement(aActionId);
@ -5130,7 +5103,6 @@ uint64_t nsFocusManager::GenerateFocusActionId() {
MOZ_ASSERT(contentChild);
contentChild->SendInsertNewFocusActionId(id);
}
LOGFOCUS(("GenerateFocusActionId %lu", id));
return id;
}
@ -5166,8 +5138,7 @@ void nsFocusManager::SetFocusedWindowInternal(nsPIDOMWindowOuter* aWindow,
// Unclear if this ever happens.
LOGFOCUS(
("Ignored an attempt to set an in-process BrowsingContext as "
"focused due to stale action id %lu.",
aActionId));
"focused due to stale action id."));
return;
}

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

@ -28,11 +28,6 @@
using namespace mozilla::ipc;
mozilla::LazyLogModule gBrowserChildFocusLog("BrowserChildFocus");
#define LOGBROWSERCHILDFOCUS(args) \
MOZ_LOG(gBrowserChildFocusLog, mozilla::LogLevel::Debug, args)
namespace mozilla::dom {
BrowserBridgeChild::BrowserBridgeChild(BrowsingContext* aBrowsingContext,
@ -82,8 +77,6 @@ void BrowserBridgeChild::NavigateByKey(bool aForward,
}
void BrowserBridgeChild::Activate(uint64_t aActionId) {
LOGBROWSERCHILDFOCUS(
("BrowserBridgeChild::Activate actionid: %lu", aActionId));
Unused << SendActivate(aActionId);
}

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

@ -1133,7 +1133,7 @@ void BrowserParent::HandleAccessKey(const WidgetKeyboardEvent& aEvent,
}
void BrowserParent::Activate(uint64_t aActionId) {
LOGBROWSERFOCUS(("Activate %p actionid: %lu", this, aActionId));
LOGBROWSERFOCUS(("Activate %p", this));
if (!mIsDestroyed) {
SetTopLevelWebFocus(this); // Intentionally inside "if"
Unused << SendActivate(aActionId);
@ -1141,7 +1141,7 @@ void BrowserParent::Activate(uint64_t aActionId) {
}
void BrowserParent::Deactivate(bool aWindowLowering, uint64_t aActionId) {
LOGBROWSERFOCUS(("Deactivate %p actionid: %lu", this, aActionId));
LOGBROWSERFOCUS(("Deactivate %p", this));
if (!aWindowLowering) {
UnsetTopLevelWebFocus(this); // Intentionally outside the next "if"
}

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

@ -6772,7 +6772,6 @@ mozilla::ipc::IPCResult ContentParent::RecvWindowFocus(
("ParentIPC: Trying to send a message to dead or detached context"));
return IPC_OK();
}
LOGFOCUS(("ContentParent::RecvWindowFocus actionid: %lu", aActionId));
CanonicalBrowsingContext* context = aContext.get_canonical();
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
@ -6808,7 +6807,6 @@ mozilla::ipc::IPCResult ContentParent::RecvRaiseWindow(
("ParentIPC: Trying to send a message to dead or detached context"));
return IPC_OK();
}
LOGFOCUS(("ContentParent::RecvRaiseWindow actionid: %lu", aActionId));
CanonicalBrowsingContext* context = aContext.get_canonical();
@ -6828,9 +6826,6 @@ mozilla::ipc::IPCResult ContentParent::RecvAdjustWindowFocus(
("ParentIPC: Trying to send a message to dead or detached context"));
return IPC_OK();
}
LOGFOCUS(("ContentParent::RecvAdjustWindowFocus isVisible %d actionid: %lu",
aIsVisible, aActionId));
nsTHashMap<nsPtrHashKey<ContentParent>, bool> processes(2);
processes.InsertOrUpdate(this, true);
@ -6879,8 +6874,6 @@ mozilla::ipc::IPCResult ContentParent::RecvSetFocusedBrowsingContext(
("ParentIPC: Trying to send a message to dead or detached context"));
return IPC_OK();
}
LOGFOCUS(("ContentParent::RecvSetFocusedBrowsingContext actionid: %lu",
aActionId));
CanonicalBrowsingContext* context = aContext.get_canonical();
nsFocusManager* fm = nsFocusManager::GetFocusManager();
@ -6916,8 +6909,6 @@ mozilla::ipc::IPCResult ContentParent::RecvSetActiveBrowsingContext(
("ParentIPC: Trying to send a message to dead or detached context"));
return IPC_OK();
}
LOGFOCUS(
("ContentParent::RecvSetActiveBrowsingContext actionid: %lu", aActionId));
CanonicalBrowsingContext* context = aContext.get_canonical();
nsFocusManager* fm = nsFocusManager::GetFocusManager();
@ -6951,8 +6942,6 @@ mozilla::ipc::IPCResult ContentParent::RecvUnsetActiveBrowsingContext(
("ParentIPC: Trying to send a message to dead or detached context"));
return IPC_OK();
}
LOGFOCUS(("ContentParent::RecvUnsetActiveBrowsingContext actionid: %lu",
aActionId));
CanonicalBrowsingContext* context = aContext.get_canonical();
nsFocusManager* fm = nsFocusManager::GetFocusManager();
@ -6986,7 +6975,6 @@ mozilla::ipc::IPCResult ContentParent::RecvSetFocusedElement(
("ParentIPC: Trying to send a message to dead or detached context"));
return IPC_OK();
}
LOGFOCUS(("ContentParent::RecvSetFocusedElement"));
CanonicalBrowsingContext* context = aContext.get_canonical();
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
@ -7007,7 +6995,6 @@ mozilla::ipc::IPCResult ContentParent::RecvFinalizeFocusOuter(
("ParentIPC: Trying to send a message to dead or detached context"));
return IPC_OK();
}
LOGFOCUS(("ContentParent::RecvFinalizeFocusOuter"));
CanonicalBrowsingContext* context = aContext.get_canonical();
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
@ -7021,8 +7008,6 @@ mozilla::ipc::IPCResult ContentParent::RecvFinalizeFocusOuter(
mozilla::ipc::IPCResult ContentParent::RecvInsertNewFocusActionId(
uint64_t aActionId) {
LOGFOCUS(
("ContentParent::RecvInsertNewFocusActionId actionid: %lu", aActionId));
nsFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm) {
fm->InsertNewFocusActionId(aActionId);
@ -7044,13 +7029,6 @@ mozilla::ipc::IPCResult ContentParent::RecvBlurToParent(
return IPC_OK();
}
LOGFOCUS(
("ContentParent::RecvBlurToParent isLeavingDocument %d adjustWidget %d "
"browsingContextToClearHandled %d ancestorBrowsingContextToFocusHandled "
"%d actionid: %lu",
aIsLeavingDocument, aAdjustWidget, aBrowsingContextToClearHandled,
aAncestorBrowsingContextToFocusHandled, aActionId));
CanonicalBrowsingContext* focusedBrowsingContext =
aFocusedBrowsingContext.get_canonical();

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

@ -1,20 +0,0 @@
<!doctype html>
<meta charset=utf-8>
<title>Focus already focused iframe</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
setup({explicit_done:true});
var w = null;
window.onload = function() {
window.onmessage = function(e) {
test(function() {
assert_equals(e.data, "PASS", 'Check result');
}, "Check result");
w.close();
w = null;
done();
};
w = window.open("support/focus-already-focused-iframe-deep-different-site-outer.sub.html");
}
</script>

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

@ -1,20 +0,0 @@
<!doctype html>
<meta charset=utf-8>
<title>Focus already focused iframe</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
setup({explicit_done:true});
var w = null;
window.onload = function() {
window.onmessage = function(e) {
test(function() {
assert_equals(e.data, "PASS", 'Check result');
}, "Check result");
w.close();
w = null;
done();
};
w = window.open("support/focus-already-focused-iframe-deep-same-site-outer.html");
}
</script>

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

@ -1,20 +0,0 @@
<!doctype html>
<meta charset=utf-8>
<title>Focus already focused iframe</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
setup({explicit_done:true});
var w = null;
window.onload = function() {
window.onmessage = function(e) {
test(function() {
assert_equals(e.data, "PASS", 'Check result');
}, "Check result");
w.close();
w = null;
done();
};
w = window.open("support/focus-already-focused-iframe-different-site-outer.sub.html");
}
</script>

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

@ -1,20 +0,0 @@
<!doctype html>
<meta charset=utf-8>
<title>Focus already focused iframe</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
setup({explicit_done:true});
var w = null;
window.onload = function() {
window.onmessage = function(e) {
test(function() {
assert_equals(e.data, "PASS", 'Check result');
}, "Check result");
w.close();
w = null;
done();
};
w = window.open("support/focus-already-focused-iframe-same-site-outer.html");
}
</script>

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

@ -1,21 +0,0 @@
<!doctype html>
<meta charset="utf-8">
<title>Focus already focused iframe</title>
<script>
let failed = false;
window.onmessage = function(e) {
if (e.data == "focus") {
document.getElementsByTagName("iframe")[0].focus();
opener.step_timeout(function() {
if (failed) {
opener.postMessage("FAIL", "*");
} else {
opener.postMessage("PASS", "*");
}
}, 1500);
} else if (e.data == "FAIL") {
failed = true;
}
}
</script>
<iframe src="http://{{hosts[alt][www]}}:{{ports[http][0]}}/focus/support/focus-already-focused-iframe-middle.html"></iframe>

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

@ -1,21 +0,0 @@
<!doctype html>
<meta charset="utf-8">
<title>Focus already focused iframe</title>
<script>
let failed = false;
window.onmessage = function(e) {
if (e.data == "focus") {
document.getElementsByTagName("iframe")[0].focus();
opener.step_timeout(function() {
if (failed) {
opener.postMessage("FAIL", "*");
} else {
opener.postMessage("PASS", "*");
}
}, 1500);
} else if (e.data == "FAIL") {
failed = true;
}
}
</script>
<iframe src="focus-already-focused-iframe-middle.html"></iframe>

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

@ -1,21 +0,0 @@
<!doctype html>
<meta charset="utf-8">
<title>Focus already focused iframe</title>
<script>
let failed = false;
window.onmessage = function(e) {
if (e.data == "focus") {
document.getElementsByTagName("iframe")[0].focus();
opener.step_timeout(function() {
if (failed) {
opener.postMessage("FAIL", "*");
} else {
opener.postMessage("PASS", "*");
}
}, 1500);
} else if (e.data == "FAIL") {
failed = true;
}
}
</script>
<iframe src="http://{{hosts[alt][www]}}:{{ports[http][0]}}/focus/support/focus-already-focused-iframe-inner.html"></iframe>

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

@ -1,18 +0,0 @@
<!doctype html>
<meta charset="utf-8">
<title>Focus already focused iframe</title>
<script>
let haveGottenFocus = false;
function gotFocus() {
if (haveGottenFocus) {
parent.postMessage("FAIL", "*");
} else {
haveGottenFocus = true;
parent.postMessage("focus", "*");
}
}
window.onload = function() {
document.getElementsByTagName("input")[0].focus();
}
</script>
<input onfocus="gotFocus();">

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

@ -1,15 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Middle</title>
<script>
window.onmessage = function(e) {
parent.postMessage(e.data, "*");
}
</script>
</head>
<body>
<iframe src="focus-already-focused-iframe-inner.html"></iframe>
</body>
</html>

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

@ -1,21 +0,0 @@
<!doctype html>
<meta charset="utf-8">
<title>Focus already focused iframe</title>
<script>
let failed = false;
window.onmessage = function(e) {
if (e.data == "focus") {
document.getElementsByTagName("iframe")[0].focus();
opener.step_timeout(function() {
if (failed) {
opener.postMessage("FAIL", "*");
} else {
opener.postMessage("PASS", "*");
}
}, 1500);
} else if (e.data == "FAIL") {
failed = true;
}
}
</script>
<iframe src="focus-already-focused-iframe-inner.html"></iframe>