Unreviewed test fix after r240243
[WebKit-https.git] / JSTests / stress / scope-operation-cache-global-property-even-if-it-fails.js
1 function shouldThrow(func, errorMessage) {
2     var errorThrown = false;
3     var error = null;
4     try {
5         func();
6     } catch (e) {
7         errorThrown = true;
8         error = e;
9     }
10     if (!errorThrown)
11         throw new Error('not thrown');
12     if (String(error) !== errorMessage)
13         throw new Error(`bad error: ${String(error)}`);
14 }
15 noInline(shouldThrow);
16
17 function foo() {
18     bar = 4;
19 }
20 Object.preventExtensions(this);
21 foo();
22 $.evalScript('const bar = 3;');
23 shouldThrow(() => foo(), `TypeError: Attempted to assign to readonly property.`);