tor-browser

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

imperative-slot-initial-fallback.html (1306B)


      1 <!DOCTYPE html>
      2 <title>Imperative Slot API: intial fallback should be correctly set up</title>
      3 <link rel="author" href="mailto:xiaochengh@chromium.org">
      4 <link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1292292">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 
      8 <div>
      9  <div id="host1"></div>
     10  <div id="host2"></div>
     11 </div>
     12 
     13 <script>
     14 test(() => {
     15  const host = document.getElementById('host1');
     16  const shadow = host.attachShadow({mode: 'open', slotAssignment: 'manual'});
     17  shadow.innerHTML = '<slot>fallback</slot>';
     18  const slot = shadow.firstChild;
     19  assert_array_equals(slot.assignedNodes(), []);
     20  assert_greater_than(host.offsetHeight, 0, 'Fallback content should be rendered');
     21 }, 'Unassigned imperative slot can render text node as the initial fallback');
     22 
     23 test(() => {
     24  const host = document.getElementById('host2');
     25  const shadow = host.attachShadow({mode: 'open', slotAssignment: 'manual'});
     26  shadow.innerHTML = '<slot><span>fallback</span></slot>';
     27  const slot = shadow.firstChild;
     28  assert_array_equals(slot.assignedNodes(), []);
     29  assert_greater_than(host.offsetHeight, 0, 'Fallback content should be rendered');
     30 }, 'Unassigned imperative slot can render element as the initial fallback');
     31 </script>