tor-browser

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

constraints-data.https.html (1744B)


      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 passing data to a child layout works correctly." />
      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 const DATA = {
     32  str: 'hello',
     33  num: 42,
     34  obj: {str2: 'world'},
     35 };
     36 
     37 registerLayout('parent', class {
     38  async intrinsicSizes() {}
     39  async layout([child], edges, constraints, styleMap) {
     40 
     41    const childFragment = await child.layoutNextFragment({data: DATA});
     42 
     43    // If the child's block-size is 100 the structured cloning worked.
     44    if (childFragment.blockSize === 100) {
     45      return {autoBlockSize: 100, childFragments: [childFragment]};
     46    }
     47 
     48    return {autoBlockSize: 0, childFragments: [childFragment]};
     49  }
     50 });
     51 
     52 registerLayout('child', class {
     53  async intrinsicSizes() {}
     54  async layout(children, edges, constraints, styleMap) {
     55    // Use JSON.stringify to make sure the structured cloning worked.
     56    if (constraints.data !== DATA &&
     57        JSON.stringify(constraints.data) === JSON.stringify(DATA)) {
     58      return {autoBlockSize: 100};
     59    }
     60 
     61    return {autoBlockSize: 0};
     62  }
     63 });
     64 </script>
     65 
     66 <script>
     67 importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, document.getElementById('code').textContent);
     68 </script>
     69 </html>