tor-browser

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

offsetParent-body-and-html.html (1794B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>CSSOM View: offsetParent</title>
      4 <link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
      5 <link rel="help" href="https://drafts.csswg.org/cssom-view-1/#dom-htmlelement-offsetparent">
      6 <link rel="help" href="https://github.com/w3c/csswg-drafts/issues/12834">
      7 <meta name="assert" content="Checks offsetParent on <body> and <html> elements.">
      8 <style>html, body { position: relative }</style>
      9 
     10 <body>
     11 <script src="/resources/testharness.js"></script>
     12 <script src="/resources/testharnessreport.js"></script>
     13 <script>
     14 const root = document.documentElement;
     15 const other_html = document.createElement("html");
     16 const other_body_1 = document.createElement("body");
     17 const other_body_2 = document.createElement("body");
     18 const other_body_3 = document.createElement("body");
     19 other_body_2.append(other_body_3);
     20 other_html.append(other_body_2);
     21 root.append(other_html, other_body_1);
     22 
     23 test(() => {
     24  assert_equals(root.offsetParent, null);
     25 }, "The offsetParent of the root element is null");
     26 
     27 test(() => {
     28  assert_equals(other_html.offsetParent, root);
     29 }, "The offsetParent of a <html> element which is not the root is computed normally");
     30 
     31 test(() => {
     32  assert_equals(document.body.offsetParent, null);
     33 }, "The offsetParent of 'the body element' is null");
     34 
     35 test(() => {
     36  assert_equals(other_body_1.offsetParent, null);
     37 }, "The offsetParent of a <body> element which has a previous <body> sibling is also null");
     38 
     39 test(() => {
     40  assert_equals(other_body_2.offsetParent, null);
     41 }, "The offsetParent of a <body> element which is a child of a non-root <html> is also null");
     42 
     43 test(() => {
     44  assert_equals(other_body_3.offsetParent, null);
     45 }, "The offsetParent of a <body> element which is a child of a non-<html> is also null");
     46 </script>
     47 </body>