blob: 57debbc7537d5a9f77563da026e44c9cd5320212 [file] [log] [blame]
<html>
<head>
<script>
function debug(str)
{
var li = document.createElement('li');
li.appendChild(document.createTextNode(str));
document.getElementById('console').appendChild(li)
}
function checkLocationObject(l)
{
if (!l) {
debug('could not access top.location');
return false;
}
try {
if (l.href) {
debug('could access top.location.href');
return false;
}
} catch (e) {
return true;
}
return true;
}
function getPlugin()
{
return document.querySelector('embed');
}
function runTest()
{
var numErrors = 0;
// Try accessing childFrame.location using NPN_Evaluate
var l = getPlugin().testExecuteScript('top.location')
if (!checkLocationObject(l))
numErrors++;
// Try getting childFrame.location.href using NPN_Evaluate
try {
var href = getPlugin().testExecuteScript('top.location.href');
} catch (e) {
debug(e);
}
if (href) {
debug("could access top.location.href")
numErrors++;
}
// Try accessing childFrame.location using NPN_GetProperty
var l = getPlugin().testGetProperty('top', 'location');
if (!checkLocationObject(l))
numErrors++;
try {
var href = getPlugin().testGetProperty('top', 'location', 'href');
} catch (e) {
debug(e);
}
if (href) {
debug("could access top.location.href")
numErrors++;
}
// Try accessing top.document using NPN_EVALUATE
try {
var documentViaTestEvaluate = getPlugin().testExecuteScript('top.document')
} catch (e) {
debug(e);
};
if (documentViaTestEvaluate) {
debug('could access top.document');
numErrors++;
}
// Try accessing top.document using NPN_GetProperty
try {
var documentViaTestGetProperty = getPlugin().testGetProperty('top', 'document')
} catch (e) {
debug(e);
};
if (documentViaTestGetProperty) {
debug('could access top.document');
numErrors++;
}
if (numErrors == 0)
document.getElementById('result').innerHTML = 'SUCCESS';
}
</script>
</head>
<body onload="runTest()">
<embed type="application/x-blink-deprecated-test-plugin"></embed>
<div>This tests that plugins can access objects in other frames as allowed by the security model enforced in WebCore.</div>
<ul id="console">
</ul>
<div id="result">FAILURE</div>
</body>
</html>