Merge central to inbound

This commit is contained in:
Marco Bonardo 2012-04-04 13:39:52 +02:00
commit 10bda00159
15 changed files with 138 additions and 20 deletions

View File

@ -54,7 +54,7 @@ PlacesViewBase.prototype = {
get result() this._result,
set result(val) {
if (this._result == val)
return;
return val;
if (this._result) {
this._result.removeObserver(this);
@ -1678,7 +1678,7 @@ PlacesToolbar.prototype = {
if (parent.localName == "toolbarbutton")
this._openedMenuButton = parent;
return PlacesViewBase.prototype._onPopupShowing.apply(this, arguments);
PlacesViewBase.prototype._onPopupShowing.apply(this, arguments);
},
_onPopupHidden: function PT__onPopupHidden(aEvent) {

View File

@ -1515,7 +1515,7 @@ let PlacesControllerDragHelper = {
for (let i = 0; i < dropCount; ++i) {
let flavor = this.getFirstValidFlavor(dt.mozTypesAt(i));
if (!flavor)
return false;
return;
let data = dt.mozGetDataAt(flavor, i);
let unwrapped;

View File

@ -837,8 +837,10 @@ nsAutoMutationBatch::Done()
m->mAddedNodes = addedList;
m->mPreviousSibling = mPrevSibling;
m->mNextSibling = mNextSibling;
ob->ScheduleForRun();
}
// Always schedule the observer so that transient receivers are
// removed correctly.
ob->ScheduleForRun();
}
nsDOMMutationObserver::LeaveMutationHandling();
}

View File

@ -286,6 +286,7 @@ _TEST_FILES1 = \
file_XHRDocURI.text^headers^ \
test_DOMException.html \
test_mutationobservers.html \
mutationobserver_dialog.html \
$(NULL)
_TEST_FILES2 = \

View File

@ -0,0 +1,62 @@
<html>
<head>
<title></title>
<script>
var div = document.createElement("div");
var M;
if ("MozMutationObserver" in window) {
M = window.MozMutationObserver;
} else if ("WebKitMutationObserver" in window) {
M = window.WebKitMutationObserver;
} else {
M = window.MutationObserver;
}
var didCall1 = false;
var didCall2 = false;
function testMutationObserverInDialog() {
div.innerHTML = "<span>1</span><span>2</span>";
m = new M(function(records, observer) {
opener.is(records[0].type, "childList", "Should have got childList");
opener.is(records[0].removedNodes.length, 2, "Should have got removedNodes");
opener.is(records[0].addedNodes.length, 1, "Should have got addedNodes");
observer.disconnect();
m = null;
didCall1 = true;
});
m.observe(div, { childList: true });
div.innerHTML = "<span><span>foo</span></span>";
}
function testMutationObserverInDialog2() {
div.innerHTML = "<span>1</span><span>2</span>";
m = new M(function(records, observer) {
opener.is(records[0].type, "childList", "Should have got childList");
opener.is(records[0].removedNodes.length, 2, "Should have got removedNodes");
opener.is(records[0].addedNodes.length, 1, "Should have got addedNodes");
observer.disconnect();
m = null;
didCall2 = true;
});
m.observe(div, { childList: true });
div.innerHTML = "<span><span>foo</span></span>";
}
window.addEventListener("load", testMutationObserverInDialog);
window.addEventListener("load", testMutationObserverInDialog2);
window.addEventListener("load",
function() {
opener.ok(didCall1, "Should have called 1st mutation callback");
opener.ok(didCall2, "Should have called 2nd mutation callback");
window.close();
});
</script>
<style>
</style>
</head>
<body>
<input type="button" onclick="window.close()" value="close">
</body>
</html>

View File

@ -293,6 +293,11 @@ function testChildList4() {
});
m.observe(df, { childList: true, characterData: true, characterDataOldValue: true, subtree: true });
m.observe(div, { childList: true });
// Make sure transient observers aren't leaked.
var leakTest = new MozMutationObserver(function(){});
leakTest.observe(div, { characterData: true, subtree: true });
div.insertBefore(df, s2);
s1.firstChild.data = "bar"; // This should *not* create a record.
t1.data = "Hello the whole "; // This should create a record.
@ -454,6 +459,24 @@ function testSyncXHR() {
function testSyncXHR2() {
ok(callbackHandled, "Should have called the mutation callback!");
then(testModalDialog);
}
function testModalDialog() {
var didHandleCallback = false;
div.innerHTML = "<span>1</span><span>2</span>";
m = new M(function(records, observer) {
is(records[0].type, "childList", "Should have got childList");
is(records[0].removedNodes.length, 2, "Should have got removedNodes");
is(records[0].addedNodes.length, 1, "Should have got addedNodes");
observer.disconnect();
m = null;
didHandleCallback = true;
});
m.observe(div, { childList: true });
div.innerHTML = "<span><span>foo</span></span>";
window.showModalDialog("mutationobserver_dialog.html");
ok(didHandleCallback, "Should have called the callback while showing modal dialog!");
then();
}

View File

@ -7153,6 +7153,8 @@ nsGlobalWindow::ShowModalDialog(const nsAString& aURI, nsIVariant *aArgs,
options.AppendLiteral(",scrollbars=1,centerscreen=1,resizable=0");
nsCOMPtr<nsIDOMWindow> callerWin = EnterModalState();
PRUint32 oldMicroTaskLevel = nsContentUtils::MicroTaskLevel();
nsContentUtils::SetMicroTaskLevel(0);
nsresult rv = OpenInternal(aURI, EmptyString(), options,
false, // aDialog
true, // aContentModal
@ -7162,6 +7164,7 @@ nsGlobalWindow::ShowModalDialog(const nsAString& aURI, nsIVariant *aArgs,
GetPrincipal(), // aCalleePrincipal
nsnull, // aJSCallerContext
getter_AddRefs(dlgWin));
nsContentUtils::SetMicroTaskLevel(oldMicroTaskLevel);
LeaveModalState(callerWin);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -718,7 +718,7 @@ public:
private:
friend class GeneralPattern;
friend class GlyphBufferAzure;
friend struct GlyphBufferAzure;
typedef mozilla::gfx::Matrix Matrix;
typedef mozilla::gfx::DrawTarget DrawTarget;

View File

@ -1736,6 +1736,7 @@ nsPresContext::MediaFeatureValuesChanged(bool aCallerWillRebuildStyleData)
for (PRUint32 i = 0, i_end = notifyList.Length(); i != i_end; ++i) {
if (pusher.RePush(et)) {
nsAutoMicroTask mt;
nsDOMMediaQueryList::HandleChangeData &d = notifyList[i];
d.listener->HandleChange(d.mql);
}

View File

@ -1,8 +1,9 @@
<html> <head>
<html>
<head>
<title></title>
</head>
<script type="text/javascript">
var scriptItem = "untouched";
function checkLoads() {
@ -14,6 +15,7 @@ function checkLoads() {
var style = document.defaultView.getComputedStyle(elt, "");
window.parent.isnot(style.visibility, "hidden", "Should not load bad css");
// End (parent) test.
window.parent.SimpleTest.finish();
}
@ -25,10 +27,13 @@ function checkLoads() {
<!-- Try loading from a malware css URI -->
<link rel="stylesheet" type="text/css" href="http://malware.example.com/tests/toolkit/components/url-classifier/tests/mochitest/evil.css"></link>
<!-- XXX How is this part of the test supposed to work (= be checked)? -->
<!-- Try loading a marked-as-malware css through an @import from a clean URI -->
<link rel="stylesheet" type="text/css" href="import.css"></link>
</head>
<body onload="checkLoads()">
The following should not be hidden:
<div id="styleCheck">STYLE TEST</div>
</body> </html>
</body>
</html>

View File

@ -1,4 +1,3 @@
onmessage = function() {
postMessage("loaded bad file");
}

View File

@ -1 +1,3 @@
/* malware.example.com is in the malware database.
classifierBad.css does not actually exist. */
@import url("http://malware.example.com/tests/docshell/test/classifierBad.css");

View File

@ -5,6 +5,7 @@
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="doUpdate(testUpdate);">
<p id="display"></p>
<div id="content" style="display: none">
@ -27,8 +28,6 @@ var testUpdate =
var dbService = Cc["@mozilla.org/url-classifier/dbservice;1"]
.getService(Ci.nsIUrlClassifierDBService);
var numTries = 10;
function doUpdate(update) {
var listener = {
QueryInterface: function(iid)
@ -36,17 +35,23 @@ function doUpdate(update) {
if (iid.equals(Ci.nsISupports) ||
iid.equals(Ci.nsIUrlClassifierUpdateObserver))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
updateUrlRequested: function(url) { },
streamFinished: function(status) { },
updateError: function(errorCode) {
ok(false, "Couldn't update classifier.");
// Abort test.
SimpleTest.finish();
},
updateSuccess: function(requestedTimeout) {
document.getElementById("testFrame").src = "classifierFrame.html";
SpecialPowers.pushPrefEnv(
{"set" : [["browser.safebrowsing.malware.enabled", true]]},
function loadTestFrame() {
document.getElementById("testFrame").src = "classifierFrame.html";
}
);
}
};
@ -59,9 +64,11 @@ function doUpdate(update) {
dbService.finishUpdate();
}
// Expected finish() call is in "classifierFrame.html".
SimpleTest.waitForExplicitFinish();
</script>
</pre>
<iframe id="testFrame" onload=""></iframe>
</body>

View File

@ -5,6 +5,7 @@
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="doUpdate(testUpdate);">
<p id="display"></p>
<div id="content" style="display: none">
@ -27,8 +28,6 @@ var testUpdate =
var dbService = Cc["@mozilla.org/url-classifier/dbservice;1"]
.getService(Ci.nsIUrlClassifierDBService);
var numTries = 10;
function doUpdate(update) {
var listener = {
QueryInterface: function(iid)
@ -36,17 +35,24 @@ function doUpdate(update) {
if (iid.equals(Ci.nsISupports) ||
iid.equals(Ci.nsIUrlClassifierUpdateObserver))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
updateUrlRequested: function(url) { },
streamFinished: function(status) { },
updateError: function(errorCode) {
ok(false, "Couldn't update classifier.");
// Abort test.
SimpleTest.finish();
},
updateSuccess: function(requestedTimeout) {
document.getElementById("testFrame").src = "http://example.com/tests/toolkit/components/url-classifier/tests/mochitest/workerFrame.html";
SpecialPowers.pushPrefEnv(
{"set" : [["browser.safebrowsing.malware.enabled", true]]},
function loadTestFrame() {
document.getElementById("testFrame").src =
"http://example.com/tests/toolkit/components/url-classifier/tests/mochitest/workerFrame.html";
}
);
}
};
@ -75,6 +81,7 @@ window.addEventListener("message", onmessage, false);
SimpleTest.waitForExplicitFinish();
</script>
</pre>
<iframe id="testFrame" onload=""></iframe>
</body>

View File

@ -1,10 +1,12 @@
<html> <head>
<html>
<head>
<title></title>
</head>
<script type="text/javascript">
function startCleanWorker() {
var worker = new Worker("cleanWorker.js");
worker.onmessage = function(event) {
if (event.data == "success") {
window.parent.postMessage("success:blocked importScripts('evilWorker.js')", "*");
@ -24,6 +26,7 @@ function startCleanWorker() {
function startEvilWorker() {
var worker = new Worker("evilWorker.js");
worker.onmessage = function(event) {
window.parent.postMessage("failure:failed to block evilWorker.js", "*");
startCleanWorker();
@ -39,5 +42,8 @@ function startEvilWorker() {
</script>
</head>
<body onload="startEvilWorker()">
</body> </html>
</body>
</html>