2011-09-14 09:22:27 -07:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Test NPNVdocumentOrigin</title>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
2013-09-04 07:05:40 -07:00
|
|
|
<script type="application/javascript" src="utils.js"></script>
|
2011-09-14 09:22:27 -07:00
|
|
|
</head>
|
|
|
|
<body onload="runTest()">
|
|
|
|
<script class="testbody" type="application/javascript">
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
2013-09-04 07:05:40 -07:00
|
|
|
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
|
2011-09-14 09:22:27 -07:00
|
|
|
|
|
|
|
function runTest() {
|
2012-11-21 13:20:05 -08:00
|
|
|
"use strict";
|
2011-09-14 09:22:27 -07:00
|
|
|
var p1 = document.getElementById("plugin1");
|
|
|
|
var realOrigin = "http://mochi.test:8888";
|
|
|
|
|
|
|
|
// Test with no modifications
|
|
|
|
is(p1.getNPNVdocumentOrigin(), realOrigin, "Checking for expected origin.");
|
|
|
|
|
2012-03-23 15:58:18 -07:00
|
|
|
// This used to test that shadowing window.location.toString didn't confuse
|
|
|
|
// getNPNVdocumentOrigin. But now we explicitly throw when that happens. So
|
|
|
|
// just verify that we throw. There's no reason why getNPNVdocumentOrigin _would_
|
|
|
|
// be confused in this case anyway.
|
|
|
|
try {
|
|
|
|
window.location.toString = function() { return 'http://victim.rckc.at/'; }
|
|
|
|
ok(false, "Should throw when shadowing window.location.toString");
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
ok(true, "Should throw when shadowing window.location.toString");
|
|
|
|
}
|
2011-09-14 09:22:27 -07:00
|
|
|
|
|
|
|
// Create a plugin in a new window with about:blank
|
|
|
|
var newWindow = window.open("about:blank");
|
2014-03-15 14:52:58 -07:00
|
|
|
newWindow.onload = function() {
|
|
|
|
newWindow.document.writeln('<embed id="plugin2" type="application/x-test" width="200" height="200"></embed>');
|
|
|
|
var p2 = newWindow.document.getElementById("plugin2");
|
|
|
|
is(p2.getNPNVdocumentOrigin(), realOrigin, "Checking for expected origin of plugin in new about:blank window.");
|
|
|
|
newWindow.close();
|
2011-09-14 09:22:27 -07:00
|
|
|
|
2014-03-15 14:52:58 -07:00
|
|
|
SimpleTest.finish();
|
|
|
|
};
|
2011-09-14 09:22:27 -07:00
|
|
|
}
|
|
|
|
</script>
|
2013-09-04 07:05:40 -07:00
|
|
|
|
|
|
|
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
|
2011-09-14 09:22:27 -07:00
|
|
|
</body>
|
|
|
|
</html>
|