Bug 894953 - Don't leak onDOMConentLoaded event handlers, r=mdas

This commit is contained in:
Jonathan Griffin 2013-07-17 15:13:09 -07:00
Родитель d002636799
Коммит d22b9e593b
2 изменённых файлов: 7 добавлений и 5 удалений

Просмотреть файл

@ -97,7 +97,7 @@ class TestNavigate(MarionetteTestCase):
self.assertTrue(self.marionette.find_element("id", "mozLink"))
self.fail("Should have thrown a MarionetteException")
except MarionetteException as e:
self.assertEqual(str(e), "Error loading page, timed out")
self.assertTrue("Error loading page, timed out" in str(e))
except Exception as inst:
import traceback
print traceback.format_exc()

Просмотреть файл

@ -1093,24 +1093,26 @@ function goUrl(msg) {
let start = new Date().getTime();
let end = null;
function checkLoad(){
checkTimer.cancel();
end = new Date().getTime();
let errorRegex = /about:.+(error)|(blocked)\?/;
let elapse = end - start;
if (msg.json.pageTimeout == null || elapse <= msg.json.pageTimeout){
if (curWindow.document.readyState == "complete"){
removeEventListener("DOMContentLoaded", onDOMContentLoaded, false);
sendOk(command_id);
checkTimer.cancel();
}
else if (curWindow.document.readyState == "interactive" && errorRegex.exec(curWindow.document.baseURI)){
removeEventListener("DOMContentLoaded", onDOMContentLoaded, false);
sendError("Error loading page", 13, null, command_id);
}
else{
checkTimer.cancel();
checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT);
}
}
else{
sendError("Error loading page, timed out", 21, null, command_id);
removeEventListener("DOMContentLoaded", onDOMContentLoaded, false);
sendError("Error loading page, timed out (checkLoad)", 21, null, command_id);
}
}
// Prevent DOMContentLoaded events from frames from invoking this code,
@ -1124,8 +1126,8 @@ function goUrl(msg) {
};
function timerFunc(){
sendError("Error loading page, timed out", 21, null, command_id);
removeEventListener("DOMContentLoaded", onDOMContentLoaded, false);
sendError("Error loading page, timed out (onDOMContentLoaded)", 21, null, command_id);
}
if (msg.json.pageTimeout != null){
checkTimer.initWithCallback(timerFunc, msg.json.pageTimeout, Ci.nsITimer.TYPE_ONE_SHOT);