Skip to content

Commit

Permalink
Use addEventListener if possible. Fixes issue 6680
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Apr 22, 2014
1 parent aa55398 commit c877e93
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions javascript/selenium-core/scripts/selenium-browserbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -2349,7 +2349,11 @@ IEBrowserBot.prototype.modifySeparateTestWindowToDetectPageLoads = function(wind
var pageUnloadDetector = function() {
self.pageUnloading = true;
};
windowObject.attachEvent("onbeforeunload", pageUnloadDetector);
if (win.addEventListener) {
win.addEventListener('beforeunload', pageUnloadDetector, true);
} else {
win.attachEvent('onbeforeunload', pageUnloadDetector);

This comment has been minimized.

Copy link
@dr29bart

dr29bart Apr 22, 2014

Should be listener attached to windowObject instead of win?

}
BrowserBot.prototype.modifySeparateTestWindowToDetectPageLoads.call(this, windowObject);
};

Expand Down Expand Up @@ -2603,7 +2607,11 @@ IEBrowserBot.prototype._fireEventOnElement = function(eventType, element, client
var pageUnloadDetector = function() {
pageUnloading = true;
};
win.attachEvent("onbeforeunload", pageUnloadDetector);
if (win.addEventListener) {
win.addEventListener('beforeunload', pageUnloadDetector, true);
} else {
win.attachEvent('onbeforeunload', pageUnloadDetector);
}
this._modifyElementTarget(element);
if (element[eventType]) {
element[eventType]();
Expand Down

1 comment on commit c877e93

@barancev
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed in the next commit.

Please sign in to comment.