diff --git a/content/browser/media/webrtc_browsertest.cc b/content/browser/media/webrtc_browsertest.cc index 26793c288fd39..36f7a408e820f 100644 --- a/content/browser/media/webrtc_browsertest.cc +++ b/content/browser/media/webrtc_browsertest.cc @@ -432,4 +432,8 @@ IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserTest, CreateOfferWithOfferOptions) { MakeTypicalPeerConnectionCall("testCreateOfferOptions();"); } +IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserTest, CallInsideIframe) { + MakeTypicalPeerConnectionCall("callInsideIframe({video: true, audio:true});"); +} + } // namespace content diff --git a/content/test/data/media/peerconnection-call.html b/content/test/data/media/peerconnection-call.html index 12ae9ef8711eb..3c782bfe21c42 100644 --- a/content/test/data/media/peerconnection-call.html +++ b/content/test/data/media/peerconnection-call.html @@ -551,6 +551,33 @@ }); } + // Loads this page inside itself using an iframe, and ensures we can make a + // successful getUserMedia + peerconnection call inside the iframe. + function callInsideIframe(constraints) { + runInsideIframe(function(iframe) { + // Run a regular webrtc call inside the iframe. + iframe.contentWindow.call(constraints); + }); + } + + // Func should accept an iframe as its first argument. + function runInsideIframe(func) { + var iframe = document.createElement('iframe'); + document.body.appendChild(iframe); + iframe.onload = onIframeLoaded; + iframe.src = window.location; + + function onIframeLoaded() { + var iframe = window.document.querySelector('iframe'); + + // Propagate test success out of the iframe. + iframe.contentWindow.setAllEventsOccuredHandler( + window.parent.reportTestSuccess); + + func(iframe); + } + } + // This function is used for setting up a test that: // 1. Creates a data channel on |gFirstConnection| and sends data to // |gSecondConnection|.