Skip to content

Commit a3dcfdd

Browse files
committed
Fix emrun test script to only call to user_pref() to set prefs (the other directives did not quite work). When building with --emrun, have exit() close the current browser window automatically. Run browser.test_emrun with --safe_firefox_profile.
1 parent 2f20ab8 commit a3dcfdd

3 files changed

Lines changed: 22 additions & 9 deletions

File tree

emrun

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,15 @@ user_pref("app.update.silent", false);
206206
user_pref("app.update.mode", 0);
207207
user_pref("app.update.service.enabled", false);
208208
// Don't check compatibility with add-ons, or (auto)update them
209-
clearPref("extensions.lastAppVersion");
210-
lockPref("plugins.hide_infobar_for_outdated_plugin", true);
211-
clearPref("plugins.update.url");
209+
user_pref("extensions.lastAppVersion", '');
210+
user_pref("plugins.hide_infobar_for_outdated_plugin", true);
211+
user_pref("plugins.update.url", '');
212212
// Disable health reporter
213-
lockPref("datareporting.healthreport.service.enabled", false);
213+
user_pref("datareporting.healthreport.service.enabled", false);
214214
// Disable crash reporter
215-
lockPref("toolkit.crashreporter.enabled", false);
216-
Components.classes["@mozilla.org/toolkit/crash-reporter;1"].getService(Components.interfaces.nsICrashReporter).submitReports = false;
215+
user_pref("toolkit.crashreporter.enabled", false);
217216
// Don't show WhatsNew on first run after every update
218-
pref("browser.startup.homepage_override.mstone","ignore");
217+
user_pref("browser.startup.homepage_override.mstone","ignore");
219218
// Don't show 'know your rights' and a bunch of other nag windows at startup
220219
user_pref("browser.rights.3.shown", true);
221220
user_pref('devtools.devedition.promo.shown', true);

src/emrun_postjs.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,26 @@ if (typeof window === "object" && (typeof ENVIRONMENT_IS_PTHREAD === 'undefined'
55
http.open("POST", "stdio.html", true);
66
http.send(msg);
77
}
8+
function postExit(msg) {
9+
var http = new XMLHttpRequest();
10+
http.onreadystatechange = function() {
11+
if (http.readyState == 4 /*DONE*/) {
12+
try {
13+
// Try closing the current browser window, since it exit()ed itself. This can shut down the browser process
14+
// and emrun does not need to kill the whole browser process.
15+
if (typeof window !== 'undefined' && window.close) window.close();
16+
} catch(e) {}
17+
}
18+
}
19+
http.open("POST", "stdio.html", true);
20+
http.send(msg);
21+
}
822
// If the address contains localhost, or we are running the page from port 6931, we can assume we're running the test runner and should post stdout logs.
923
if (document.URL.search("localhost") != -1 || document.URL.search(":6931/") != -1) {
1024
var emrun_http_sequence_number = 1;
1125
var prevPrint = Module['print'];
1226
var prevErr = Module['printErr'];
13-
function emrun_exit() { post('^exit^'+EXITSTATUS); };
27+
function emrun_exit() { postExit('^exit^'+EXITSTATUS); };
1428
Module['addOnExit'](emrun_exit);
1529
Module['print'] = function emrun_print(text) { post('^out^'+(emrun_http_sequence_number++)+'^'+encodeURIComponent(text)); prevPrint(text); }
1630
Module['printErr'] = function emrun_printErr(text) { post('^err^'+(emrun_http_sequence_number++)+'^'+encodeURIComponent(text)); prevErr(text); }

tests/test_browser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,7 @@ def test_emrun(self):
18561856
# and the browser will not close as part of the test, pinning down the cwd on Windows and it wouldn't be possible to delete it. Therefore switch away from that directory
18571857
# before launching.
18581858
os.chdir(path_from_root())
1859-
args = [PYTHON, path_from_root('emrun'), '--timeout', '30', '--verbose', '--log_stdout', os.path.join(outdir, 'stdout.txt'), '--log_stderr', os.path.join(outdir, 'stderr.txt')]
1859+
args = [PYTHON, path_from_root('emrun'), '--timeout', '30', '--safe_firefox_profile', '--verbose', '--log_stdout', os.path.join(outdir, 'stdout.txt'), '--log_stderr', os.path.join(outdir, 'stderr.txt')]
18601860
if emscripten_browser is not None:
18611861
args += ['--browser', emscripten_browser]
18621862
args += [os.path.join(outdir, 'hello_world.html'), '1', '2', '--3']

0 commit comments

Comments
 (0)