Skip to content

Commit

Permalink
Restore the native JSON.parse (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
macbre committed May 30, 2015
1 parent 53a3d6d commit 84e8af9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/phantomas.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,11 @@ phantomas.prototype = {

// called when all HTTP requests are completed
report: function() {
// restote the native JSON.parse (just in case, see #482)
this.page.evaluate(function() {
JSON.parse = window.__phantomas && window.__phantomas.JSON.parse;
});

this.emitInternal('report'); // @desc the report is about to be generated

var time = Date.now() - this.start;
Expand Down
6 changes: 6 additions & 0 deletions core/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
// create a scope
var phantomas = (scope.__phantomas = scope.__phantomas || {});

// keep the original JSON functions (#482)
phantomas.JSON = {
parse: JSON.parse,
stringify: JSON.stringify
};

// NodeRunner
var nodeRunner = function() {
// "Beep, Beep"
Expand Down
1 change: 1 addition & 0 deletions test/integration-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,4 @@
metrics:
globalVariables: 3
globalVariablesFalsy: 1
jsErrors: 0

0 comments on commit 84e8af9

Please sign in to comment.