TEST_F(BaseAudioContextTest, AutoplayMetrics_CallResumeNoGesture) { HistogramTester histogramTester; createChildFrame(); childDocument().settings()->setMediaPlaybackRequiresUserGesture(true); ScriptState::Scope scope(getScriptStateFrom(childDocument())); BaseAudioContext* audioContext = BaseAudioContext::create(childDocument(), ASSERT_NO_EXCEPTION); audioContext->resumeContext(getScriptStateFrom(childDocument())); rejectPendingResolvers(audioContext); recordAutoplayStatus(audioContext); histogramTester.expectBucketCount(kCrossOriginMetric, AutoplayStatus::AutoplayStatusFailed, 1); histogramTester.expectTotalCount(kCrossOriginMetric, 1); }
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); }