⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 279487 in webkit


Ignore:
Timestamp:
Jul 1, 2021, 5:08:31 PM (5 years ago)
Author:
eric.carlson@apple.com
Message:

WebAudio auto-play policy should come from top document
​https://bugs.webkit.org/show_bug.cgi?id=227593
rdar://76920375

Reviewed by Chris Dumez.

Source/WebCore:

Tests: media/auto-play-video-in-about-blank-iframe.html

media/auto-play-web-audio-in-about-blank-iframe.html

  • Modules/webaudio/AudioContext.cpp:

(WebCore::AudioContext::constructCommon): Get auto-play policy from document()->topDocument().

  • testing/Internals.cpp:

(WebCore::Internals::setDocumentAutoplayPolicy): New method to test auto-play policy.

  • testing/Internals.h:
  • testing/Internals.idl:

LayoutTests:

  • media/auto-play-video-in-about-blank-iframe-expected.txt: Added.
  • media/auto-play-video-in-about-blank-iframe.html: Added.
  • media/auto-play-web-audio-in-about-blank-iframe-expected.txt: Added.
  • media/auto-play-web-audio-in-about-blank-iframe.html: Added.
  • media/video-test.js:

(waitForEventWithTimeout): Return event.

Location:
trunk
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r279485 r279487  
     12021-07-01  Eric Carlson  <eric.carlson@apple.com>
     2
     3        WebAudio auto-play policy should come from top document
     4        https://bugs.webkit.org/show_bug.cgi?id=227593
     5        rdar://76920375
     6
     7        Reviewed by Chris Dumez.
     8
     9        * media/auto-play-video-in-about-blank-iframe-expected.txt: Added.
     10        * media/auto-play-video-in-about-blank-iframe.html: Added.
     11        * media/auto-play-web-audio-in-about-blank-iframe-expected.txt: Added.
     12        * media/auto-play-web-audio-in-about-blank-iframe.html: Added.
     13
     14        * media/video-test.js:
     15        (waitForEventWithTimeout): Return event.
     16
    1172021-07-01  Cameron McCormack  <heycam@apple.com>
    218
  • trunk/LayoutTests/media/video-test.js

    r263835 r279487  
    214214       
    215215        consoleWrite(`EVENT(${result.type})`);
    216         Promise.resolve(result);
     216        return Promise.resolve(result);
    217217    });
    218218}
  • trunk/Source/WebCore/ChangeLog

    r279483 r279487  
     12021-07-01  Eric Carlson  <eric.carlson@apple.com>
     2
     3        WebAudio auto-play policy should come from top document
     4        https://bugs.webkit.org/show_bug.cgi?id=227593
     5        rdar://76920375
     6
     7        Reviewed by Chris Dumez.
     8
     9        Tests: media/auto-play-video-in-about-blank-iframe.html
     10               media/auto-play-web-audio-in-about-blank-iframe.html
     11
     12        * Modules/webaudio/AudioContext.cpp:
     13        (WebCore::AudioContext::constructCommon): Get auto-play policy from document()->topDocument().
     14
     15        * testing/Internals.cpp:
     16        (WebCore::Internals::setDocumentAutoplayPolicy): New method to test auto-play policy.
     17        * testing/Internals.h:
     18        * testing/Internals.idl:
     19
    1202021-07-01  Youenn Fablet  <youenn@apple.com>
    221
  • trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp

    r278788 r279487  
    136136{
    137137    ASSERT(document());
    138     if (document()->audioPlaybackRequiresUserGesture())
     138    if (document()->topDocument().audioPlaybackRequiresUserGesture())
    139139        addBehaviorRestriction(RequireUserGestureForAudioStartRestriction);
    140140    else
  • trunk/Source/WebCore/testing/Internals.cpp

    r279463 r279487  
    11/*
    22 * Copyright (C) 2012 Google Inc. All rights reserved.
    3  * Copyright (C) 2013-2020 Apple Inc. All rights reserved.
     3 * Copyright (C) 2013-2021 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
    … …  
    64196419}
    64206420
     6421ExceptionOr<void> Internals::setDocumentAutoplayPolicy(Document& document, Internals::AutoplayPolicy policy)
     6422{
     6423    static_assert(static_cast<uint8_t>(WebCore::AutoplayPolicy::Default) == static_cast<uint8_t>(Internals::AutoplayPolicy::Default), "Internals::Default != WebCore::Default");
     6424    static_assert(static_cast<uint8_t>(WebCore::AutoplayPolicy::Allow) == static_cast<uint8_t>(Internals::AutoplayPolicy::Allow), "Internals::Allow != WebCore::Allow");
     6425    static_assert(static_cast<uint8_t>(WebCore::AutoplayPolicy::AllowWithoutSound) == static_cast<uint8_t>(Internals::AutoplayPolicy::AllowWithoutSound), "Internals::AllowWithoutSound != WebCore::AllowWithoutSound");
     6426    static_assert(static_cast<uint8_t>(WebCore::AutoplayPolicy::Deny) == static_cast<uint8_t>(Internals::AutoplayPolicy::Deny), "Internals::Deny != WebCore::Deny");
     6427
     6428    auto* loader = document.loader();
     6429    if (!loader)
     6430        return Exception { InvalidStateError };
     6431
     6432    loader->setAutoplayPolicy(static_cast<WebCore::AutoplayPolicy>(policy));
     6433
     6434    return { };
     6435}
    64216436
    64226437} // namespace WebCore
  • trunk/Source/WebCore/testing/Internals.h

    r279463 r279487  
    11/*
    22 * Copyright (C) 2012 Google Inc. All rights reserved.
    3  * Copyright (C) 2013-2020 Apple Inc. All rights reserved.
     3 * Copyright (C) 2013-2021 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
    … …  
    11701170    String dumpStyleResolvers();
    11711171
     1172    enum class AutoplayPolicy : uint8_t {
     1173        Default,
     1174        Allow,
     1175        AllowWithoutSound,
     1176        Deny,
     1177    };
     1178    ExceptionOr<void> setDocumentAutoplayPolicy(Document&, AutoplayPolicy);
     1179
    11721180private:
    11731181    explicit Internals(Document&);
  • trunk/Source/WebCore/testing/Internals.idl

    r279463 r279487  
    11/*
    22 * Copyright (C) 2012 Google Inc. All rights reserved.
    3  * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
     3 * Copyright (C) 2013-2021 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
    … …  
    104104    "GPUStatusFailure",
    105105    "Timeout"
     106};
     107
     108enum AutoplayPolicy {
     109    "Default",
     110    "Allow",
     111    "AllowWithoutSound",
     112    "Deny"
    106113};
    107114
    … …  
    10391046
    10401047    DOMString dumpStyleResolvers();
    1041 };
     1048
     1049    undefined setDocumentAutoplayPolicy(Document document, AutoplayPolicy policy);
     1050};
Note: See TracChangeset for help on using the changeset viewer.