// Ensure that a stringify replacer function gets a chance to do something sane with E4X XML object var e4x = ; var expected = JSON.stringify(e4x.toXMLString()); try { var actual = JSON.stringify(e4x, function(key, value) { return ((typeof value) === "xml") ? value.toXMLString() : value; }); } catch (ud) { throw "JSON.stringify(, replacer) threw an Exception" } if (actual !== expected) { throw "Expected '" + expected + "', got '" + actual + "'"; } "success";