Bug 1230027 - Stop burnCPOWInSandbox from being GC'd during tests. r?yoric
Since no one is holding a reference to the burnCPOWInSandbox function
in the child process, it might get GC'd during the test. Binding it to
the global object should keep the function alive long enough for the
test to call it via CPOW.
--- a/toolkit/components/perfmonitoring/tests/browser/head.js
+++ b/toolkit/components/perfmonitoring/tests/browser/head.js
@@ -88,25 +88,29 @@ CPUBurner.frameScript = function() {
sendAsyncMessage(topic, {});
} catch (ex) {
dump(`This is the content attempting to burn CPU: error ${ex}\n`);
dump(`${ex.stack}\n`);
}
});
}
+ // Bind the function to the global context or it might be GC'd during test
+ // causing failures (bug 1230027)
+ this.burnCPOWInSandbox = function(addonId) {
+ try {
+ burnCPUInSandbox(addonId);
+ } catch (ex) {
+ dump(`This is the addon attempting to burn CPOW: error ${ex}\n`);
+ dump(`${ex.stack}\n`);
+ }
+ }
+
sendAsyncMessage("test-performance-watcher:cpow-init", {}, {
- burnCPOWInSandbox: function(addonId) {
- try {
- burnCPUInSandbox(addonId);
- } catch (ex) {
- dump(`This is the addon attempting to burn CPOW: error ${ex}\n`);
- dump(`${ex.stack}\n`);
- }
- }
+ burnCPOWInSandbox: this.burnCPOWInSandbox
});
} catch (ex) {
Cu.reportError("This is the addon: error " + ex);
Cu.reportError(ex.stack);
}
};