зеркало из https://github.com/mozilla/pjs.git
Bug 383511: Support multi-domain tests in mochitest. r=sayrer
This commit is contained in:
Родитель
f7d9a5d64a
Коммит
aa8b6ea8ff
|
@ -42,7 +42,9 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS += dom-level1-core \
|
||||
DIRS += \
|
||||
dom-level0 \
|
||||
dom-level1-core \
|
||||
dom-level2-core \
|
||||
ajax \
|
||||
bugs \
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2007
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
relativesrcdir = dom/tests/mochitest/dom-level0
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_TEST_FILES = \
|
||||
test_crossdomainprops.html \
|
||||
file_crossdomainprops_inner.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
$(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
var myVar = 10;
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
inner
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for Cross domain access to properties</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body onload="runTest()">
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<iframe name="frame1" src="file_crossdomainprops_inner.html"></iframe>
|
||||
<iframe name="frame2" src="http://localhost:8889/tests/dom/tests/mochitest/dom-level0/file_crossdomainprops_inner.html"></iframe>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTest() {
|
||||
ok(frames.frame1.myVar == 10, "access same domain inner window variable");
|
||||
var otherDomainVar = null;
|
||||
try {
|
||||
otherDomainVar = frames.frame2.myVar;
|
||||
}
|
||||
catch (e) {
|
||||
otherDomainVar = -1;
|
||||
}
|
||||
ok(otherDomainVar == -1, "access other domain inner window variable");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -42,7 +42,9 @@
|
|||
// sucks.
|
||||
|
||||
const SERVER_PORT = 8888;
|
||||
const SERVER_PORT_OTHER_DOMAIN = 8889;
|
||||
var server; // for use in the shutdown handler, if necessary
|
||||
var otherDomainServer; // for use in the shutdown handler, if necessary
|
||||
|
||||
//
|
||||
// HTML GENERATION
|
||||
|
@ -136,12 +138,16 @@ function runServer()
|
|||
serverBasePath.append("mochitest");
|
||||
server = new nsHttpServer();
|
||||
server.registerDirectory("/", serverBasePath);
|
||||
otherDomainServer = new nsHttpServer();
|
||||
otherDomainServer.registerDirectory("/", serverBasePath);
|
||||
|
||||
if (environment["CLOSE_WHEN_DONE"])
|
||||
server.registerPathHandler("/server/shutdown", serverShutdown);
|
||||
|
||||
server.setIndexHandler(defaultDirHandler);
|
||||
server.start(SERVER_PORT);
|
||||
otherDomainServer.setIndexHandler(defaultDirHandler);
|
||||
otherDomainServer.start(SERVER_PORT_OTHER_DOMAIN);
|
||||
|
||||
// touch a file in the profile directory to indicate we're alive
|
||||
var foStream = Cc["@mozilla.org/network/file-output-stream;1"]
|
||||
|
@ -195,6 +201,7 @@ function serverShutdown(metadata, response)
|
|||
|
||||
// Note: this doesn't disrupt the current request.
|
||||
server.stop();
|
||||
otherDomainServer.stop();
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Загрузка…
Ссылка в новой задаче