tor-browser

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

await-using-outer-inner-using-bindings.js (1187B)


      1 // |reftest| shell-option(--enable-explicit-resource-management) skip-if(!(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('explicit-resource-management'))||!xulRuntime.shell) async -- explicit-resource-management is not enabled unconditionally, requires shell-options
      2 // Copyright (C) 2023 Ron Buckton. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-runtime-semantics-fordeclarationbindinginstantiation
      7 description: >
      8    outer await using binding unchanged by for-loop await using binding
      9 flags: [async]
     10 includes: [asyncHelpers.js]
     11 features: [explicit-resource-management]
     12 ---*/
     13 
     14 asyncTest(async function () {
     15  const outer_x = { [Symbol.dispose]() {} };
     16  const outer_y = { [Symbol.dispose]() {} };
     17  const inner_x = { [Symbol.dispose]() {} };
     18  const inner_y = { [Symbol.dispose]() {} };
     19 
     20  {
     21    await using x = outer_x;
     22    await using y = outer_y;
     23    var i = 0;
     24 
     25    for (await using x = inner_x; i < 1; i++) {
     26      await using y = inner_y;
     27 
     28      assert.sameValue(x, inner_x);
     29      assert.sameValue(y, inner_y);
     30    }
     31    assert.sameValue(x, outer_x);
     32    assert.sameValue(y, outer_y);
     33  }
     34 });