Skip to content

Commit c7a2305

Browse files
committed
address code review comments
1 parent 49c2c0b commit c7a2305

3 files changed

Lines changed: 34 additions & 21 deletions

File tree

spec/env/common.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,23 @@ HandlebarsTestBench.prototype.toCompileTo = function (expectedOutputAsString) {
175175

176176
HandlebarsTestBench.prototype.toThrow = function (errorLike, errMsgMatcher) {
177177
var self = this;
178-
if (errMsgMatcher) {
179-
expect(function () {
180-
self._compileAndExecute();
181-
}).toThrowError(errMsgMatcher);
182-
} else {
183-
expect(function () {
184-
self._compileAndExecute();
185-
}).toThrow();
178+
var caught;
179+
try {
180+
self._compileAndExecute();
181+
} catch (e) {
182+
caught = e;
183+
}
184+
185+
expect(caught).toBeDefined();
186+
187+
if (typeof errorLike === 'function') {
188+
expect(caught).toBeInstanceOf(errorLike);
189+
if (errMsgMatcher) {
190+
expect(caught.message).toMatch(errMsgMatcher);
191+
}
192+
} else if (errorLike) {
193+
// errorLike is a string or regex message matcher (single-argument form)
194+
expect(caught.message).toMatch(errorLike);
186195
}
187196
};
188197

spec/security.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,23 @@ describe('security issues', function () {
109109
});
110110

111111
describe('GH-1563', function () {
112-
it('should not allow to access constructor after overriding via __defineGetter__', function () {
113-
if ({}.__defineGetter__ == null || {}.__lookupGetter__ == null) {
114-
return; // Browser does not support this exploit anyway
112+
var browserSupportsExploit =
113+
{}.__defineGetter__ != null && {}.__lookupGetter__ != null;
114+
115+
it.skipIf(!browserSupportsExploit)(
116+
'should not allow to access constructor after overriding via __defineGetter__',
117+
function () {
118+
expectTemplate(
119+
'{{__defineGetter__ "undefined" valueOf }}' +
120+
'{{#with __lookupGetter__ }}' +
121+
'{{__defineGetter__ "propertyIsEnumerable" (this.bind (this.bind 1)) }}' +
122+
'{{constructor.name}}' +
123+
'{{/with}}'
124+
)
125+
.withInput({})
126+
.toThrow(/Missing helper: "__defineGetter__"/);
115127
}
116-
expectTemplate(
117-
'{{__defineGetter__ "undefined" valueOf }}' +
118-
'{{#with __lookupGetter__ }}' +
119-
'{{__defineGetter__ "propertyIsEnumerable" (this.bind (this.bind 1)) }}' +
120-
'{{constructor.name}}' +
121-
'{{/with}}'
122-
)
123-
.withInput({})
124-
.toThrow(/Missing helper: "__defineGetter__"/);
125-
});
128+
);
126129
});
127130

128131
describe('GH-1595: dangerous properties', function () {

vitest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default defineConfig({
1818
name: 'tasks',
1919
include: ['tasks/tests/*.test.js'],
2020
globals: true,
21+
pool: 'forks',
2122
},
2223
},
2324
{

0 commit comments

Comments
 (0)