зеркало из https://github.com/mozilla/pjs.git
Backed out changeset a5587354082a
This commit is contained in:
Родитель
2726c50012
Коммит
616d02e21f
|
@ -138,7 +138,6 @@ NS_CP_ContentTypeName(PRUint32 contentType)
|
|||
CASE_RETURN( TYPE_OBJECT_SUBREQUEST );
|
||||
CASE_RETURN( TYPE_DTD );
|
||||
CASE_RETURN( TYPE_FONT );
|
||||
CASE_RETURN( TYPE_MEDIA );
|
||||
default:
|
||||
return "<Unknown Type>";
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ interface nsIDOMNode;
|
|||
* by launching a dialog to prompt the user for something).
|
||||
*/
|
||||
|
||||
[scriptable,uuid(344f9cb0-9a17-44c5-ab96-ee707884266c)]
|
||||
[scriptable,uuid(58cf9dca-40b3-6211-a508-7351f437a53e)]
|
||||
interface nsIContentPolicy : nsISupports
|
||||
{
|
||||
const unsigned long TYPE_OTHER = 1;
|
||||
|
@ -131,11 +131,6 @@ interface nsIContentPolicy : nsISupports
|
|||
*/
|
||||
const unsigned long TYPE_FONT = 14;
|
||||
|
||||
/**
|
||||
* Indicates a video or audio load.
|
||||
*/
|
||||
const unsigned long TYPE_MEDIA = 15;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
|
|
|
@ -138,10 +138,6 @@ public:
|
|||
// events can be fired.
|
||||
void ChangeReadyState(nsMediaReadyState aState);
|
||||
|
||||
// Gets the pref media.enforce_same_site_origin, which determines
|
||||
// if we should check Access Controls, or allow cross domain loads.
|
||||
PRBool ShouldCheckAllowOrigin();
|
||||
|
||||
// Is the media element potentially playing as defined by the HTML 5 specification.
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/#potentially-playing
|
||||
PRBool IsPotentiallyPlaying() const;
|
||||
|
|
|
@ -71,11 +71,6 @@
|
|||
#include "nsICategoryManager.h"
|
||||
#include "nsCommaSeparatedTokenizer.h"
|
||||
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsContentErrors.h"
|
||||
#include "nsCrossSiteListenerProxy.h"
|
||||
|
||||
#ifdef MOZ_OGG
|
||||
#include "nsOggDecoder.h"
|
||||
#endif
|
||||
|
@ -221,7 +216,7 @@ PRBool nsHTMLMediaElement::AbortExistingLoads()
|
|||
|
||||
if (mBegun) {
|
||||
mBegun = PR_FALSE;
|
||||
mError = new nsHTMLMediaError(nsIDOMHTMLMediaError::MEDIA_ERR_ABORTED);
|
||||
mError = new nsHTMLMediaError(nsHTMLMediaError::MEDIA_ERR_ABORTED);
|
||||
DispatchProgressEvent(NS_LITERAL_STRING("abort"));
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
@ -260,20 +255,6 @@ NS_IMETHODIMP nsHTMLMediaElement::Load()
|
|||
mChannel = nsnull;
|
||||
}
|
||||
|
||||
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
|
||||
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_MEDIA,
|
||||
uri,
|
||||
NodePrincipal(),
|
||||
this,
|
||||
EmptyCString(), // mime type
|
||||
nsnull, // extra
|
||||
&shouldLoad,
|
||||
nsContentUtils::GetContentPolicy(),
|
||||
nsContentUtils::GetSecurityManager());
|
||||
if (NS_FAILED(rv) || NS_CP_REJECTED(shouldLoad)) {
|
||||
return NS_ERROR_CONTENT_BLOCKED;
|
||||
}
|
||||
|
||||
rv = NS_NewChannel(getter_AddRefs(mChannel),
|
||||
uri,
|
||||
nsnull,
|
||||
|
@ -285,27 +266,8 @@ NS_IMETHODIMP nsHTMLMediaElement::Load()
|
|||
// The listener holds a strong reference to us. This creates a reference
|
||||
// cycle which is manually broken in the listener's OnStartRequest method
|
||||
// after it is finished with the element.
|
||||
nsCOMPtr<nsIStreamListener> loadListener = new nsMediaLoadListener(this);
|
||||
NS_ENSURE_TRUE(loadListener, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsCOMPtr<nsIStreamListener> listener;
|
||||
if (ShouldCheckAllowOrigin()) {
|
||||
listener = new nsCrossSiteListenerProxy(loadListener,
|
||||
NodePrincipal(),
|
||||
mChannel,
|
||||
PR_FALSE,
|
||||
&rv);
|
||||
NS_ENSURE_TRUE(listener, NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
rv = nsContentUtils::GetSecurityManager()->
|
||||
CheckLoadURIWithPrincipal(NodePrincipal(),
|
||||
uri,
|
||||
nsIScriptSecurityManager::STANDARD);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
listener = loadListener;
|
||||
}
|
||||
nsCOMPtr<nsIStreamListener> listener = new nsMediaLoadListener(this);
|
||||
NS_ENSURE_TRUE(listener, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> hc = do_QueryInterface(mChannel);
|
||||
if (hc) {
|
||||
|
@ -988,7 +950,7 @@ void nsHTMLMediaElement::ResourceLoaded()
|
|||
|
||||
void nsHTMLMediaElement::NetworkError()
|
||||
{
|
||||
mError = new nsHTMLMediaError(nsIDOMHTMLMediaError::MEDIA_ERR_NETWORK);
|
||||
mError = new nsHTMLMediaError(nsHTMLMediaError::MEDIA_ERR_NETWORK);
|
||||
mBegun = PR_FALSE;
|
||||
DispatchProgressEvent(NS_LITERAL_STRING("error"));
|
||||
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_EMPTY;
|
||||
|
@ -1019,12 +981,6 @@ void nsHTMLMediaElement::SeekCompleted()
|
|||
DispatchAsyncSimpleEvent(NS_LITERAL_STRING("seeked"));
|
||||
}
|
||||
|
||||
PRBool nsHTMLMediaElement::ShouldCheckAllowOrigin()
|
||||
{
|
||||
return nsContentUtils::GetBoolPref("media.enforce_same_site_origin",
|
||||
PR_TRUE);
|
||||
}
|
||||
|
||||
void nsHTMLMediaElement::ChangeReadyState(nsMediaReadyState aState)
|
||||
{
|
||||
// Handle raising of "waiting" event during seek (see 4.8.10.9)
|
||||
|
|
|
@ -174,10 +174,6 @@ class nsMediaDecoder : public nsIObserver
|
|||
// thread by the owning object before that object disposes of this object.
|
||||
virtual void Shutdown();
|
||||
|
||||
// Returns a weak reference to the media element we're decoding for,
|
||||
// if it's available.
|
||||
nsHTMLMediaElement* GetMediaElement();
|
||||
|
||||
protected:
|
||||
|
||||
// Start timer to update download progress information.
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#include "nsIChannel.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "prlock.h"
|
||||
|
||||
class nsMediaDecoder;
|
||||
|
|
|
@ -41,8 +41,6 @@
|
|||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsChannelToPipeListener.h"
|
||||
#include "nsICachingChannel.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsHTMLMediaElement.h"
|
||||
|
||||
#define HTTP_OK_CODE 200
|
||||
#define HTTP_PARTIAL_RESPONSE_CODE 206
|
||||
|
@ -98,19 +96,6 @@ nsresult nsChannelToPipeListener::GetInputStream(nsIInputStream** aStream)
|
|||
|
||||
nsresult nsChannelToPipeListener::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
|
||||
{
|
||||
nsHTMLMediaElement* element = mDecoder->GetMediaElement();
|
||||
NS_ENSURE_TRUE(element, NS_ERROR_FAILURE);
|
||||
if (element->ShouldCheckAllowOrigin()) {
|
||||
// If the request was cancelled by nsCrossSiteListenerProxy due to failing
|
||||
// the Access Control check, send an error through to the media element.
|
||||
nsresult status;
|
||||
nsresult rv = aRequest->GetStatus(&status);
|
||||
if (NS_FAILED(rv) || status == NS_ERROR_DOM_BAD_URI) {
|
||||
mDecoder->NetworkError();
|
||||
return NS_ERROR_DOM_BAD_URI;
|
||||
}
|
||||
}
|
||||
|
||||
mIntervalStart = PR_IntervalNow();
|
||||
mIntervalEnd = mIntervalStart;
|
||||
mTotalBytes = 0;
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
#include "gfxImageSurface.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsMediaDecoder.h"
|
||||
#include "nsDOMError.h"
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
// Logging object for decoder
|
||||
|
@ -241,7 +240,3 @@ void nsMediaDecoder::ElementUnavailable()
|
|||
mElement = nsnull;
|
||||
}
|
||||
|
||||
nsHTMLMediaElement* nsMediaDecoder::GetMediaElement()
|
||||
{
|
||||
return mElement;
|
||||
}
|
||||
|
|
|
@ -51,9 +51,6 @@
|
|||
#include "nsIStreamListener.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsChannelToPipeListener.h"
|
||||
#include "nsCrossSiteListenerProxy.h"
|
||||
#include "nsHTMLMediaElement.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
// For HTTP seeking, if number of bytes needing to be
|
||||
// seeked forward is less than this value then a read is
|
||||
|
@ -109,34 +106,11 @@ nsresult nsDefaultStreamStrategy::Open(nsIStreamListener** aStreamListener)
|
|||
nsresult rv = mListener->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIStreamListener> listener = do_QueryInterface(mListener);
|
||||
|
||||
if (aStreamListener) {
|
||||
*aStreamListener = mListener;
|
||||
NS_ADDREF(mListener);
|
||||
} else {
|
||||
// Ensure that if we're loading cross domain, that the server is sending
|
||||
// an authorizing Access-Control header.
|
||||
nsHTMLMediaElement* element = mDecoder->GetMediaElement();
|
||||
NS_ENSURE_TRUE(element, NS_ERROR_FAILURE);
|
||||
if (element->ShouldCheckAllowOrigin()) {
|
||||
listener = new nsCrossSiteListenerProxy(mListener,
|
||||
element->NodePrincipal(),
|
||||
mChannel,
|
||||
PR_FALSE,
|
||||
&rv);
|
||||
NS_ENSURE_TRUE(listener, NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
// Ensure that we never load a local file from some page on a
|
||||
// web server.
|
||||
rv = nsContentUtils::GetSecurityManager()->
|
||||
CheckLoadURIWithPrincipal(element->NodePrincipal(),
|
||||
mURI,
|
||||
nsIScriptSecurityManager::STANDARD);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
rv = mChannel->AsyncOpen(listener, nsnull);
|
||||
rv = mChannel->AsyncOpen(mListener, nsnull);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
@ -277,17 +251,6 @@ nsresult nsFileStreamStrategy::Open(nsIStreamListener** aStreamListener)
|
|||
|
||||
rv = NS_NewLocalFileInputStream(getter_AddRefs(mInput), file);
|
||||
} else {
|
||||
// Ensure that we never load a local file from some page on a
|
||||
// web server.
|
||||
nsHTMLMediaElement* element = mDecoder->GetMediaElement();
|
||||
NS_ENSURE_TRUE(element, NS_ERROR_FAILURE);
|
||||
|
||||
rv = nsContentUtils::GetSecurityManager()->
|
||||
CheckLoadURIWithPrincipal(element->NodePrincipal(),
|
||||
mURI,
|
||||
nsIScriptSecurityManager::STANDARD);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mChannel->Open(getter_AddRefs(mInput));
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -398,7 +361,7 @@ public:
|
|||
}
|
||||
|
||||
// These methods have the same thread calling requirements
|
||||
// as those with the same name in nsMediaStream.
|
||||
// as those with the same name in nsMediaStream
|
||||
virtual nsresult Open(nsIStreamListener** aListener);
|
||||
virtual nsresult Close();
|
||||
virtual nsresult Read(char* aBuffer, PRUint32 aCount, PRUint32* aBytes);
|
||||
|
@ -412,14 +375,13 @@ public:
|
|||
// Return PR_TRUE if the stream has been cancelled.
|
||||
PRBool IsCancelled() const;
|
||||
|
||||
// This must be called on the main thread only, and at a time when the
|
||||
// strategy is not reading from the current channel/stream. It's primary
|
||||
// purpose is to be called from a Seek to reset to the new byte range
|
||||
// request HTTP channel.
|
||||
nsresult OpenInternal(nsIChannel* aChannel, PRInt64 aOffset);
|
||||
|
||||
// Opens the HTTP channel, using a byte range request to start at aOffset.
|
||||
nsresult OpenInternal(nsIStreamListener **aStreamListener, PRInt64 aOffset);
|
||||
// This must be called on the main thread only, and at a
|
||||
// time when the strategy is not reading from the current
|
||||
// channel/stream. It's primary purpose is to be called from
|
||||
// a Seek to reset to the new byte range request http channel.
|
||||
void Reset(nsIChannel* aChannel,
|
||||
nsChannelToPipeListener* aListener,
|
||||
nsIInputStream* aStream);
|
||||
|
||||
private:
|
||||
// Listener attached to channel to constantly download the
|
||||
|
@ -449,25 +411,18 @@ private:
|
|||
PRPackedBool mCancelled;
|
||||
};
|
||||
|
||||
void nsHttpStreamStrategy::Reset(nsIChannel* aChannel,
|
||||
nsChannelToPipeListener* aListener,
|
||||
nsIInputStream* aStream)
|
||||
{
|
||||
nsAutoLock lock(mLock);
|
||||
mChannel = aChannel;
|
||||
mListener = aListener;
|
||||
mPipeInput = aStream;
|
||||
}
|
||||
|
||||
nsresult nsHttpStreamStrategy::Open(nsIStreamListener **aStreamListener)
|
||||
{
|
||||
return OpenInternal(aStreamListener, 0);
|
||||
}
|
||||
|
||||
nsresult nsHttpStreamStrategy::OpenInternal(nsIChannel* aChannel,
|
||||
PRInt64 aOffset)
|
||||
{
|
||||
nsAutoLock lock(mLock);
|
||||
mChannel = aChannel;
|
||||
return OpenInternal(static_cast<nsIStreamListener**>(nsnull), aOffset);
|
||||
}
|
||||
|
||||
nsresult nsHttpStreamStrategy::OpenInternal(nsIStreamListener **aStreamListener,
|
||||
PRInt64 aOffset)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||
NS_ENSURE_TRUE(mChannel, NS_ERROR_NULL_POINTER);
|
||||
|
||||
if (aStreamListener) {
|
||||
*aStreamListener = nsnull;
|
||||
}
|
||||
|
@ -478,59 +433,34 @@ nsresult nsHttpStreamStrategy::OpenInternal(nsIStreamListener **aStreamListener,
|
|||
nsresult rv = mListener->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIStreamListener> listener = do_QueryInterface(mListener);
|
||||
|
||||
if (aStreamListener) {
|
||||
*aStreamListener = mListener;
|
||||
NS_ADDREF(*aStreamListener);
|
||||
} else {
|
||||
// Ensure that if we're loading cross domain, that the server is sending
|
||||
// an authorizing Access-Control header.
|
||||
nsHTMLMediaElement* element = mDecoder->GetMediaElement();
|
||||
NS_ENSURE_TRUE(element, NS_ERROR_FAILURE);
|
||||
if (element->ShouldCheckAllowOrigin()) {
|
||||
listener = new nsCrossSiteListenerProxy(mListener,
|
||||
element->NodePrincipal(),
|
||||
mChannel,
|
||||
PR_FALSE,
|
||||
&rv);
|
||||
NS_ENSURE_TRUE(listener, NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
rv = nsContentUtils::GetSecurityManager()->
|
||||
CheckLoadURIWithPrincipal(element->NodePrincipal(),
|
||||
mURI,
|
||||
nsIScriptSecurityManager::STANDARD);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
}
|
||||
// Use a byte range request from the start of the resource.
|
||||
// This enables us to detect if the stream supports byte range
|
||||
// requests, and therefore seeking, early.
|
||||
nsCOMPtr<nsIHttpChannel> hc = do_QueryInterface(mChannel);
|
||||
if (hc) {
|
||||
nsCAutoString rangeString("bytes=");
|
||||
rangeString.AppendInt(aOffset);
|
||||
rangeString.Append("-");
|
||||
hc->SetRequestHeader(NS_LITERAL_CSTRING("Range"), rangeString, PR_FALSE);
|
||||
hc->SetRequestHeader(NS_LITERAL_CSTRING("Range"),
|
||||
NS_LITERAL_CSTRING("bytes=0-"),
|
||||
PR_FALSE);
|
||||
}
|
||||
|
||||
rv = mChannel->AsyncOpen(listener, nsnull);
|
||||
rv = mChannel->AsyncOpen(mListener, nsnull);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
rv = mListener->GetInputStream(getter_AddRefs(mPipeInput));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mPosition = aOffset;
|
||||
mPosition = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsHttpStreamStrategy::Close()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||
nsAutoLock lock(mLock);
|
||||
if (mChannel) {
|
||||
mChannel->Cancel(NS_BINDING_ABORTED);
|
||||
|
@ -566,9 +496,11 @@ class nsByteRangeEvent : public nsRunnable
|
|||
{
|
||||
public:
|
||||
nsByteRangeEvent(nsHttpStreamStrategy* aStrategy,
|
||||
nsMediaDecoder* aDecoder,
|
||||
nsIURI* aURI,
|
||||
PRInt64 aOffset) :
|
||||
mStrategy(aStrategy),
|
||||
mDecoder(aDecoder),
|
||||
mURI(aURI),
|
||||
mOffset(aOffset),
|
||||
mResult(NS_OK)
|
||||
|
@ -598,16 +530,35 @@ public:
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
mStrategy->Close();
|
||||
mResult = NS_NewChannel(getter_AddRefs(channel),
|
||||
mResult = NS_NewChannel(getter_AddRefs(mChannel),
|
||||
mURI,
|
||||
nsnull,
|
||||
nsnull,
|
||||
nsnull,
|
||||
nsIRequest::LOAD_NORMAL);
|
||||
NS_ENSURE_SUCCESS(mResult, mResult);
|
||||
mResult = mStrategy->OpenInternal(channel, mOffset);
|
||||
nsCOMPtr<nsIHttpChannel> hc = do_QueryInterface(mChannel);
|
||||
if (hc) {
|
||||
nsCAutoString rangeString("bytes=");
|
||||
rangeString.AppendInt(mOffset);
|
||||
rangeString.Append("-");
|
||||
hc->SetRequestHeader(NS_LITERAL_CSTRING("Range"), rangeString, PR_FALSE);
|
||||
}
|
||||
|
||||
mListener = new nsChannelToPipeListener(mDecoder, PR_TRUE);
|
||||
NS_ENSURE_TRUE(mListener, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
mResult = mListener->Init();
|
||||
NS_ENSURE_SUCCESS(mResult, mResult);
|
||||
|
||||
mResult = mChannel->AsyncOpen(mListener, nsnull);
|
||||
NS_ENSURE_SUCCESS(mResult, mResult);
|
||||
|
||||
mResult = mListener->GetInputStream(getter_AddRefs(mStream));
|
||||
NS_ENSURE_SUCCESS(mResult, mResult);
|
||||
|
||||
mStrategy->Reset(mChannel, mListener, mStream);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -712,7 +663,7 @@ nsresult nsHttpStreamStrategy::Seek(PRInt32 aWhence, PRInt64 aOffset)
|
|||
|
||||
// Don't acquire mLock in this scope as we do a synchronous call to the main thread
|
||||
// which would deadlock if that thread is calling Close().
|
||||
nsCOMPtr<nsByteRangeEvent> event = new nsByteRangeEvent(this, mURI, aOffset);
|
||||
nsCOMPtr<nsByteRangeEvent> event = new nsByteRangeEvent(this, mDecoder, mURI, aOffset);
|
||||
NS_DispatchToMainThread(event, NS_DISPATCH_SYNC);
|
||||
|
||||
// If the sync request fails, or a call to Cancel() is made during the request,
|
||||
|
|
Двоичные данные
content/media/video/test/320x240.allow-origin.ogg
Двоичные данные
content/media/video/test/320x240.allow-origin.ogg
Двоичный файл не отображается.
|
@ -1 +0,0 @@
|
|||
Access-Control-Allow-Origin: *
|
|
@ -60,9 +60,6 @@ _TEST_FILES = \
|
|||
|
||||
ifdef MOZ_OGG
|
||||
_TEST_FILES += \
|
||||
test_access_control.html \
|
||||
test_access_control-2.html \
|
||||
file_access_controls.html \
|
||||
test_bug448534.html \
|
||||
test_bug461281.html \
|
||||
test_can_play_type_ogg.html \
|
||||
|
@ -82,10 +79,7 @@ _TEST_FILES += \
|
|||
test_timeupdate2.html \
|
||||
test_timeupdate3.html \
|
||||
320x240.ogg \
|
||||
320x240.allow-origin.ogg \
|
||||
320x240.allow-origin.ogg^headers^ \
|
||||
bug461281.ogg \
|
||||
redirect.sjs \
|
||||
seek.ogg \
|
||||
$(NULL)
|
||||
else
|
||||
|
|
|
@ -1,135 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<script>
|
||||
|
||||
// Page URL: http://example.org/tests/content/media/video/test/file_access_controls.html
|
||||
|
||||
var gTests = [
|
||||
{
|
||||
url: "redirect.sjs?http://example.com/tests/content/media/video/test/320x240.ogg",
|
||||
result: "error",
|
||||
description: "Won't load when redirected to different domain",
|
||||
},{
|
||||
url: "redirect.sjs?http://example.com/tests/content/media/video/test/320x240.allow-origin.ogg",
|
||||
result: "loaded",
|
||||
description: "Can load when redirected to different domain with allow-origin",
|
||||
},{
|
||||
url: "redirect.sjs?http://test1.example.org/tests/content/media/video/test/320x240.ogg",
|
||||
result: "error",
|
||||
description: "Won't load when redirected to subdomain",
|
||||
},{
|
||||
url: "redirect.sjs?http://test1.example.org/tests/content/media/video/test/320x240.allow-origin.ogg",
|
||||
result: "loaded",
|
||||
description: "Can load when redirected to subdomain with allow-origin",
|
||||
},{
|
||||
url: "redirect.sjs?http://example.org/tests/content/media/video/test/320x240.ogg",
|
||||
result: "loaded",
|
||||
description: "Can load when redirected to same domain",
|
||||
},{
|
||||
url: "http://example.org/tests/content/media/video/test/320x240.ogg",
|
||||
result: "loaded",
|
||||
description: "Can load from same domain"
|
||||
},{
|
||||
url: "http://example.org:8000/tests/content/media/video/test/320x240.ogg",
|
||||
result: "error",
|
||||
description: "Won't load from differnet port on same domain"
|
||||
},{
|
||||
url: "http://example.org:8000/tests/content/media/video/test/320x240.allow-origin.ogg",
|
||||
result: "loaded",
|
||||
description: "Can load from different port on same domain with allow-origin",
|
||||
},{
|
||||
url: "http://example.com/tests/content/media/video/test/320x240.ogg",
|
||||
result: "error",
|
||||
description: "Won't load cross domain",
|
||||
},{
|
||||
url: "http://example.com/tests/content/media/video/test/320x240.allow-origin.ogg",
|
||||
result: "loaded",
|
||||
description: "Can load cross domain with allow-origin",
|
||||
},{
|
||||
url: "http://test1.example.org/tests/content/media/video/test/320x240.allow-origin.ogg",
|
||||
result: "loaded",
|
||||
description: "Can load from subdomain with allow-origin",
|
||||
},{
|
||||
url: "http://test1.example.org/tests/content/media/video/test/320x240.ogg",
|
||||
result: "error",
|
||||
description: "Won't load from subdomain",
|
||||
}
|
||||
];
|
||||
|
||||
var gTestNum = 0;
|
||||
var gExpectedResult = null;
|
||||
var gTestDescription = null;
|
||||
var video = null;
|
||||
var gTestedRemoved = false;
|
||||
var gOldPref;
|
||||
|
||||
function result(code) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
dump("result " + code);
|
||||
opener.is(code, gExpectedResult, gTestDescription);
|
||||
nextTest();
|
||||
}
|
||||
|
||||
function load() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
opener.is(window.location.href,
|
||||
"http://example.org/tests/content/media/video/test/file_access_controls.html",
|
||||
"We must be on a example.org:80");
|
||||
video = document.getElementById('video');
|
||||
|
||||
// Ensure access control check pref is on.
|
||||
// media.enforce_same_site_origin
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService);
|
||||
opener.ok(prefService!=null, "Get pref service");
|
||||
var branch = prefService.getBranch("media.");
|
||||
opener.ok(branch!=null, "Get media pref branch");
|
||||
gOldPref = branch.getBoolPref("enforce_same_site_origin");
|
||||
branch.setBoolPref("enforce_same_site_origin", true);
|
||||
nextTest();
|
||||
}
|
||||
|
||||
function nextTest() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
if (gTestNum == gTests.length) {
|
||||
if (!gTestedRemoved) {
|
||||
// Repeat all tests with element removed from doc, should get same result.
|
||||
video.parentNode.removeChild(video);
|
||||
gTestedRemoved = true;
|
||||
gTestNum = 0;
|
||||
} else {
|
||||
// We're done, exit the test.
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
gExpectedResult = gTests[gTestNum].result;
|
||||
gTestDescription = gTests[gTestNum].description;
|
||||
video.src = gTests[gTestNum].url;
|
||||
gTestNum++;
|
||||
}
|
||||
|
||||
function done() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
// Undo change to access control check pref.
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService);
|
||||
var branch = prefService.getBranch("media.");
|
||||
branch.setBoolPref("enforce_same_site_origin", gOldPref);
|
||||
opener.done();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</head>
|
||||
<body onload="load();" onunload="done()">
|
||||
|
||||
<!-- Change onloadedfirstframe to onloadeddata after bug 462570 lands -->
|
||||
<video id="video"
|
||||
onloadeddata="result('loaded');"
|
||||
onerror="result('error');">
|
||||
</video>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
function handleRequest(request, response)
|
||||
{
|
||||
response.setStatusLine(request.httpVersion, 301, "Moved Permanently");
|
||||
response.setHeader("Location", request.queryString, false);
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=451958
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 451958</title>
|
||||
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=451958">Mozilla Bug 451958</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 451958 **/
|
||||
|
||||
function run() {
|
||||
window.open("http://example.org:80/tests/content/media/video/test/file_access_controls.html", "", "width=500,height=500");
|
||||
}
|
||||
|
||||
function done() {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
addLoadEvent(run);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -131,10 +131,6 @@ pref("browser.chrome.image_icons.max_size", 1024);
|
|||
|
||||
pref("browser.triple_click_selects_paragraph", true);
|
||||
|
||||
// When loading <video> or <audio>, check for Access-Control-Allow-Origin
|
||||
// header, and disallow the connection if not present or permitted.
|
||||
pref("media.enforce_same_site_origin", false);
|
||||
|
||||
#ifdef MOZ_OGG
|
||||
pref("media.ogg.enabled", true);
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче