tor-browser

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

range-restore-oninput-onchange-event.https.html (2067B)


      1 <!DOCTYPE html>
      2 <link rel=author href="mailto:jarhar@chromium.org">
      3 <link rel=help href="https://github.com/whatwg/html/pull/7283">
      4 <link rel=help href="https://bugs.chromium.org/p/chromium/issues/detail?id=1266468">
      5 
      6 <link rel=author href="mailto:gulukesh@gmail.com">
      7 <link rel=help href="https://bugs.chromium.org/p/chromium/issues/detail?id=1131234">
      8 
      9 <script src="/resources/testharness.js"></script>
     10 <script src="/resources/testharnessreport.js"></script>
     11 
     12 <body>
     13 <script>
     14 function runTest(type, testValue) {
     15  promise_test(async () => {
     16    const w = window.open(`resources/${type}-restore-events.html`);
     17    // Unfortunately, navigating |w| doesn't fire load events in this parent
     18    // window, so we have to make the child window manually tell this parent
     19    // window when it has loaded.
     20    await new Promise(resolve => window.loadResolver = resolve);
     21    // We can't navigate the child window until after a setTimeout.
     22    await new Promise(resolve => step_timeout(resolve, 0));
     23 
     24    assert_not_equals(
     25      w.document.querySelector('input').value,
     26      testValue,
     27      `Test shouldn't start with the new value already in the input.`);
     28    w.document.querySelector('input').value = testValue;
     29 
     30    w.location.href = 'resources/loadresolver.html';
     31    await new Promise(resolve => window.loadResolver = resolve);
     32 
     33    w.history.back();
     34    await new Promise(resolve => window.loadResolver = resolve);
     35    // The value doesn't get restored until after a setTimeout.
     36    await new Promise(resolve => step_timeout(resolve, 0));
     37 
     38    assert_equals(w.document.querySelector('input').value, testValue,
     39      'The input should have its value restored.');
     40 
     41    assert_false(w.seeninput || false,
     42      'The input event should not have been fired after restoration.');
     43    assert_false(w.seenchange || false,
     44      'The change event should not have been fired after restoration.');
     45 
     46    w.close();
     47  }, `Verifies that form restoration does not fire input or change events for <input type=${type}>.`);
     48 }
     49 
     50 runTest('range', '8');
     51 runTest('text', 'foo');
     52 </script>