Skip to content

Commit

Permalink
Merge pull request web-platform-tests#114 from w3c/jgraham/document_d…
Browse files Browse the repository at this point in the history
…omain_dispatch

Don't error out trying to access cross-origin functions when document.domain got set; r=Ms2ger
  • Loading branch information
Ms2ger committed Apr 10, 2015
2 parents 87c22bb + c48d50e commit 7de19d4
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions testharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,22 @@ policies and contribution forms [3].

WindowTestEnvironment.prototype._dispatch = function(selector, callback_args, message_arg) {
this._forEach_windows(
function(w, is_same_origin) {
if (is_same_origin && selector in w) {
function(w, same_origin) {
if (same_origin) {
try {
w[selector].apply(undefined, callback_args);
} catch (e) {
if (debug) {
throw e;
var has_selector = selector in w;
} catch(e) {
// If document.domain was set at some point same_origin can be
// wrong and the above will fail.
has_selector = false;
}
if (has_selector) {
try {
w[selector].apply(undefined, callback_args);
} catch (e) {
if (debug) {
throw e;
}
}
}
}
Expand Down

0 comments on commit 7de19d4

Please sign in to comment.