mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
115 lines
4.1 KiB
HTML
115 lines
4.1 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=405924
|
|
-->
|
|
<head>
|
|
<title>Test for Bug 405924</title>
|
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="text/javascript" src="prompt_common.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
</head>
|
|
<body>
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=405924">
|
|
Mozilla Bug 405924</a>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
<iframe id="iframe"></iframe>
|
|
</div>
|
|
<pre id="test">
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
/** Test for Bug 405924 **/
|
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|
var isDone = false;
|
|
|
|
// This is called from prompt_common when the error dialog shows up
|
|
function handleDialog(doc) {
|
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|
// Verify the error message is correct - the string (places) is not
|
|
// translated
|
|
dump("BUG_405924: We caught the alert error dialog!\n");
|
|
var dialog = doc.getElementById("commonDialog");
|
|
var desc = doc.getElementById("info.body");
|
|
var errmsg = desc.childNodes[0].data;
|
|
ok(errmsg.match(/\(place\)/), "Check for the correct error message");
|
|
|
|
// Clear the dialog
|
|
dialog.acceptDialog();
|
|
// Declared in prompt_common and used to show that we flashed the error
|
|
// message
|
|
didDialog = true;
|
|
}
|
|
|
|
// Called when the iFrame or the Window is reloaded
|
|
function onloadHandler() {
|
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|
ok(didDialog, "Error Dialog was shown");
|
|
|
|
if (isDone) {
|
|
// Finish up
|
|
SimpleTest.finish();
|
|
}
|
|
}
|
|
|
|
function useXMLHttpRequest(aType, aUri, aValueToSend) {
|
|
var req = new XMLHttpRequest();
|
|
|
|
req.onreadystatechange=function() {
|
|
// If this completes, it's an error
|
|
if (req.readyState == 4)
|
|
ok(false, "XMLHttpRequest to Places URI succeeded: security breach");
|
|
}
|
|
|
|
try {
|
|
req.open(aType, aUri, false);
|
|
req.send(aValueToSend);
|
|
ok(false, "XMLHttpRequest did not throw error - security breach");
|
|
} catch (ex) {
|
|
// Unfortunately it's an unknown error, so no use in trying to see
|
|
// what it was
|
|
ok(true, "XMLHttpRequest to Places URI threw error: expected behavior");
|
|
}
|
|
}
|
|
|
|
// First try requesting a places URI from javascript - fails silently
|
|
useXMLHttpRequest("GET",
|
|
"place:folder=BOOKMARKS_MENU&folder=UNFILED_BOOKMARKS&folder=TOOLBAR&sort=12&excludeQueries=1&queryType=1",
|
|
null);
|
|
|
|
// Second, try posting to a places URI just for grins
|
|
useXMLHttpRequest("POST",
|
|
"place:folder=UNFILED_BOOKMARKS&sort=12&queryType=1",
|
|
"SELECT%20*%20FROM%20moz_places");
|
|
|
|
// Third test, use the iFrame and try loading directly
|
|
var iframe = document.getElementById("iframe");
|
|
iframe.onload = onloadHandler;
|
|
startCallbackTimer();
|
|
try {
|
|
iframe.src = "place:sort=14&type=6&maxResults=10";
|
|
ok(false, "Iframe set to places URI did not throw - security breach");
|
|
} catch (ex) {
|
|
ok(true, "Iframe set to places URI threw exception: expected behavior");
|
|
}
|
|
|
|
// And finally, go for broke
|
|
window.onload = onloadHandler;
|
|
isDone = true;
|
|
startCallbackTimer();
|
|
try {
|
|
window.content.document.location.href = "place:sort=8&maxResults=10";
|
|
ok(false, "Window set to places URI did not throw - security breach");
|
|
} catch (ex) {
|
|
ok(true, "Window set to places URI threw exception: expected behavior");
|
|
}
|
|
|
|
// We finish up in the onloadHandler
|
|
SimpleTest.waitForExplicitFinish();
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|
|
|