From 83d60ea279257c8b3029a6a7e9e8fdec6328a2f9 Mon Sep 17 00:00:00 2001 From: Sami Jaktholm Date: Tue, 22 Dec 2015 20:15:17 +0200 Subject: [PATCH] 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. --HG-- extra : transplant_source : %60%97%A0%8D%1D%B6%D1G%A0h%2B%11%A9%05%C1%13%25%10cc --- .../perfmonitoring/tests/browser/head.js | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/toolkit/components/perfmonitoring/tests/browser/head.js b/toolkit/components/perfmonitoring/tests/browser/head.js index 6780eadf3835..f060a17ab192 100644 --- a/toolkit/components/perfmonitoring/tests/browser/head.js +++ b/toolkit/components/perfmonitoring/tests/browser/head.js @@ -93,15 +93,19 @@ CPUBurner.frameScript = function() { }); } - 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`); - } + // 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: this.burnCPOWInSandbox }); } catch (ex) {