Пример #1
0
TEST_F(BaseAudioContextTest, AutoplayMetrics_NodeStartNoGesture) {
  HistogramTester histogramTester;
  createChildFrame();
  childDocument().settings()->setMediaPlaybackRequiresUserGesture(true);

  BaseAudioContext* audioContext =
      BaseAudioContext::create(childDocument(), ASSERT_NO_EXCEPTION);
  audioContext->maybeRecordStartAttempt();
  recordAutoplayStatus(audioContext);

  histogramTester.expectBucketCount(kCrossOriginMetric,
                                    AutoplayStatus::AutoplayStatusFailed, 1);
  histogramTester.expectTotalCount(kCrossOriginMetric, 1);
}
Пример #2
0
TEST_F(BaseAudioContextTest, AutoplayMetrics_NodeStartGestureThenSucces) {
  HistogramTester histogramTester;
  createChildFrame();
  childDocument().settings()->setMediaPlaybackRequiresUserGesture(true);

  ScriptState::Scope scope(getScriptStateFrom(childDocument()));

  BaseAudioContext* audioContext =
      BaseAudioContext::create(childDocument(), ASSERT_NO_EXCEPTION);

  UserGestureIndicator userGestureScope(DocumentUserGestureToken::create(
      &childDocument(), UserGestureToken::NewGesture));
  audioContext->maybeRecordStartAttempt();
  audioContext->resumeContext(getScriptStateFrom(childDocument()));
  rejectPendingResolvers(audioContext);
  recordAutoplayStatus(audioContext);

  histogramTester.expectBucketCount(kCrossOriginMetric,
                                    AutoplayStatus::AutoplayStatusSucceeded, 1);
  histogramTester.expectTotalCount(kCrossOriginMetric, 1);
}