tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

body-put-error.js (1311B)


      1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-runtime-semantics-forin-div-ofbodyevaluation-lhs-stmt-iterator-lhskind-labelset
      5 description: >
      6  If the left-hand side is not a lexical binding and the assignment produces
      7  an error, the iterator should be closed and the error forwarded to the
      8  runtime.
      9 info: |
     10  ...
     11  If destructuring is false, then
     12    If lhsRef is an abrupt completion, then
     13      Let status be lhsRef.
     14    Else if lhsKind is lexicalBinding, then
     15      Let status be InitializeReferencedBinding(lhsRef, nextValue).
     16    Else,
     17      Let status be PutValue(lhsRef, nextValue).
     18  ...
     19 
     20 features: [for-of, Symbol.iterator]
     21 ---*/
     22 
     23 var callCount = 0;
     24 var iterationCount = 0;
     25 var iterable = {};
     26 var x = {
     27  set attr(_) {
     28    throw new Test262Error();
     29  }
     30 };
     31 
     32 iterable[Symbol.iterator] = function() {
     33  return {
     34    next: function() {
     35      return { done: false, value: 0 };
     36    },
     37    return: function() {
     38      callCount += 1;
     39    }
     40  }
     41 };
     42 
     43 assert.throws(Test262Error, function() {
     44  for (x.attr of iterable) {
     45    iterationCount += 1;
     46  }
     47 });
     48 
     49 assert.sameValue(iterationCount, 0, 'The loop body is not evaluated');
     50 assert.sameValue(callCount, 1, 'Iterator is closed');
     51 
     52 reportCompare(0, 0);