mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 98cc8a50348f (bug 936340) because it misses the test_beaconElectrolysis.html file, which breaks the build
This commit is contained in:
parent
d01bf12235
commit
65a4f26667
@ -110,7 +110,6 @@ NS_CP_ContentTypeName(uint32_t contentType)
|
||||
CASE_RETURN( TYPE_WEBSOCKET );
|
||||
CASE_RETURN( TYPE_CSP_REPORT );
|
||||
CASE_RETURN( TYPE_XSLT );
|
||||
CASE_RETURN( TYPE_BEACON );
|
||||
default:
|
||||
return "<Unknown Type>";
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ typedef unsigned long nsContentPolicyType;
|
||||
* by launching a dialog to prompt the user for something).
|
||||
*/
|
||||
|
||||
[scriptable,uuid(b6a71698-c117-441d-86b9-480cf06e3952)]
|
||||
[scriptable,uuid(e48e3024-f302-4a16-b8b6-2034d3a4b279)]
|
||||
interface nsIContentPolicy : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -145,11 +145,6 @@ interface nsIContentPolicy : nsISupports
|
||||
*/
|
||||
const nsContentPolicyType TYPE_XSLT = 18;
|
||||
|
||||
/**
|
||||
* Indicates a beacon post.
|
||||
*/
|
||||
const nsContentPolicyType TYPE_BEACON = 19;
|
||||
|
||||
/* When adding new content types, please update nsContentBlocker,
|
||||
* NS_CP_ContentTypeName, contentSecurityPolicy.js, all nsIContentPolicy
|
||||
* implementations, and other things that are not listed here that are
|
||||
|
@ -97,7 +97,6 @@ function ContentSecurityPolicy() {
|
||||
csp._MAPPINGS[cp.TYPE_MEDIA] = cspr_sd_new.MEDIA_SRC;
|
||||
csp._MAPPINGS[cp.TYPE_FONT] = cspr_sd_new.FONT_SRC;
|
||||
csp._MAPPINGS[cp.TYPE_XSLT] = cspr_sd_new.SCRIPT_SRC;
|
||||
csp._MAPPINGS[cp.TYPE_BEACON] = cspr_sd_new.CONNECT_SRC;
|
||||
|
||||
/* Our original CSP implementation's mappings for XHR and websocket
|
||||
* These should be changed to be = cspr_sd.CONNECT_SRC when we remove
|
||||
|
@ -242,8 +242,6 @@ nsMixedContentBlocker::ShouldLoad(uint32_t aContentType,
|
||||
// spoofing attacks (e.g. make a "grant permission" button look like a
|
||||
// "refuse permission" button).
|
||||
//
|
||||
// TYPE_BEACON: Beacon requests are similar to TYPE_PING, but are default on.
|
||||
//
|
||||
// TYPE_WEBSOCKET: The Websockets API requires browsers to
|
||||
// reject mixed-content websockets: "If secure is false but the origin of
|
||||
// the entry script has a scheme component that is itself a secure protocol,
|
||||
@ -287,7 +285,6 @@ nsMixedContentBlocker::ShouldLoad(uint32_t aContentType,
|
||||
case TYPE_MEDIA:
|
||||
case TYPE_OBJECT_SUBREQUEST:
|
||||
case TYPE_PING:
|
||||
case TYPE_BEACON:
|
||||
classification = eMixedDisplay;
|
||||
break;
|
||||
|
||||
|
@ -30,8 +30,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=62178
|
||||
case nsIContentPolicy::TYPE_MEDIA:
|
||||
case nsIContentPolicy::TYPE_PING:
|
||||
our ping implementation is off by default and does not comply with the current spec (bug 786347)
|
||||
case nsIContentPolicy::TYPE_BEACON:
|
||||
|
||||
}
|
||||
*/
|
||||
-->
|
||||
|
@ -15,11 +15,6 @@
|
||||
#include "mozilla/dom/DesktopNotification.h"
|
||||
#include "nsGeolocation.h"
|
||||
#include "nsIHttpProtocolHandler.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsCrossSiteListenerProxy.h"
|
||||
#include "nsISupportsPriority.h"
|
||||
#include "nsICachingChannel.h"
|
||||
#include "nsIWebContentHandlerRegistrar.h"
|
||||
#include "nsICookiePermission.h"
|
||||
@ -50,19 +45,14 @@
|
||||
#endif
|
||||
#include "nsIIdleObserver.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIHttpChannelInternal.h"
|
||||
#include "TimeManager.h"
|
||||
#include "DeviceStorage.h"
|
||||
#include "nsIDOMNavigatorSystemMessages.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsIAppsService.h"
|
||||
#include "mozIApplication.h"
|
||||
#include "WidgetUtils.h"
|
||||
#include "mozIThirdPartyUtil.h"
|
||||
#include "nsChannelPolicy.h"
|
||||
|
||||
#ifdef MOZ_MEDIA_NAVIGATOR
|
||||
#include "MediaManager.h"
|
||||
@ -89,9 +79,6 @@
|
||||
#include "mozilla/dom/NavigatorBinding.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
|
||||
#include "nsIUploadChannel2.h"
|
||||
#include "nsFormData.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
@ -1003,279 +990,6 @@ Navigator::GetGeolocation(ErrorResult& aRv)
|
||||
return mGeolocation;
|
||||
}
|
||||
|
||||
class BeaconStreamListener MOZ_FINAL : public nsIStreamListener
|
||||
{
|
||||
public:
|
||||
BeaconStreamListener() {}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS2(BeaconStreamListener,
|
||||
nsIStreamListener,
|
||||
nsIRequestObserver)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
BeaconStreamListener::OnStartRequest(nsIRequest *aRequest,
|
||||
nsISupports *aContext)
|
||||
{
|
||||
aRequest->Cancel(NS_ERROR_NET_INTERRUPT);
|
||||
return NS_BINDING_ABORTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BeaconStreamListener::OnStopRequest(nsIRequest *aRequest,
|
||||
nsISupports *aContext,
|
||||
nsresult aStatus)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BeaconStreamListener::OnDataAvailable(nsIRequest *aRequest,
|
||||
nsISupports *ctxt,
|
||||
nsIInputStream *inStr,
|
||||
uint64_t sourceOffset,
|
||||
uint32_t count)
|
||||
{
|
||||
MOZ_ASSERT(false);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
Navigator::SendBeacon(const nsAString& aUrl,
|
||||
const Nullable<ArrayBufferViewOrBlobOrStringOrFormData>& aData,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (!mWindow) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = mWindow->GetDoc();
|
||||
if (!doc) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return false;
|
||||
}
|
||||
|
||||
nsIURI* documentURI = doc->GetDocumentURI();
|
||||
if (!documentURI) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = nsContentUtils::NewURIWithDocumentCharset(
|
||||
getter_AddRefs(uri),
|
||||
aUrl,
|
||||
doc,
|
||||
doc->GetDocBaseURI());
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(NS_ERROR_DOM_URL_MISMATCH_ERR);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check whether this is a sane URI to load
|
||||
// Explicitly disallow things like chrome:, javascript:, and data: URIs
|
||||
nsCOMPtr<nsIPrincipal> principal = doc->NodePrincipal();
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan = nsContentUtils::GetSecurityManager();
|
||||
uint32_t flags = nsIScriptSecurityManager::DISALLOW_INHERIT_PRINCIPAL
|
||||
& nsIScriptSecurityManager::DISALLOW_SCRIPT;
|
||||
rv = secMan->CheckLoadURIWithPrincipal(principal,
|
||||
uri,
|
||||
flags);
|
||||
if (NS_FAILED(rv)) {
|
||||
// Bad URI
|
||||
aRv.Throw(rv);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check whether the CSP allows us to load
|
||||
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
|
||||
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_BEACON,
|
||||
uri,
|
||||
principal,
|
||||
doc,
|
||||
EmptyCString(), //mime guess
|
||||
nullptr, //extra
|
||||
&shouldLoad,
|
||||
nsContentUtils::GetContentPolicy(),
|
||||
nsContentUtils::GetSecurityManager());
|
||||
if (NS_FAILED(rv) || NS_CP_REJECTED(shouldLoad)) {
|
||||
// Disallowed by content policy
|
||||
aRv.Throw(NS_ERROR_CONTENT_BLOCKED);
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
nsCOMPtr<nsIChannelPolicy> channelPolicy;
|
||||
nsCOMPtr<nsIContentSecurityPolicy> csp;
|
||||
rv = principal->GetCsp(getter_AddRefs(csp));
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (csp) {
|
||||
channelPolicy = do_CreateInstance(NSCHANNELPOLICY_CONTRACTID);
|
||||
channelPolicy->SetContentSecurityPolicy(csp);
|
||||
channelPolicy->SetLoadType(nsIContentPolicy::TYPE_BEACON);
|
||||
}
|
||||
rv = NS_NewChannel(getter_AddRefs(channel),
|
||||
uri,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nsIRequest::LOAD_NORMAL,
|
||||
channelPolicy);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
|
||||
if (!httpChannel) {
|
||||
// Beacon spec only supports HTTP requests at this time
|
||||
aRv.Throw(NS_ERROR_DOM_BAD_URI);
|
||||
return false;
|
||||
}
|
||||
httpChannel->SetReferrer(documentURI);
|
||||
|
||||
// Anything that will need to refer to the window during the request
|
||||
// will need to be done now. For example, detection of whether any
|
||||
// cookies set by this request are foreign. Note that ThirdPartyUtil
|
||||
// (nsIThirdPartyUtil.isThirdPartyChannel) does a secondary check between
|
||||
// the channel URI and the cookie URI even when forceAllowThirdPartyCookie
|
||||
// is set, so this is safe with regard to redirects.
|
||||
nsCOMPtr<nsIHttpChannelInternal> httpChannelInternal(do_QueryInterface(channel));
|
||||
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = do_GetService(THIRDPARTYUTIL_CONTRACTID);
|
||||
if (!httpChannelInternal) {
|
||||
aRv.Throw(NS_ERROR_DOM_BAD_URI);
|
||||
return false;
|
||||
}
|
||||
bool isForeign = true;
|
||||
thirdPartyUtil->IsThirdPartyWindow(mWindow, uri, &isForeign);
|
||||
httpChannelInternal->SetForceAllowThirdPartyCookie(!isForeign);
|
||||
|
||||
nsCString mimeType;
|
||||
if (!aData.IsNull()) {
|
||||
nsCOMPtr<nsIInputStream> in;
|
||||
|
||||
if (aData.Value().IsString()) {
|
||||
nsCString stringData = NS_ConvertUTF16toUTF8(aData.Value().GetAsString());
|
||||
nsCOMPtr<nsIStringInputStream> strStream = do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
}
|
||||
rv = strStream->SetData(stringData.BeginReading(), stringData.Length());
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
}
|
||||
mimeType.AssignLiteral("text/plain;charset=UTF-8");
|
||||
in = strStream;
|
||||
|
||||
} else if (aData.Value().IsArrayBufferView()) {
|
||||
|
||||
nsCOMPtr<nsIStringInputStream> strStream = do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
}
|
||||
|
||||
rv = strStream->SetData(reinterpret_cast<char*>(aData.Value().GetAsArrayBufferView().Data()),
|
||||
aData.Value().GetAsArrayBufferView().Length());
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
}
|
||||
mimeType.AssignLiteral("application/octet-stream");
|
||||
in = strStream;
|
||||
|
||||
} else if (aData.Value().IsBlob()) {
|
||||
nsCOMPtr<nsIDOMBlob> blob = aData.Value().GetAsBlob();
|
||||
rv = blob->GetInternalStream(getter_AddRefs(in));
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
}
|
||||
nsAutoString type;
|
||||
rv = blob->GetType(type);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
}
|
||||
mimeType = NS_ConvertUTF16toUTF8(type);
|
||||
|
||||
} else if (aData.Value().IsFormData()) {
|
||||
nsFormData& form = aData.Value().GetAsFormData();
|
||||
uint64_t len;
|
||||
nsAutoCString charset;
|
||||
form.GetSendInfo(getter_AddRefs(in),
|
||||
&len,
|
||||
mimeType,
|
||||
charset);
|
||||
} else {
|
||||
MOZ_ASSERT(false, "switch statements not in sync");
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIUploadChannel2> uploadChannel = do_QueryInterface(channel);
|
||||
if (!uploadChannel) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
}
|
||||
uploadChannel->ExplicitSetUploadStream(in, mimeType, -1,
|
||||
NS_LITERAL_CSTRING("POST"),
|
||||
false);
|
||||
} else {
|
||||
httpChannel->SetRequestMethod(NS_LITERAL_CSTRING("POST"));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(channel);
|
||||
if (p) {
|
||||
p->SetPriority(nsISupportsPriority::PRIORITY_LOWEST);
|
||||
}
|
||||
|
||||
nsRefPtr<nsCORSListenerProxy> cors = new nsCORSListenerProxy(new BeaconStreamListener(),
|
||||
principal,
|
||||
true);
|
||||
|
||||
// Start a preflight if cross-origin and content type is not whitelisted
|
||||
rv = secMan->CheckSameOriginURI(documentURI, uri, false);
|
||||
bool crossOrigin = NS_FAILED(rv);
|
||||
nsAutoCString contentType, parsedCharset;
|
||||
rv = NS_ParseContentType(mimeType, contentType, parsedCharset);
|
||||
if (crossOrigin &&
|
||||
contentType.Length() > 0 &&
|
||||
!contentType.Equals(APPLICATION_WWW_FORM_URLENCODED) &&
|
||||
!contentType.Equals(MULTIPART_FORM_DATA) &&
|
||||
!contentType.Equals(TEXT_PLAIN)) {
|
||||
nsCOMPtr<nsIChannel> preflightChannel;
|
||||
nsTArray<nsCString> unsafeHeaders;
|
||||
unsafeHeaders.AppendElement(NS_LITERAL_CSTRING("Content-Type"));
|
||||
rv = NS_StartCORSPreflight(channel,
|
||||
cors,
|
||||
principal,
|
||||
true,
|
||||
unsafeHeaders,
|
||||
getter_AddRefs(preflightChannel));
|
||||
} else {
|
||||
rv = channel->AsyncOpen(cors, nullptr);
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef MOZ_MEDIA_NAVIGATOR
|
||||
void
|
||||
Navigator::MozGetUserMedia(JSContext* aCx,
|
||||
|
@ -8,7 +8,6 @@
|
||||
#define mozilla_dom_Navigator_h
|
||||
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/dom/Nullable.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsIDOMNavigator.h"
|
||||
#include "nsIMozNavigatorNetwork.h"
|
||||
@ -25,7 +24,6 @@ class nsIDOMMozMobileMessageManager;
|
||||
class nsIDOMNavigatorSystemMessages;
|
||||
class nsDOMCameraManager;
|
||||
class nsDOMDeviceStorage;
|
||||
class nsIDOMBlob;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -34,7 +32,6 @@ class systemMessageCallback;
|
||||
class MediaStreamConstraints;
|
||||
class MediaStreamConstraintsInternal;
|
||||
class WakeLock;
|
||||
class ArrayBufferViewOrBlobOrStringOrFormData;
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,11 +221,6 @@ public:
|
||||
#ifdef MOZ_AUDIO_CHANNEL_MANAGER
|
||||
system::AudioChannelManager* GetMozAudioChannelManager(ErrorResult& aRv);
|
||||
#endif // MOZ_AUDIO_CHANNEL_MANAGER
|
||||
|
||||
bool SendBeacon(const nsAString& aUrl,
|
||||
const Nullable<ArrayBufferViewOrBlobOrStringOrFormData>& aData,
|
||||
ErrorResult& aRv);
|
||||
|
||||
#ifdef MOZ_MEDIA_NAVIGATOR
|
||||
void MozGetUserMedia(JSContext* aCx,
|
||||
const MediaStreamConstraints& aConstraints,
|
||||
|
@ -1,24 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Inner frame performing a basic sendBeacon from within an iframe</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
|
||||
function sendBeacon()
|
||||
{
|
||||
var frame = window.parent.document.getElementById("frame");
|
||||
var data = window.parent.beaconConvert(frame.getAttribute("data"));
|
||||
|
||||
var result = navigator.sendBeacon("http://mochi.test:8888/tests/dom/tests/mochitest/beacon/beacon-handler.sjs", data);
|
||||
window.parent.beaconSent(result);
|
||||
}
|
||||
|
||||
window.addEventListener("load", function() { setTimeout(sendBeacon, 0); }, false);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,83 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const CC = Components.Constructor;
|
||||
const BinaryInputStream = CC("@mozilla.org/binaryinputstream;1",
|
||||
"nsIBinaryInputStream",
|
||||
"setInputStream");
|
||||
|
||||
function DEBUG(str)
|
||||
{
|
||||
// dump("********** " + str);
|
||||
}
|
||||
|
||||
function handleRequest(request, response) {
|
||||
DEBUG("Entered request handler");
|
||||
response.setHeader("Cache-Control", "no-cache", false);
|
||||
|
||||
if (request.method == "GET") {
|
||||
response.setHeader("Content-Type", "application/json", false);
|
||||
switch (request.queryString) {
|
||||
case "getLastBeacon":
|
||||
var data = getState("beaconData");
|
||||
var mimetype = getState("beaconMimetype");
|
||||
DEBUG("GET was sending : " + data + "\n");
|
||||
DEBUG("GET was sending : " + mimetype + "\n");
|
||||
var result = {
|
||||
"data": data,
|
||||
"mimetype": mimetype,
|
||||
};
|
||||
response.write(JSON.stringify(result));
|
||||
break;
|
||||
default:
|
||||
response.setStatusLine(request.httpVersion, 400, "Bad Request");
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (request.method == "POST") {
|
||||
var body = new BinaryInputStream(request.bodyInputStream);
|
||||
var avail;
|
||||
var bytes = [];
|
||||
|
||||
while ((avail = body.available()) > 0) {
|
||||
Array.prototype.push.apply(bytes, body.readByteArray(avail));
|
||||
}
|
||||
|
||||
var data = "";
|
||||
for (var i=0; i < bytes.length; i++) {
|
||||
// We are only passing strings at this point.
|
||||
if (bytes[i] < 32) continue;
|
||||
var charcode = String.fromCharCode(bytes[i]);
|
||||
data += charcode;
|
||||
}
|
||||
|
||||
var mimetype = request.getHeader("Content-Type");
|
||||
|
||||
// check to see if this is form data.
|
||||
if (mimetype.indexOf("multipart/form-data") != -1) {
|
||||
|
||||
// trim the mime type to make testing easier.
|
||||
mimetype = "multipart/form-data";
|
||||
// Extract only the form-data name.
|
||||
|
||||
var pattern = /; name=\"(.+)\";/;
|
||||
data = data.split(pattern)[1];
|
||||
}
|
||||
|
||||
DEBUG("********** POST was sending : " + data + "\n");
|
||||
DEBUG("********** POST was sending : " + mimetype + "\n");
|
||||
setState("beaconData", data);
|
||||
setState("beaconMimetype", mimetype);
|
||||
|
||||
response.setHeader("Content-Type", "text/plain", false);
|
||||
response.write('ok');
|
||||
return;
|
||||
}
|
||||
|
||||
response.setStatusLine(request.httpVersion, 402, "Bad Request");
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
function handleRequest(request, response)
|
||||
{
|
||||
response.setHeader("Set-Cookie", "cookie="+ request.host + "~" + Math.random());
|
||||
response.setHeader("Content-Type", "text/plain", false);
|
||||
response.setHeader("Cache-Control", "no-cache", false);
|
||||
|
||||
response.setStatusLine(request.httpVersion, 200, "OK");
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
[DEFAULT]
|
||||
support-files = beacon-frame.html
|
||||
beacon-handler.sjs
|
||||
beacon-set-cookie.sjs
|
||||
|
||||
[test_beacon.html]
|
||||
[test_beaconFrame.html]
|
||||
[test_beaconPreflight.html]
|
||||
[test_beaconCookies.html]
|
||||
[test_beaconContentPolicy.html]
|
||||
[test_beaconElectrolysis.html]
|
@ -1,8 +0,0 @@
|
||||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
MOCHITEST_MANIFESTS += ['mochitest.ini']
|
||||
|
@ -1,48 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=936340
|
||||
-->
|
||||
<head>
|
||||
<title>Test whether sendBeacon fails for non-HTTP URIs and syntactically incorrect calls</title>
|
||||
<script type="text/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=936340">Mozilla Bug 936340</a>
|
||||
<p id="display"></p>
|
||||
|
||||
<div id="content">
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({'set': [["beacon.enabled", true]]}, beginTest);
|
||||
|
||||
function beginTest() {
|
||||
var threw;
|
||||
try {
|
||||
is(false, navigator.sendBeacon("ftp://example.com", "0"));
|
||||
threw = false;
|
||||
} catch (ex) {
|
||||
threw = true;
|
||||
}
|
||||
ok(threw, "sendBeacon not supported for non ftp calls.");
|
||||
|
||||
try {
|
||||
is(false, navigator.sendBeacon());
|
||||
threw = false;
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
}
|
||||
ok(threw, "sendBeacon needs more parameters.");
|
||||
|
||||
SimpleTest.finish()
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,97 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=936340
|
||||
-->
|
||||
<head>
|
||||
<title>Test that sendBeacon obeys content policy directives</title>
|
||||
<script type="text/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=936340">Mozilla Bug 936340</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var beaconUrl = "http://mochi.test:8888/tests/dom/tests/mochitest/beacon/beacon-handler.sjs";
|
||||
|
||||
const Cc = SpecialPowers.Cc;
|
||||
const Ci = SpecialPowers.Ci;
|
||||
|
||||
// not enabled by default yet.
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var policy = setupPolicy();
|
||||
|
||||
SpecialPowers.pushPrefEnv({'set': [["beacon.enabled", true]]}, beginTest);
|
||||
|
||||
function setupPolicy() {
|
||||
var policyID = SpecialPowers.wrap(SpecialPowers.Components).ID("{b80e19d0-878f-d41b-2654-194714a4115c}");
|
||||
var policyName = "@mozilla.org/testpolicy;1";
|
||||
var policy = {
|
||||
// nsISupports implementation
|
||||
QueryInterface: function(iid) {
|
||||
iid = SpecialPowers.wrap(iid);
|
||||
if (iid.equals(Ci.nsISupports) ||
|
||||
iid.equals(Ci.nsIFactory) ||
|
||||
iid.equals(Ci.nsIContentPolicy))
|
||||
return this;
|
||||
throw SpecialPowers.Cr.NS_ERROR_NO_INTERFACE;
|
||||
},
|
||||
|
||||
// nsIFactory implementation
|
||||
createInstance: function(outer, iid) {
|
||||
return this.QueryInterface(iid);
|
||||
},
|
||||
|
||||
// nsIContentPolicy implementation
|
||||
shouldLoad: function(contentType, contentLocation, requestOrigin, context, mimeTypeGuess, extra) {
|
||||
// Remember last content type seen for the test url
|
||||
|
||||
if (SpecialPowers.wrap(contentLocation).spec == beaconUrl) {
|
||||
is(contentType, Ci.nsIContentPolicy.TYPE_BEACON, "Beacon content type should match expected. is: " + contentType + " should be: " + Ci.nsIContentPolicy.TYPE_BEACON);
|
||||
teardownPolicy();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
},
|
||||
|
||||
shouldProcess: function(contentType, contentLocation, requestOrigin, context, mimeTypeGuess, extra) {
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
}
|
||||
}
|
||||
policy = SpecialPowers.wrapCallbackObject(policy);
|
||||
|
||||
// Register content policy
|
||||
var componentManager = SpecialPowers.wrap(SpecialPowers.Components).manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
componentManager.registerFactory(policyID, "Test content policy", policyName, policy);
|
||||
|
||||
var categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
|
||||
categoryManager.addCategoryEntry("content-policy", policyName, policyName, false, true);
|
||||
|
||||
return { 'policy': policy, 'policyID': policyID, 'policyName': policyName };
|
||||
}
|
||||
|
||||
function teardownPolicy() {
|
||||
setTimeout(function() {
|
||||
// policy will not be removed from the category correctly
|
||||
var componentManager = SpecialPowers.wrap(SpecialPowers.Components).manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
componentManager.unregisterFactory(policy.policyID, policy.policy);
|
||||
var categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
|
||||
categoryManager.deleteCategoryEntry("content-policy", policy.policyName, false);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function beginTest() {
|
||||
navigator.sendBeacon(beaconUrl, "bacon would have been a better name than beacon");
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -1,58 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=936340
|
||||
-->
|
||||
<head>
|
||||
<title>Test whether sendBeacon sets cookies</title>
|
||||
<script type="text/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=936340">Mozilla Bug 936340</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var beaconUrl = "http://mochi.test:8888/tests/dom/tests/mochitest/beacon/beacon-set-cookie.sjs";
|
||||
|
||||
// not enabled by default yet.
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({'set': [["beacon.enabled", true]]}, beginTest);
|
||||
|
||||
const Cc = SpecialPowers.Cc;
|
||||
const Ci = SpecialPowers.Ci;
|
||||
|
||||
function examiner() {
|
||||
SpecialPowers.addObserver(this, "cookie-changed", false);
|
||||
}
|
||||
examiner.prototype = {
|
||||
finished: false,
|
||||
observe: function examiner_observe(subject, topic, data) {
|
||||
if (!this.finished) {
|
||||
ok(true, "cookie set by beacon request");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.examiner = new examiner();
|
||||
|
||||
function fail() {
|
||||
examiner.finished = true;
|
||||
ok(false, "cookie event never arrived");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function beginTest() {
|
||||
navigator.sendBeacon(beaconUrl, "ceci n'est pas une demande");
|
||||
setTimeout(2000, fail);
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -1,118 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=936340
|
||||
-->
|
||||
<head>
|
||||
<title>Test for beacon</title>
|
||||
<script type="text/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=936340">Mozilla Bug 936340</a>
|
||||
<p id="display"></p>
|
||||
|
||||
<div id="content">
|
||||
</div>
|
||||
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
// not enabled by default yet.
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({'set': [["beacon.enabled", true]]}, runNextTest);
|
||||
|
||||
function getBeaconServerStatus(callback) {
|
||||
var request = new XMLHttpRequest();
|
||||
request.open("GET", "http://mochi.test:8888/tests/dom/tests/mochitest/beacon/beacon-handler.sjs?getLastBeacon", true);
|
||||
request.onload = function() {
|
||||
if (request.readyState === request.DONE) {
|
||||
callback(request.responseText);
|
||||
}
|
||||
};
|
||||
request.send(null);
|
||||
}
|
||||
|
||||
function createIframeWithData(data, mimetype, convert) {
|
||||
beaconConvert = convert;
|
||||
|
||||
var frame = document.createElement("IFRAME");
|
||||
frame.setAttribute("src", "beacon-frame.html");
|
||||
frame.id = "frame";
|
||||
frame.setAttribute("data", data.toString());
|
||||
frame.setAttribute("mimetype", mimetype);
|
||||
var c = document.getElementById("content");
|
||||
c.appendChild(frame);
|
||||
}
|
||||
|
||||
function beaconSent(result) {
|
||||
// This function gets called from beacon-frame.html in the inner frame
|
||||
// Check that the beacon was actually sent
|
||||
ok(result, "Beacon was not sent")
|
||||
|
||||
// remove the frame.
|
||||
var frame = document.getElementById("frame");
|
||||
var data = frame.getAttribute("data");
|
||||
var mimetype = frame.getAttribute("mimetype");
|
||||
|
||||
var c = document.getElementById("content");
|
||||
c.removeChild(frame);
|
||||
|
||||
getBeaconServerStatus( function(response) {
|
||||
console.log(response);
|
||||
var result = JSON.parse(response);
|
||||
|
||||
is(result.data, data, "Beacon status should match expected. is: " + result.data + " should be: " + data);
|
||||
is(result.mimetype, mimetype, "Beacon mimetype should match expected. is: " + result.mimetype + " should be: " + mimetype);
|
||||
|
||||
runNextTest();
|
||||
});
|
||||
}
|
||||
|
||||
function runNextTest() {
|
||||
var test = tests.shift();
|
||||
setTimeout(test, 0);
|
||||
}
|
||||
|
||||
var beaconConvert = function() {};
|
||||
|
||||
function stringToArrayBuffer(input) {
|
||||
|
||||
var buffer = new ArrayBuffer(input.length * 2);
|
||||
var array = new Uint16Array(buffer);
|
||||
|
||||
// dumbly copy over the bytes
|
||||
for (var i = 0, len = input.length; i < len; i++) {
|
||||
array[i] = input.charCodeAt(i);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
function stringToBlob(input) {
|
||||
var blob = new Blob([input], {type : 'text/html'});
|
||||
return blob;
|
||||
}
|
||||
|
||||
function stringToFormData(input) {
|
||||
var formdata = new FormData();
|
||||
formdata.append(input, new Blob(['hi']));
|
||||
return formdata;
|
||||
}
|
||||
|
||||
function identity(data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
var tests = [
|
||||
function() { createIframeWithData("hi!", "text/plain;charset=UTF-8", identity); },
|
||||
function() { createIframeWithData("123", "application/octet-stream", stringToArrayBuffer); },
|
||||
function() { createIframeWithData("abc", "text/html", stringToBlob); },
|
||||
function() { createIframeWithData("qwerty", "multipart/form-data", stringToFormData); },
|
||||
function() { SimpleTest.finish(); },
|
||||
];
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,36 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=936340
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 936340</title>
|
||||
<script type="text/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=936340">Mozilla Bug 936340</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var beaconUrl = "http://mochi.test:8888/tests/dom/tests/mochitest/beacon/beacon-handler.sjs";
|
||||
|
||||
// not enabled by default yet.
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({'set': [["beacon.enabled", true]]}, beginTest);
|
||||
|
||||
function beginTest() {
|
||||
var abv = new Uint8Array([0,1,2,3]);
|
||||
var sent = navigator.sendBeacon(beaconUrl, abv);
|
||||
ok(sent, "non-standard content type allowed after pre-flight");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -7,7 +7,6 @@
|
||||
DIRS += [
|
||||
'dom-level0',
|
||||
'ajax',
|
||||
'beacon',
|
||||
'bugs',
|
||||
'crypto',
|
||||
'general',
|
||||
|
@ -11,7 +11,6 @@
|
||||
* http://www.w3.org/TR/vibration/#vibration-interface
|
||||
* http://www.w3.org/2012/sysapps/runtime/#extension-to-the-navigator-interface-1
|
||||
* https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension
|
||||
* http://www.w3.org/TR/beacon/#sec-beacon-method
|
||||
*
|
||||
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
|
||||
* Opera Software ASA. You are granted a license to use, reproduce
|
||||
@ -348,9 +347,3 @@ partial interface Navigator {
|
||||
optional unsigned long long innerWindowID = 0);
|
||||
};
|
||||
#endif // MOZ_MEDIA_NAVIGATOR
|
||||
|
||||
partial interface Navigator {
|
||||
[Throws, Pref="beacon.enabled"]
|
||||
boolean sendBeacon(DOMString url,
|
||||
optional (ArrayBufferView or Blob or DOMString or FormData)? data = null);
|
||||
};
|
||||
|
@ -111,7 +111,6 @@
|
||||
#define MULTIPART_ALTERNATIVE "multipart/alternative"
|
||||
#define MULTIPART_APPLEDOUBLE "multipart/appledouble"
|
||||
#define MULTIPART_DIGEST "multipart/digest"
|
||||
#define MULTIPART_FORM_DATA "multipart/form-data"
|
||||
#define MULTIPART_HEADER_SET "multipart/header-set"
|
||||
#define MULTIPART_MIXED "multipart/mixed"
|
||||
#define MULTIPART_PARALLEL "multipart/parallel"
|
||||
|
@ -140,12 +140,6 @@
|
||||
"dom/tests/mochitest/ajax/offline/test_updatingManifest.html":"",
|
||||
"dom/tests/mochitest/ajax/offline/test_xhtmlManifest.xhtml":"",
|
||||
|
||||
"dom/tests/mochitest/beacon/test_beacon.html":"",
|
||||
"dom/tests/mochitest/beacon/test_beaconContentPolicy.html":"",
|
||||
"dom/tests/mochitest/beacon/test_beaconCookies.html":"",
|
||||
"dom/tests/mochitest/beacon/test_beaconFrame.html":"",
|
||||
"dom/tests/mochitest/beacon/test_beaconPreflight.html":"",
|
||||
|
||||
"content/base/test/test_bug466080.html":"bug 901356, also fails on android",
|
||||
|
||||
"content/base/test/test_bug666604.html":"dom.disable_open_during_load not implemented in b2g",
|
||||
|
@ -141,12 +141,6 @@
|
||||
"dom/tests/mochitest/ajax/offline/test_updatingManifest.html":"",
|
||||
"dom/tests/mochitest/ajax/offline/test_xhtmlManifest.xhtml":"",
|
||||
|
||||
"dom/tests/mochitest/beacon/test_beacon.html":"",
|
||||
"dom/tests/mochitest/beacon/test_beaconContentPolicy.html":"",
|
||||
"dom/tests/mochitest/beacon/test_beaconCookies.html":"",
|
||||
"dom/tests/mochitest/beacon/test_beaconFrame.html":"",
|
||||
"dom/tests/mochitest/beacon/test_beaconPreflight.html":"",
|
||||
|
||||
"content/base/test/test_bug466080.html":"bug 901356, also fails on android",
|
||||
|
||||
"content/base/test/test_bug666604.html":"dom.disable_open_during_load not implemented in b2g",
|
||||
|
@ -130,12 +130,6 @@
|
||||
"dom/tests/mochitest/ajax/offline/test_updatingManifest.html":"",
|
||||
"dom/tests/mochitest/ajax/offline/test_xhtmlManifest.xhtml":"",
|
||||
|
||||
"dom/tests/mochitest/beacon/test_beacon.html":"",
|
||||
"dom/tests/mochitest/beacon/test_beaconContentPolicy.html":"",
|
||||
"dom/tests/mochitest/beacon/test_beaconCookies.html":"",
|
||||
"dom/tests/mochitest/beacon/test_beaconFrame.html":"",
|
||||
"dom/tests/mochitest/beacon/test_beaconPreflight.html":"",
|
||||
|
||||
"content/base/test/test_bug466080.html":"bug 901356, also fails on android",
|
||||
|
||||
"content/base/test/test_bug666604.html":"dom.disable_open_during_load not implemented in b2g",
|
||||
|
Loading…
Reference in New Issue
Block a user