Backed out changeset e15addefe3a2 (bug 762939)

This commit is contained in:
Justin Lebar 2012-07-23 11:43:33 -04:00
parent 6e40e7a4ec
commit 5932353a75
13 changed files with 5 additions and 345 deletions

View File

@ -5017,20 +5017,12 @@ nsDocShell::SetIsActive(bool aIsActive)
}
}
// Recursively tell all of our children, but don't tell <iframe mozbrowser>
// children; they handle their state separately.
// Recursively tell all of our children
PRInt32 n = mChildList.Count();
for (PRInt32 i = 0; i < n; ++i) {
nsCOMPtr<nsIDocShell> docshell = do_QueryInterface(ChildAt(i));
if (!docshell) {
continue;
}
bool isBrowser = false;
docshell->GetIsBrowserFrame(&isBrowser);
if (!isBrowser) {
docshell->SetIsActive(aIsActive);
}
if (docshell)
docshell->SetIsActive(aIsActive);
}
return NS_OK;

View File

@ -49,15 +49,6 @@ function BrowserElementChild() {
// Maps outer window id --> weak ref to window. Used by modal dialog code.
this._windowIDDict = {};
// _forcedVisible corresponds to the visibility state our owner has set on us
// (via iframe.setVisible). ownerVisible corresponds to whether the docShell
// whose window owns this element is visible.
//
// Our docShell is visible iff _forcedVisible and _ownerVisible are both
// true.
this._forcedVisible = true;
this._ownerVisible = true;
this._init();
};
@ -136,7 +127,6 @@ BrowserElementChild.prototype = {
addMsgListener("stop", this._recvStop);
addMsgListener("unblock-modal-prompt", this._recvStopWaiting);
addMsgListener("fire-ctx-callback", this._recvFireCtxCallback);
addMsgListener("owner-visibility-change", this._recvOwnerVisibilityChange);
let els = Cc["@mozilla.org/eventlistenerservice;1"]
.getService(Ci.nsIEventListenerService);
@ -458,24 +448,8 @@ BrowserElementChild.prototype = {
_recvSetVisible: function(data) {
debug("Received setVisible message: (" + data.json.visible + ")");
this._forcedVisible = data.json.visible;
this._updateDocShellVisibility();
},
/**
* Called when the window which contains this iframe becomes hidden or
* visible.
*/
_recvOwnerVisibilityChange: function(data) {
debug("Received ownerVisibilityChange: (" + data.json.visible + ")");
this._ownerVisible = data.json.visible;
this._updateDocShellVisibility();
},
_updateDocShellVisibility: function() {
var visible = this._forcedVisible && this._ownerVisible;
if (docShell.isActive !== visible) {
docShell.isActive = visible;
if (docShell.isActive !== data.json.visible) {
docShell.isActive = data.json.visible;
}
},

View File

@ -192,13 +192,6 @@ function BrowserElementParent(frameLoader) {
defineDOMRequestMethod('getScreenshot', 'get-screenshot');
defineDOMRequestMethod('getCanGoBack', 'get-can-go-back');
defineDOMRequestMethod('getCanGoForward', 'get-can-go-forward');
// Listen to mozvisibilitychange on the iframe's owner window, and forward it
// down to the child.
this._window.addEventListener('mozvisibilitychange',
this._ownerVisibilityChange.bind(this),
/* useCapture = */ false,
/* wantsUntrusted = */ false);
}
BrowserElementParent.prototype = {
@ -225,14 +218,6 @@ BrowserElementParent.prototype = {
_recvHello: function(data) {
debug("recvHello");
// Inform our child if our owner element's document is invisible. Note
// that we must do so here, rather than in the BrowserElementParent
// constructor, because the BrowserElementChild may not be initialized when
// we run our constructor.
if (this._window.document.mozHidden) {
this._ownerVisibilityChange();
}
},
_fireCtxMenuEvent: function(data) {
@ -427,14 +412,6 @@ BrowserElementParent.prototype = {
this._frameElement.dispatchEvent(evt);
},
/**
* Called when the visibility of the window which owns this iframe changes.
*/
_ownerVisibilityChange: function() {
this._sendAsyncMsg('owner-visibility-change',
{visible: !this._window.document.mozHidden});
},
};
var NSGetFactory = XPCOMUtils.generateNSGetFactory([BrowserElementParentFactory]);

View File

@ -39,13 +39,6 @@ MOCHITEST_FILES = \
test_browserElement_inproc_GetScreenshot.html \
browserElement_SetVisible.js \
test_browserElement_inproc_SetVisible.html \
browserElement_SetVisibleFrames.js \
test_browserElement_inproc_SetVisibleFrames.html \
file_browserElement_SetVisibleFrames_Outer.html \
file_browserElement_SetVisibleFrames_Inner.html \
browserElement_SetVisibleFrames2.js \
test_browserElement_inproc_SetVisibleFrames2.html \
file_browserElement_SetVisibleFrames2_Outer.html \
browserElement_KeyEvents.js \
test_browserElement_inproc_KeyEvents.html \
browserElement_XFrameOptions.js \
@ -125,8 +118,6 @@ MOCHITEST_FILES += \
test_browserElement_oop_Iconchange.html \
test_browserElement_oop_GetScreenshot.html \
test_browserElement_oop_SetVisible.html \
test_browserElement_oop_SetVisibleFrames.html \
test_browserElement_oop_SetVisibleFrames2.html \
test_browserElement_oop_KeyEvents.html \
test_browserElement_oop_XFrameOptions.html \
test_browserElement_oop_XFrameOptionsDeny.html \

View File

@ -1,77 +0,0 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 762939 - Test that visibility propagates down properly through
// hierarchies of <iframe mozbrowser>.
//
// In this test, we modify the parent's visibility and check that the child's
// visibility is changed as appopriate. We test modifying the child's
// visibility in a separate testcase.
"use strict";
SimpleTest.waitForExplicitFinish();
var iframe;
function runTest() {
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addToWhitelist();
iframe = document.createElement('iframe');
iframe.mozbrowser = true;
// Our test involves three <iframe mozbrowser>'s, parent, child1, and child2.
// child1 and child2 are contained inside parent. child1 is visibile, and
// child2 is not.
//
// For the purposes of this test, we want there to be a process barrier
// between child{1,2} and parent. Therefore parent must be a non-remote
// <iframe mozbrowser>, until bug 761935 is resolved and we can have nested
// content processes.
iframe.remote = false;
iframe.addEventListener('mozbrowsershowmodalprompt', checkMessage);
expectMessage('parent:ready', test1);
document.body.appendChild(iframe);
iframe.src = 'file_browserElement_SetVisibleFrames_Outer.html';
}
function test1() {
expectMessage('child1:hidden', test2);
iframe.setVisible(false);
}
function test2() {
expectMessage('child1:visible', finish);
iframe.setVisible(true);
}
function finish() {
// We need to remove this listener because when this test finishes and the
// iframe containing this document is navigated, we'll fire a
// visibilitychange(false) event on all child iframes. That's OK and
// expected, but if we don't remove our listener, then we'll end up causing
// the /next/ test to fail!
iframe.removeEventListener('mozbrowsershowmodalprompt', checkMessage);
SimpleTest.finish();
}
var expectedMsg = null;
var expectedMsgCallback = null;
function expectMessage(msg, next) {
expectedMsg = msg;
expectedMsgCallback = next;
}
function checkMessage(e) {
var msg = e.detail.message;
is(msg, expectedMsg);
if (msg == expectedMsg) {
expectedMsg = null;
SimpleTest.executeSoon(function() { expectedMsgCallback() });
}
}
runTest();

View File

@ -1,53 +0,0 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 762939 - Test that setting a <iframe mozbrowser> to invisible / visible
// inside an invisible <iframe mozbrowser> doesn't trigger any events.
"use strict";
SimpleTest.waitForExplicitFinish();
function runTest() {
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addToWhitelist();
var iframe = document.createElement('iframe');
iframe.mozbrowser = true;
// We need remote = false here until bug 761935 is fixed; see
// SetVisibleFrames.js for an explanation.
iframe.remote = false;
iframe.addEventListener('mozbrowserloadend', function loadEnd(e) {
iframe.removeEventListener('mozbrowserloadend', loadEnd);
iframe.setVisible(false);
iframe.src = 'file_browserElement_SetVisibleFrames2_Outer.html';
});
iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
if (e.detail.message == 'parent:finish') {
ok(true, "Got parent:finish");
// Give any extra events a chance to fire, then end the test.
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
SimpleTest.finish();
});
});
});
});
});
}
else {
ok(false, "Got unexpected message: " + e.detail.message);
}
});
document.body.appendChild(iframe);
}
runTest();

