Skip to content

Instantly share code, notes, and snippets.

@daleharvey
Last active May 26, 2019 09:32
Show Gist options
  • Save daleharvey/b6396ef3a21820e59ab9a63a67298b15 to your computer and use it in GitHub Desktop.
Save daleharvey/b6396ef3a21820e59ab9a63a67298b15 to your computer and use it in GitHub Desktop.
[task 2019-05-25T22:24:10.841Z] 22:24:10 INFO - Entering test bound testSlowLoadingPage
[task 2019-05-25T22:24:10.842Z] 22:24:10 INFO - TEST-PASS | browser/base/content/test/permissions/browser_autoplay_blocked.js | test started -
[task 2019-05-25T22:24:10.845Z] 22:24:10 INFO - TEST-PASS | browser/base/content/test/permissions/browser_autoplay_blocked.js | PAGE LOADING: about:home -
[task 2019-05-25T22:24:10.850Z] 22:24:10 INFO - TEST-PASS | browser/base/content/test/permissions/browser_autoplay_blocked.js | PAGE LOADING: SLOW_AUTOPLAY_PAGE -
[task 2019-05-25T22:24:10.853Z] 22:24:10 INFO - Buffered messages logged at 22:23:33
[task 2019-05-25T22:24:10.855Z] 22:24:10 INFO - Console message: [JavaScript Warning: "Autoplay is only allowed when approved by the user, the site is activated by the user, or media is muted." {file: "https://example.com/browser/browser/base/content/test/permissions/browser_autoplay_blocked_slow.sjs" line: 0}]
[task 2019-05-25T22:24:10.857Z] 22:24:10 INFO - Buffered messages finished
[task 2019-05-25T22:24:10.860Z] 22:24:10 INFO - TEST-UNEXPECTED-FAIL | browser/base/content/test/permissions/browser_autoplay_blocked.js | Test timed out -
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
const DELAY_MS = "500";
const AUTOPLAY_HTML = `<!DOCTYPE HTML>
<html dir="ltr" xml:lang="en-US" lang="en-US">
<head>
<meta charset="utf8">
</head>
<body>
<audio autoplay="autoplay" >
<source src="audio.ogg" />
</audio>
<script>setTimeout(() => { document.location.href = '#foo'; }, 250);</script>
</body>
</html>`;
function handleRequest(req, resp) {
resp.processAsync();
resp.setHeader("Cache-Control", "no-cache", false);
resp.setHeader("Content-Type", "text/html;charset=utf-8", false);
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
resp.write(AUTOPLAY_HTML);
timer.init(() => {
resp.write("");
resp.finish();
}, DELAY_MS, Ci.nsITimer.TYPE_ONE_SHOT);
}
add_task(async function testSlowLoadingPage() {
ok(true, 'test started');
Services.prefs.setIntPref(AUTOPLAY_PREF, Ci.nsIAutoplay.BLOCKED);
ok(true, 'PAGE LOADING: about:home');
let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:home");
ok(true, 'PAGE LOADING: SLOW_AUTOPLAY_PAGE');
let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, SLOW_AUTOPLAY_PAGE);
ok(true, 'WAITING FOR ICON');
await blockedIconShown();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment