Merge mozilla-central to mozilla-inbound

This commit is contained in:
Ed Morley 2012-12-04 15:38:27 +00:00
Родитель 7732931b5f 4857665ccf
Коммит c187e71ad5
3 изменённых файлов: 122 добавлений и 2 удалений

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

@ -724,7 +724,9 @@ let SessionStoreInternal = {
}
else if (this._restoreLastWindow && aWindow.toolbar.visible &&
this._closedWindows.length
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
&& !PrivateBrowsingUtils.isWindowPrivate(aWindow)
#else
&& !this._inPrivateBrowsing
#endif
) {

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

@ -35,7 +35,6 @@ MOCHITEST_CHROME_FILES = test_bug343416.xul \
test_bug429954.xul \
window_bug429954.xul \
test_bug444800.xul \
test_bug462106.xul \
$(filter disabled-for-intermittent-timeouts--bug-561929, test_bug478536.xul) \
window_bug478536.xul \
test_bug517396.xul \
@ -59,6 +58,12 @@ MOCHITEST_CHROME_FILES = test_bug343416.xul \
test_bug760802.xul \
$(NULL)
ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
MOCHITEST_CHROME_FILES += test_bug462106_perwindow.xul
else
MOCHITEST_CHROME_FILES += test_bug462106.xul
endif
# test_bug413277.html mac-only based on 604789, 605178
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)

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

@ -0,0 +1,113 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=462106
-->
<window title="Mozilla Bug 462106"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="initAndRunTests()">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
</body>
<!-- test code goes here -->
<script class="testbody" type="application/javascript">
<![CDATA[
/** Test for Bug 462106 **/
const Cc = Components.classes;
const Ci = Components.interfaces;
function copy(str, doc) {
if (!doc) {
doc = document;
}
Cc["@mozilla.org/widget/clipboardhelper;1"].
getService(Ci.nsIClipboardHelper).
copyString(str, doc);
}
function getLoadContext() {
return window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsILoadContext);
}
function paste() {
let trans = Cc["@mozilla.org/widget/transferable;1"].
createInstance(Ci.nsITransferable);
trans.init(getLoadContext());
trans.addDataFlavor("text/unicode");
let clip = Cc["@mozilla.org/widget/clipboard;1"].
getService(Ci.nsIClipboard);
clip.getData(trans, Ci.nsIClipboard.kGlobalClipboard);
let str = {}, length = {};
try {
trans.getTransferData("text/unicode", str, length);
} catch (e) {
str = null;
}
if (str) {
str = str.value.QueryInterface(Ci.nsISupportsString);
if (str)
str = str.data.substring(0, length.value / 2);
}
return str;
}
function testOnWindow(options, callback) {
var mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
let win = mainWindow.OpenBrowserWindow(options);
win.addEventListener("load", function onLoad() {
win.removeEventListener("load", onLoad, false);
callback(win);
}, false);
};
function initAndRunTests() {
SimpleTest.waitForExplicitFinish();
const data = "random number: " + Math.random();
copy(data);
is(data, paste(), "Data successfully copied before entering the private browsing mode");
testOnWindow({private: true}, function (aPrivateWindow) {
aPrivateWindow.close();
// the data should still be on the clipboard because it was copied before
// entering the private browsing mode
is(data, paste(), "Copied data persisted after leaving the private browsing mode");
const data2 = "another random number: " + Math.random();
testOnWindow({private: true}, function (aPrivateWindow) {
copy(data2, aPrivateWindow.document); // copy the data inside the private browsing mode
setTimeout(function() { // without this, the test fails sporadically
// the data should be on the clipboard inside the private browsing mode
is(data2, paste(), "Data successfully copied inside the private browsing mode");
aPrivateWindow.close();
// the data should no longer be on the clipboard at this stage
isnot(data2, paste(), "Data no longer available after leaving the private browsing mode");
SimpleTest.finish();
}, 0);
});
});
}
]]>
</script>
</window>