tor-browser

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

constraints-data-sab-failure.https.html (1686B)


      1 <!DOCTYPE html>
      2 <html class=reftest-wait>
      3 <link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#dom-layoutconstraints-data">
      4 <link rel="match" href="green-square-ref.html">
      5 <meta name="assert" content="This test checks that a SharedArrayBuffer can't be passed to a child layout." />
      6 <style>
      7 .test {
      8  background: red;
      9  width: 100px;
     10 }
     11 
     12 @supports (display: layout(parent)) {
     13  .test {
     14    display: layout(parent);
     15    background: green;
     16  }
     17 
     18  .child {
     19    display: layout(child);
     20  }
     21 }
     22 </style>
     23 <script src="/common/reftest-wait.js"></script>
     24 <script src="/common/worklet-reftest.js"></script>
     25 
     26 <div class="test">
     27  <div class="child"></div>
     28 </div>
     29 
     30 <script id="code" type="text/worklet">
     31 registerLayout('parent', class {
     32  async intrinsicSizes() {}
     33  async layout([child], edges, constraints, styleMap) {
     34    let childFragment = null;
     35 
     36    try {
     37      childFragment = await child.layoutNextFragment({
     38        // See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
     39        data: { sab: new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer }
     40      });
     41    } catch(e) {
     42      // Success! The structured cloning algorithm should have thrown an error.
     43      childFragment = await child.layoutNextFragment({});
     44      return {autoBlockSize: 100, childFragments: [childFragment]};
     45    }
     46 
     47    return {autoBlockSize: 0, childFragments: [childFragment]};
     48  }
     49 });
     50 
     51 registerLayout('child', class {
     52  async intrinsicSizes() {}
     53  async layout() {
     54    return {autoBlockSize: 0};
     55  }
     56 });
     57 </script>
     58 
     59 <script>
     60 importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, document.getElementById('code').textContent);
     61 </script>
     62 </html>