mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-30 21:55:31 +00:00
Merging backout. a=orange
This commit is contained in:
commit
9193838b50
@ -4431,22 +4431,16 @@ var XULBrowserWindow = {
|
||||
else
|
||||
elt.removeAttribute("disabled");
|
||||
});
|
||||
|
||||
if (gFindBarInitialized) {
|
||||
gFindBar.close();
|
||||
|
||||
// fix bug 253793 - turn off highlight when page changes
|
||||
gFindBar.getElement("highlight").checked = false;
|
||||
}
|
||||
}
|
||||
UpdateBackForwardCommands(gBrowser.webNavigation);
|
||||
|
||||
if (gFindBarInitialized) {
|
||||
if (gFindBar.findMode != gFindBar.FIND_NORMAL) {
|
||||
// Close the Find toolbar if we're in old-style TAF mode
|
||||
gFindBar.close();
|
||||
}
|
||||
|
||||
// XXXmano new-findbar, do something useful once it lands.
|
||||
// Of course, this is especially wrong with bfcache on...
|
||||
|
||||
// fix bug 253793 - turn off highlight when page changes
|
||||
gFindBar.getElement("highlight").checked = false;
|
||||
}
|
||||
|
||||
// See bug 358202, when tabs are switched during a drag operation,
|
||||
// timers don't fire on windows (bug 203573)
|
||||
if (aRequest)
|
||||
|
@ -965,12 +965,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
// If the find bar is focused, keep it focused.
|
||||
if (gFindBarInitialized &&
|
||||
!gFindBar.hidden &&
|
||||
gFindBar.getElement("findbar-textbox").getAttribute("focused") == "true")
|
||||
break;
|
||||
|
||||
// Otherwise, focus the content area.
|
||||
let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
|
||||
let newFocusedElement = fm.getFocusedElementForWindow(window.content, true, {});
|
||||
|
@ -169,6 +169,7 @@ _BROWSER_FILES = \
|
||||
browser_bug616836.js \
|
||||
browser_bug623893.js \
|
||||
browser_bug624734.js \
|
||||
browser_bug628179.js \
|
||||
browser_contextSearchTabPosition.js \
|
||||
browser_ctrlTab.js \
|
||||
browser_customize_popupNotification.js \
|
||||
@ -243,6 +244,7 @@ _BROWSER_FILES = \
|
||||
browser_addon_bar_close_button.js \
|
||||
browser_addon_bar_shortcut.js \
|
||||
browser_addon_bar_aomlistener.js \
|
||||
test_bug628179.html \
|
||||
$(NULL)
|
||||
|
||||
# compartment-disabled
|
||||
|
66
browser/base/content/test/browser_bug628179.js
Normal file
66
browser/base/content/test/browser_bug628179.js
Normal file
@ -0,0 +1,66 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Tests that the Find bar goes away on tab switch or location change.
|
||||
|
||||
let newTab, iframe;
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
newTab = gBrowser.addTab("about:blank");
|
||||
gBrowser.addEventListener("DOMContentLoaded", testFindBarCloseOnTabSwitch,
|
||||
false);
|
||||
}
|
||||
|
||||
function testFindBarCloseOnTabSwitch() {
|
||||
gBrowser.removeEventListener("DOMContentLoaded", testFindBarCloseOnTabSwitch,
|
||||
false);
|
||||
|
||||
gFindBar.open();
|
||||
gBrowser.selectedTab = newTab;
|
||||
ok(gFindBar.hidden, "the Find bar is hidden after switching tabs");
|
||||
|
||||
gFindBar.open();
|
||||
newTab.linkedBrowser.addEventListener("DOMContentLoaded",
|
||||
testFindBarCloseOnLocationChange,
|
||||
false);
|
||||
newTab.linkedBrowser.contentWindow.location = "http://example.com/";
|
||||
}
|
||||
|
||||
function testFindBarCloseOnLocationChange() {
|
||||
newTab.linkedBrowser.removeEventListener("DOMContentLoaded",
|
||||
testFindBarCloseOnLocationChange,
|
||||
false);
|
||||
|
||||
ok(gFindBar.hidden, "the Find bar is hidden after the location changes");
|
||||
|
||||
newTab.linkedBrowser.addEventListener("DOMContentLoaded",
|
||||
prepareTestFindBarStaysOpenOnSubdocumentLocationChange, false);
|
||||
newTab.linkedBrowser.contentWindow.location = "http://example.com/browser/" +
|
||||
"browser/base/content/test/test_bug628179.html";
|
||||
}
|
||||
|
||||
function prepareTestFindBarStaysOpenOnSubdocumentLocationChange() {
|
||||
newTab.linkedBrowser.removeEventListener("DOMContentLoaded",
|
||||
prepareTestFindBarStaysOpenOnSubdocumentLocationChange, false);
|
||||
|
||||
gFindBar.open();
|
||||
|
||||
iframe = newTab.linkedBrowser.contentDocument.getElementById("iframe");
|
||||
iframe.addEventListener("load",
|
||||
testFindBarStaysOpenOnSubdocumentLocationChange, false);
|
||||
iframe.src = "http://example.org/";
|
||||
}
|
||||
|
||||
function testFindBarStaysOpenOnSubdocumentLocationChange() {
|
||||
iframe.removeEventListener("load",
|
||||
testFindBarStaysOpenOnSubdocumentLocationChange, false);
|
||||
|
||||
ok(!gFindBar.hidden, "the Find bar isn't hidden after the location of a " +
|
||||
"subdocument changes");
|
||||
|
||||
gFindBar.close();
|
||||
gBrowser.removeTab(newTab);
|
||||
finish();
|
||||
}
|
||||
|
@ -37,7 +37,6 @@
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
ok(!gFindBarInitialized, "find bar is not yet initialized");
|
||||
|
||||
let tab = gBrowser.addTab();
|
||||
gBrowser.selectedTab = tab;
|
||||
|
10
browser/base/content/test/test_bug628179.html
Normal file
10
browser/base/content/test/test_bug628179.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for closing the Find bar in subdocuments</title>
|
||||
</head>
|
||||
<body>
|
||||
<iframe id=iframe src="http://example.com/" width=320 height=240></iframe>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1366,6 +1366,103 @@ JS_TransplantObject(JSContext *cx, JSObject *origobj, JSObject *target)
|
||||
return obj;
|
||||
}
|
||||
|
||||
/*
|
||||
* The location object is special. There is the location object itself and
|
||||
* then the location object wrapper. Because there are no direct references to
|
||||
* the location object itself, we don't want the old obj (|origobj| here) to
|
||||
* become the new wrapper but the wrapper itself instead. This leads to very
|
||||
* subtle differences between js_TransplantObjectWithWrapper and
|
||||
* JS_TransplantObject.
|
||||
*/
|
||||
JS_FRIEND_API(JSObject *)
|
||||
js_TransplantObjectWithWrapper(JSContext *cx,
|
||||
JSObject *origobj,
|
||||
JSObject *origwrapper,
|
||||
JSObject *targetobj,
|
||||
JSObject *targetwrapper)
|
||||
{
|
||||
JSObject *obj;
|
||||
JSCompartment *destination = targetobj->getCompartment();
|
||||
WrapperMap &map = destination->crossCompartmentWrappers;
|
||||
|
||||
// |origv| is the map entry we're looking up. The map entries are going to
|
||||
// be for the location object itself.
|
||||
Value origv = ObjectValue(*origobj);
|
||||
|
||||
// There might already be a wrapper for the original object in the new
|
||||
// compartment.
|
||||
if (WrapperMap::Ptr p = map.lookup(origv)) {
|
||||
// There is. Make the existing wrapper a same compartment location
|
||||
// wrapper (swapping it with the given new wrapper).
|
||||
obj = &p->value.toObject();
|
||||
map.remove(p);
|
||||
if (!obj->swap(cx, targetwrapper))
|
||||
return NULL;
|
||||
} else {
|
||||
// Otherwise, use the passed-in wrapper as the same compartment
|
||||
// location wrapper.
|
||||
obj = targetwrapper;
|
||||
}
|
||||
|
||||
// Now, iterate through other scopes looking for references to the old
|
||||
// location object. Note that the entries in the maps are for |origobj|
|
||||
// and not |origwrapper|. They need to be updated to point at the new
|
||||
// location object.
|
||||
Value targetv = ObjectValue(*targetobj);
|
||||
WrapperVector &vector = cx->runtime->compartments;
|
||||
AutoValueVector toTransplant(cx);
|
||||
toTransplant.reserve(vector.length());
|
||||
|
||||
for (JSCompartment **p = vector.begin(), **end = vector.end(); p != end; ++p) {
|
||||
WrapperMap &pmap = (*p)->crossCompartmentWrappers;
|
||||
if (WrapperMap::Ptr wp = pmap.lookup(origv)) {
|
||||
// We found a wrapper. Remember and root it.
|
||||
toTransplant.append(wp->value);
|
||||
}
|
||||
}
|
||||
|
||||
for (Value *begin = toTransplant.begin(), *end = toTransplant.end(); begin != end; ++begin) {
|
||||
JSObject *wobj = &begin->toObject();
|
||||
JSCompartment *wcompartment = wobj->compartment();
|
||||
WrapperMap &pmap = wcompartment->crossCompartmentWrappers;
|
||||
JS_ASSERT(pmap.lookup(origv));
|
||||
pmap.remove(origv);
|
||||
|
||||
// First, we wrap it in the new compartment. This will return a
|
||||
// new wrapper.
|
||||
AutoCompartment ac(cx, wobj);
|
||||
|
||||
JSObject *tobj = targetobj;
|
||||
if (!ac.enter() || !wcompartment->wrap(cx, &tobj))
|
||||
return NULL;
|
||||
|
||||
// Now, because we need to maintain object identity, we do a brain
|
||||
// transplant on the old object. At the same time, we update the
|
||||
// entry in the compartment's wrapper map to point to the old
|
||||
// wrapper.
|
||||
JS_ASSERT(tobj != wobj);
|
||||
if (!wobj->swap(cx, tobj))
|
||||
return NULL;
|
||||
pmap.put(targetv, ObjectValue(*wobj));
|
||||
}
|
||||
|
||||
// Lastly, update the original object to point to the new one. However, as
|
||||
// mentioned above, we do the transplant on the wrapper, not the object
|
||||
// itself, since all of the references are to the object itself.
|
||||
{
|
||||
AutoCompartment ac(cx, origobj);
|
||||
JSObject *tobj = obj;
|
||||
if (!ac.enter() || !JS_WrapObject(cx, &tobj))
|
||||
return NULL;
|
||||
if (!origwrapper->swap(cx, tobj))
|
||||
return NULL;
|
||||
origwrapper->getCompartment()->crossCompartmentWrappers.put(targetv,
|
||||
ObjectValue(*origwrapper));
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject *)
|
||||
JS_GetGlobalObject(JSContext *cx)
|
||||
{
|
||||
|
@ -1006,6 +1006,13 @@ JS_WrapValue(JSContext *cx, jsval *vp);
|
||||
extern JS_PUBLIC_API(JSObject *)
|
||||
JS_TransplantObject(JSContext *cx, JSObject *origobj, JSObject *target);
|
||||
|
||||
extern JS_FRIEND_API(JSObject *)
|
||||
js_TransplantObjectWithWrapper(JSContext *cx,
|
||||
JSObject *origobj,
|
||||
JSObject *origwrapper,
|
||||
JSObject *targetobj,
|
||||
JSObject *targetwrapper);
|
||||
|
||||
#ifdef __cplusplus
|
||||
JS_END_EXTERN_C
|
||||
|
||||
|
@ -1630,9 +1630,38 @@ XPCWrappedNative::ReparentWrapperIfFound(XPCCallContext& ccx,
|
||||
if(!propertyHolder || !propertyHolder->copyPropertiesFrom(ccx, flat))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
flat = JS_TransplantObject(ccx, flat, newobj);
|
||||
if(!flat)
|
||||
return NS_ERROR_FAILURE;
|
||||
JSObject *ww = wrapper->GetWrapper();
|
||||
if(ww)
|
||||
{
|
||||
JSObject *newwrapper;
|
||||
if(xpc::WrapperFactory::IsLocationObject(flat))
|
||||
{
|
||||
newwrapper = xpc::WrapperFactory::WrapLocationObject(ccx, newobj);
|
||||
if(!newwrapper)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_ASSERTION(wrapper->NeedsSOW(), "weird wrapper wrapper");
|
||||
newwrapper = xpc::WrapperFactory::WrapSOWObject(ccx, newobj);
|
||||
if(!newwrapper)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
ww = js_TransplantObjectWithWrapper(ccx, flat, ww, newobj,
|
||||
newwrapper);
|
||||
if(!ww)
|
||||
return NS_ERROR_FAILURE;
|
||||
flat = newobj;
|
||||
wrapper->SetWrapper(ww);
|
||||
}
|
||||
else
|
||||
{
|
||||
flat = JS_TransplantObject(ccx, flat, newobj);
|
||||
if(!flat)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
wrapper->mFlatJSObject = flat;
|
||||
if(cache)
|
||||
cache->SetWrapper(flat);
|
||||
|
@ -1152,6 +1152,9 @@
|
||||
-->
|
||||
<method name="close">
|
||||
<body><![CDATA[
|
||||
if (this.hidden)
|
||||
return;
|
||||
|
||||
var fm =
|
||||
Components.classes["@mozilla.org/focus-manager;1"]
|
||||
.getService(Components.interfaces.nsIFocusManager);
|
||||
|
Loading…
Reference in New Issue
Block a user