Skip to content

Commit

Permalink
Merge pull request web-platform-tests#154 from gsnedders/cross_origin…
Browse files Browse the repository at this point in the history
…_assert_safety

Fix web-platform-tests#59: stop cross-origin objects from throwing in harness when creating failed assertion messages
  • Loading branch information
zcorpan committed Jan 25, 2016
2 parents 72dd676 + e8f43ce commit 64a6399
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions testharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,10 +697,17 @@ policies and contribution forms [3].
// instanceof doesn't work if the node is from another window (like an
// iframe's contentWindow):
// http://www.w3.org/Bugs/Public/show_bug.cgi?id=12295
if ("nodeType" in object &&
"nodeName" in object &&
"nodeValue" in object &&
"childNodes" in object) {
try {
var has_node_properties = ("nodeType" in object &&
"nodeName" in object &&
"nodeValue" in object &&
"childNodes" in object);
} catch (e) {
// We're probably cross-origin, which means we aren't a node
return false;
}

if (has_node_properties) {
try {
object.nodeType;
} catch (e) {
Expand Down Expand Up @@ -818,7 +825,12 @@ policies and contribution forms [3].

/* falls through */
default:
return typeof val + ' "' + truncate(String(val), 60) + '"';
try {
return typeof val + ' "' + truncate(String(val), 60) + '"';
} catch(e) {
return ("[stringifying object threw " + String(e) +
" with type " + String(typeof e) + "]");
}
}
}
expose(format_value, "format_value");
Expand Down

0 comments on commit 64a6399

Please sign in to comment.