tor-browser

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

test_1896349_vivaldi_com.py (998B)


      1 import pytest
      2 
      3 URL = "https://vivaldi.com/blog/technology/vivaldi-wont-allow-a-machine-to-lie-to-you/"
      4 TEXT_CSS = "article header h1"
      5 
      6 
      7 async def is_selection_different(client):
      8    text = client.await_css(TEXT_CSS, is_displayed=True)
      9    assert text
     10 
     11    before = text.screenshot()
     12 
     13    client.execute_script(
     14        """
     15        const text = arguments[0];
     16        const range = document.createRange();
     17        range.setStart(text, 0);
     18        range.setEnd(text, 1);
     19        const selection = window.getSelection();
     20        selection.removeAllRanges();
     21        selection.addRange(range);
     22    """,
     23        text,
     24    )
     25 
     26    return before != text.screenshot()
     27 
     28 
     29 @pytest.mark.asyncio
     30 @pytest.mark.with_interventions
     31 async def test_enabled(client):
     32    await client.navigate(URL)
     33    assert await is_selection_different(client)
     34 
     35 
     36 @pytest.mark.asyncio
     37 @pytest.mark.without_interventions
     38 async def test_disabled(client):
     39    await client.navigate(URL)
     40    assert not await is_selection_different(client)