зеркало из https://github.com/mozilla/pjs.git
Bug 544097 changing mochitests to use mochi.test instead of localhost for windows mobile refactoring p=jmaher, r=ted,dwitte, sayrer, waldo, ctalbert
This commit is contained in:
Родитель
acb95ebf6d
Коммит
3498e2898b
|
@ -63,7 +63,25 @@ if __name__ == '__main__':
|
|||
t.setDaemon(True) # don't hang on exit
|
||||
t.start()
|
||||
|
||||
automation.initializeProfile(PROFILE_DIRECTORY)
|
||||
# since this requires localhost, we cannot use automation.initializeProfile
|
||||
try:
|
||||
os.makedirs(PROFILE_DIRECTORY)
|
||||
except:
|
||||
pass # leaf directory already exists
|
||||
|
||||
prefsFile = open(PROFILE_DIRECTORY + "/" + "user.js", "w")
|
||||
prefsFile.write('user_pref("dom.popup_maximum", -1);')
|
||||
prefsFile.write('user_pref("dom.disable_open_during_load", false);')
|
||||
prefsFile.write('user_pref("browser.shell.checkDefaultBrowser", false);')
|
||||
prefsFile.write('user_pref("browser.warnOnQuit", false);')
|
||||
prefsFile.write('user_pref("dom.allow_scripts_to_close_windows", true);')
|
||||
prefsFile.write('user_pref("capability.principal.codebase.p0.granted", \
|
||||
"UniversalXPConnect UniversalBrowserRead UniversalBrowserWrite \
|
||||
UniversalPreferencesRead UniversalPreferencesWrite UniversalFileRead");\n')
|
||||
prefsFile.write('user_pref("capability.principal.codebase.p0.id", "http://localhost:%s");\n' % PORT)
|
||||
prefsFile.write('user_pref("capability.principal.codebase.p0.subjectName", "");\n')
|
||||
prefsFile.close()
|
||||
|
||||
browserEnv = automation.environment()
|
||||
browserEnv["XPCOM_DEBUG_BREAK"] = "warn"
|
||||
|
||||
|
|
|
@ -14,14 +14,19 @@ function handleRequest(request, response)
|
|||
if ("main" in query) {
|
||||
var xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
|
||||
.createInstance(Components.interfaces.nsIXMLHttpRequest);
|
||||
|
||||
//serve the main page with a CSP header!
|
||||
// -- anything served from 'self' (localhost:8888) will be allowed,
|
||||
// -- anything served from 'self' (mochi.test:8888) will be allowed,
|
||||
// -- anything served from other hosts (example.com:80) will be blocked.
|
||||
// -- XHR tests are set up in the file_CSP_main.js file which is sourced.
|
||||
response.setHeader("X-Content-Security-Policy",
|
||||
"allow 'self'",
|
||||
false);
|
||||
xhr.open("GET", "http://localhost:8888/tests/content/base/test/file_CSP_evalscript_main.html", false);
|
||||
var proxy = "127.0.0.1";
|
||||
if ("proxy" in query) {
|
||||
proxy = query["proxy"];
|
||||
}
|
||||
xhr.open("GET", "http://" + proxy + "/tests/content/base/test/file_CSP_evalscript_main.html", false);
|
||||
xhr.send(null);
|
||||
if(xhr.status == 200) {
|
||||
response.write(xhr.responseText);
|
||||
|
|
|
@ -52,9 +52,20 @@ var checkTestResults = function() {
|
|||
// set up and go
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
//need to allow for arbitrary network servers, when PAC doesn't work
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"].
|
||||
getService(Components.interfaces.nsIIOService);
|
||||
var pps = Components.classes["@mozilla.org/network/protocol-proxy-service;1"].
|
||||
getService();
|
||||
|
||||
var uri = ios.newURI("http://example.com", null, null);
|
||||
var pi = pps.resolve(uri, 0);
|
||||
var mozproxy = pi.host + ":" + pi.port;
|
||||
|
||||
// save this for last so that our listeners are registered.
|
||||
// ... this loads the testbed of good and bad requests.
|
||||
document.getElementById('cspframe').src = 'file_CSP_evalscript.sjs?main';
|
||||
document.getElementById('cspframe').src = 'file_CSP_evalscript.sjs?main&proxy=' + mozproxy;
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
|
Загрузка…
Ссылка в новой задаче