Skip to content

Commit

Permalink
eval to get global, not Function
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Mar 13, 2016
1 parent 320dd02 commit 943cf9b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ var ses;
"use strict";

// Still valid. Won't be after startSES is called.
var global = (new Function('return this;'))();
var global = (1,eval)('this');

if (typeof ses !== 'undefined' && ses.okToLoad && !ses.okToLoad()) {
// already too broken, so give up
Expand Down
2 changes: 1 addition & 1 deletion hookupSESPlus.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"use strict";

// Still valid. Won't be after startSES is called.
var global = (new Function('return this;'))();
var global = (1,eval)('this');

try {
if (!ses.okToLoad()) {
Expand Down
2 changes: 1 addition & 1 deletion repairES5.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ var ses;
"use strict";

// Still valid. Won't be after startSES is called.
var global = (new Function('return this;'))();
var global = (1,eval)('this');

var logger = ses.logger;
var EarlyStringMap = ses._EarlyStringMap;
Expand Down
6 changes: 4 additions & 2 deletions ses-usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ses.maxAcceptableSeverityName = 'NEW_SYMPTOM';
(${function() {
"use strict";
console.log('a ', global === (new Function('return this;')()));
console.log('a ', global === (1,eval)('this'));
}}());
`;

Expand All @@ -42,6 +42,7 @@ var testCases = `
console.log(cajaVM.confine('x + y', {x: 3, y: 4}));
}}());
cajaVM.confine
`;

var sesFiles = [
Expand Down Expand Up @@ -78,4 +79,5 @@ var global = {};
global.console = console;
global.global = global;
var context = VM.createContext(global);
VM.runInContext(initSES, context);
var ret = VM.runInContext(initSES, context);
console.log('ret: ', ret);

0 comments on commit 943cf9b

Please sign in to comment.