mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 894990 - Expose mochitest data file URL via SimpleTest.getTestFileURL. r=jmaher
This commit is contained in:
parent
fb70fd5030
commit
a6cb2f6e9a
@ -15,6 +15,7 @@ _TEST_FILES = \
|
||||
test_SpecialPowersPushPermissions.html \
|
||||
test_SpecialPowersPushPrefEnv.html \
|
||||
file_SpecialPowersFrame1.html \
|
||||
test_SimpleTestGetTestFileURL.html \
|
||||
test_bug816847.html \
|
||||
test_sanity_cleanup.html \
|
||||
test_sanity_cleanup2.html \
|
||||
|
@ -279,6 +279,25 @@ SimpleTest.todo = function(condition, name, diag) {
|
||||
SimpleTest._tests.push(test);
|
||||
};
|
||||
|
||||
/*
|
||||
* Returns the absolute URL to a test data file from where tests
|
||||
* are served. i.e. the file doesn't necessarely exists where tests
|
||||
* are executed.
|
||||
* (For b2g and android, mochitest are executed on the device, while
|
||||
* all mochitest html (and others) files are served from the test runner
|
||||
* slave)
|
||||
*/
|
||||
SimpleTest.getTestFileURL = function(path) {
|
||||
var lastSlashIdx = path.lastIndexOf("/") + 1;
|
||||
var filename = path.substr(lastSlashIdx);
|
||||
var location = window.location;
|
||||
// Remove mochitest html file name from the path
|
||||
var remotePath = location.pathname.replace(/\/[^\/]+?$/,"");
|
||||
var url = location.origin +
|
||||
remotePath + "/" + path;
|
||||
return url;
|
||||
};
|
||||
|
||||
SimpleTest._getCurrentTestURL = function() {
|
||||
return parentRunner && parentRunner.currentTestURL ||
|
||||
typeof gTestPath == "string" && gTestPath ||
|
||||
|
20
testing/mochitest/tests/test_SimpleTestGetTestFileURL.html
Normal file
20
testing/mochitest/tests/test_SimpleTestGetTestFileURL.html
Normal file
@ -0,0 +1,20 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for SpecialPowers extension</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var filename = "MyTestDataFile.txt";
|
||||
var url = SimpleTest.getTestFileURL(filename);
|
||||
is(url, document.location.href.replace(/test_SimpleTestGetTestFileURL\.html.*/, filename));
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user