зеркало из https://github.com/mozilla/gecko-dev.git
Bug 684115 - Test what happens when chrome takes an XHR from one origin and sticks it in another origin. r=sicking
This commit is contained in:
Родитель
e50c915f3c
Коммит
f4bde3676e
|
@ -69,6 +69,7 @@ _TEST_FILES = \
|
|||
test_cyclecollector.xul \
|
||||
test_resize_move_windows.xul \
|
||||
test_popup_blocker_chrome.xul \
|
||||
test_moving_xhr.xul \
|
||||
$(NULL)
|
||||
|
||||
ifeq (WINNT,$(OS_ARCH))
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=654370
|
||||
-->
|
||||
<window title="Mozilla Bug 654370"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=654370"
|
||||
target="_blank">Mozilla Bug 654370</a>
|
||||
</body>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var firstWindow, secondWindow;
|
||||
function iframe_loaded() {
|
||||
if (!firstWindow || !secondWindow)
|
||||
return;
|
||||
var xhr = firstWindow.wrappedJSObject.createXHR();
|
||||
ok(!("expando" in xhr), "shouldn't be able to see expandos on the XHR");
|
||||
is(xhr.readyState, XMLHttpRequest.UNSENT, "can access readyState in chrome");
|
||||
secondWindow.wrappedJSObject.tryToUseXHR(xhr, ok);
|
||||
secondWindow.wrappedJSObject.tryToUseXHR(new XMLHttpRequest(), ok);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
]]></script>
|
||||
|
||||
<iframe id="one" src="http://mochi.test:8888/tests/dom/tests/mochitest/general/file_moving_xhr.html"
|
||||
onload="firstWindow = this.contentWindow; iframe_loaded()" />
|
||||
<iframe id="two" src="http://example.org/tests/dom/tests/mochitest/general/file_moving_xhr.html"
|
||||
onload="secondWindow = this.contentWindow; iframe_loaded()" />
|
||||
</window>
|
|
@ -68,6 +68,7 @@ _TEST_FILES = \
|
|||
test_framedhistoryframes.html \
|
||||
test_windowedhistoryframes.html \
|
||||
test_focusrings.xul \
|
||||
file_moving_xhr.html \
|
||||
$(NULL)
|
||||
|
||||
_CHROME_FILES = \
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function createXHR() {
|
||||
return new XMLHttpRequest();
|
||||
}
|
||||
|
||||
function tryToUseXHR(xhr, ok) {
|
||||
function expectException(op, reason) {
|
||||
try {
|
||||
var result = op();
|
||||
ok(false, "should have thrown an exception, got: " + result);
|
||||
} catch (e) {
|
||||
ok(/Permission denied/.test(e.toString()), reason);
|
||||
}
|
||||
}
|
||||
|
||||
expectException(function() { xhr.open(); }, "should not have access to any functions");
|
||||
expectException(function() { xhr.foo = "foo"; }, "should not be able to add expandos");
|
||||
expectException(function() { xhr.withCredentials = true; }, "should not be able to set attributes");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче