Skip to content

Commit

Permalink
Fixed #1222: Update PhantomJS globals to 1.7 API
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Kovalyov <anton@kovalyov.net>
  • Loading branch information
kara-ryli authored and valueof committed Aug 15, 2013
1 parent 6c5a085 commit 27bd241
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -4570,7 +4570,7 @@ var JSHINT = (function () {
directives();

if (state.directive["use strict"]) {
if (!state.option.globalstrict && !state.option.node) {
if (!state.option.globalstrict && !(state.option.node || state.option.phantom)) {
warning("W097", state.tokens.prev);
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,9 @@ exports.node = {
exports.phantom = {
phantom : true,
require : true,
WebPage : true
WebPage : true,
console : true, // in examples, but undocumented
exports : true // v1.7+
};

exports.rhino = {
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/envs.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,10 +685,26 @@ exports.phantom = function (test) {
'phantom',
'require',
'WebPage',
'console',
'exports'
];

globalsImplied(test, globals);
globalsKnown(test, globals, { phantom: true });

// Phantom environment assumes `globalstrict`
var globalStrict = [
'"use strict";',
"function test() { return; }",
].join('\n');

TestRun(test)
.addError(1, 'Use the function form of "use strict".')
.test(globalStrict, { es3: true, strict: true });

TestRun(test)
.test(globalStrict, { es3: true, phantom: true, strict: true });


test.done();
};

0 comments on commit 27bd241

Please sign in to comment.