Skip to content

Commit c877e93

Browse files
committed
Use addEventListener if possible. Fixes issue 6680
1 parent aa55398 commit c877e93

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Diff for: javascript/selenium-core/scripts/selenium-browserbot.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -2349,7 +2349,11 @@ IEBrowserBot.prototype.modifySeparateTestWindowToDetectPageLoads = function(wind
23492349
var pageUnloadDetector = function() {
23502350
self.pageUnloading = true;
23512351
};
2352-
windowObject.attachEvent("onbeforeunload", pageUnloadDetector);
2352+
if (win.addEventListener) {
2353+
win.addEventListener('beforeunload', pageUnloadDetector, true);
2354+
} else {
2355+
win.attachEvent('onbeforeunload', pageUnloadDetector);
2356+
}
23532357
BrowserBot.prototype.modifySeparateTestWindowToDetectPageLoads.call(this, windowObject);
23542358
};
23552359

@@ -2603,7 +2607,11 @@ IEBrowserBot.prototype._fireEventOnElement = function(eventType, element, client
26032607
var pageUnloadDetector = function() {
26042608
pageUnloading = true;
26052609
};
2606-
win.attachEvent("onbeforeunload", pageUnloadDetector);
2610+
if (win.addEventListener) {
2611+
win.addEventListener('beforeunload', pageUnloadDetector, true);
2612+
} else {
2613+
win.attachEvent('onbeforeunload', pageUnloadDetector);
2614+
}
26072615
this._modifyElementTarget(element);
26082616
if (element[eventType]) {
26092617
element[eventType]();

0 commit comments

Comments
 (0)