View File

@ -1,29 +0,0 @@
<html>
<body>
<script>
var iframe = document.createElement('iframe');
iframe.mozbrowser = true;
iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
if (e.detail.message == 'child:ready') {
setTimeout(function() {
iframe.setVisible(false);
iframe.setVisible(true);
setTimeout(function() {
alert('parent:finish');
}, 0);
}, 0);
}
else {
// Pass the message up to our parent.
alert(e.detail.message);
}
});
document.body.appendChild(iframe);
iframe.src = 'file_browserElement_SetVisibleFrames_Inner.html?child';
</script>
</body>
</html>

View File

@ -1,18 +0,0 @@
<html>
<body>
<script>
var name = location.search.substring(1);
addEventListener('load', function() {
setTimeout(function() {
alert(name + ':ready');
}, 0);
});
addEventListener('mozvisibilitychange', function() {
alert(name + ':' + (document.mozHidden ? 'hidden' : 'visible'));
});
</script>
</body>
</html>

View File

@ -1,45 +0,0 @@
<html>
<body>
<script>
var numPrompts = 0;
function handlePrompt(e) {
numPrompts++;
// The first two prompts should be "child1:ready" and "child2:ready". Once
// we get both of these, forward the child's prompt up to our parent.
if (numPrompts == 2) {
// This has to happen here, because setVisibile doesn't exist on the iframe
// until BrowserElementChild.js is loaded in it. (That's pretty broken...)
iframe2.setVisible(false);
}
else if (numPrompts == 3) {
if (e.detail.message != 'child2:hidden') {
alert("parent:fail Didn't get expected 'child2:hidden'.");
}
alert('parent:ready');
}
else if (numPrompts > 3) {
alert(e.detail.message);
}
}
var iframe1 = document.createElement('iframe');
iframe1.mozbrowser = true;
iframe1.addEventListener('mozbrowsershowmodalprompt', handlePrompt);
var iframe2 = document.createElement('iframe');
iframe2.mozbrowser = true;
iframe2.addEventListener('mozbrowsershowmodalprompt', handlePrompt);
iframe1.src = 'file_browserElement_SetVisibleFrames_Inner.html?child1';
iframe2.src = 'file_browserElement_SetVisibleFrames_Inner.html?child2';
document.body.appendChild(iframe1);
document.body.appendChild(iframe2);
</script>
</body>
</html>

View File

@ -1,13 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 762939</title>
<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" src="browserElement_SetVisibleFrames.js">
</script>
</body>
</html>

View File

@ -1,13 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 762939</title>
<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" src="browserElement_SetVisibleFrames2.js">
</script>
</body>
</html>

View File

@ -1,13 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 762939</title>
<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" src="browserElement_SetVisibleFrames.js">
</script>
</body>
</html>

View File

@ -1,13 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 762939</title>
<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" src="browserElement_SetVisibleFrames2.js">
</script>
</body>
</html>