Commit 489af6e8 authored by Thomas Wisniewski's avatar Thomas Wisniewski Committed by twisniewski@mozilla.com
Browse files

Bug 1850998 - add an intervention for chaturbate.com on Android so fullscreen...

Bug 1850998 - add an intervention for chaturbate.com on Android so fullscreen is actually fullscreen; r=denschub,webcompat-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D250340
parent 2ad2df76
Loading
Loading
Loading
Loading
+17 −0
Changes for browser/extensions/webcompat/data/interventions.json: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -1542,6 +1542,23 @@
      }
    ]
  },
  "1850998": {
    "label": "chaturbate.com",
    "bugs": {
      "1850998": {
        "issue": "user-interface-frustration",
        "matches": ["*://*.chaturbate.com/*"]
      }
    },
    "interventions": [
      {
        "platforms": ["android"],
        "content_scripts": {
          "js": ["bug1850998-chaturbate.com.js"]
        }
      }
    ]
  },
  "1855014": {
    "label": "eksiseyler.com",
    "bugs": {
+27 −0
Changes for browser/extensions/webcompat/injections/js/bug1850998-chaturbate.com.js: 27 added lines, 0 removed lines.
Original line number Diff line number Diff line
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

/**
 * Bug 1850998 - going "fullscreen" does not hide the address bar
 *
 * The site avoids calling requestFullScreen on Firefox. We can address
 * this by pretending to not be Firefox for that specific check.
 */

/* globals exportFunction */

const proto = window.wrappedJSObject.RegExp.prototype;
const descriptor = Object.getOwnPropertyDescriptor(proto, "test");
const { value } = descriptor;

descriptor.value = exportFunction(function (test) {
  if (this.source === "UCBrowser|Firefox|SamsungBrowser") {
    return false;
  }
  return value.call(this, test);
}, window);

Object.defineProperty(proto, "test", descriptor);
+49 −0
Changes for testing/webcompat/interventions/tests/test_1850998_chaturbate_com.py: 49 added lines, 0 removed lines.
Original line number Diff line number Diff line
import pytest

URL = "https://chaturbate.com/"
AGREE_CSS = "#close_entrance_terms"
FIRST_ROOM_CSS = "a.room_thumbnail_container[href]"
FS_CSS = "[data-testid='mobile-fullscreen-button']"
VID_CSS = ".videoPlayerDiv"


async def is_requestFullscreen_called(client):
    await client.navigate(URL)
    client.await_css(AGREE_CSS, is_displayed=True).click()
    client.await_css(FIRST_ROOM_CSS, is_displayed=True).click()
    vid = client.await_css(VID_CSS, is_displayed=True)
    fs = client.await_css(FS_CSS, is_displayed=True)
    height = client.execute_script(
        """
      Element.prototype.requestFullscreen = () => window.fs_pressed = true
      return arguments[0].getBoundingClientRect().height;
    """,
        vid,
    )
    fs.click()
    return client.execute_async_script(
        """
      const [vidSel, height, done] = arguments;
      setInterval(() => {
        if (document.querySelector(vidSel)?.getBoundingClientRect().height > height) {
          done(window.fs_pressed);
        }
      }, 100);
    """,
        VID_CSS,
        height,
    )


@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
    assert await is_requestFullscreen_called(client)


@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
    assert not await is_requestFullscreen_called(client)