Skip to content

Commit 8870f0c

Browse files
committed
Tentative fix for XHR initialization with no js_frame present.
1 parent f4dbed3 commit 8870f0c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/gmail.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,15 +1062,25 @@ var Gmail_ = function(localJQuery) {
10621062
if (!api.tracker.xhr_init) {
10631063
api.tracker.xhr_init = true;
10641064
var js_frame = null;
1065+
10651066
if (top.document.getElementById("js_frame")){
10661067
js_frame = top.document.getElementById("js_frame");
10671068
} else if (window.opener) {
10681069
js_frame = window.opener.top.document.getElementById("js_frame");
10691070
}
10701071
if (!js_frame){
1071-
throw "Cannot register the xhr watcher as mail.google.com is not fully loaded yet. Please wrap your code in `gmail.observe.on(\"load\")`";
1072+
if (window.opener) {
1073+
js_frame = window.opener.top;
1074+
} else {
1075+
js_frame = top;
1076+
}
1077+
}
1078+
var win;
1079+
if (js_frame.contentDocument) {
1080+
win = js_frame.contentDocument.defaultView;
1081+
} else {
1082+
win = js_frame;
10721083
}
1073-
var win = js_frame.contentDocument.defaultView;
10741084

10751085
if (!win.gjs_XMLHttpRequest_open) {
10761086
win.gjs_XMLHttpRequest_open = win.XMLHttpRequest.prototype.open;

0 commit comments

Comments
 (0)