mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1226200: Don't assume a TCPSocket has only one managee (and rename LoneManagedOrNull) r=jdm (aa2d0fcc14) - Bug 1227300, Part 1 - Add an alert notification component. r=MattN,wchen (37758ce9ff) - Bug 1230700. Make Notification::ShowInternal explicitly suppress the exception from GetPermissionInternal. r=smaug (9e288cf5ae) - Bug 1225336 - Add telemetry about web notification display/messages. r=wchen,kitcambridge p=vladan# Please enter the commit message for your changes. Lines starting (b2e481691a) - Bug 1219030 - Collect notification management telemetry. r=wchen,MattN; p=ally (c0ba425b4e) - Bug 1212611 - Use system notification for website notifications in Android. r=mfinkle (84985bcf01) - Bug 1227300, Part 2 - Implement showAlert. r=MattN,wchen (33eedc7e91) - Bug 1214305 - Part 0: Ensure site security service is initialized before trying to use DataStorage via IPC. (8bd73f43b0) - Bug 1137681 - Make user agent docshell overrides affect network requests. r=jduell (e8dabb8338) - Bug 1233245 - Propagate the interception information in the non-e10s case for all HTTP redirects, not just the internal ones; r=jdm (6922fddcf8) - Bug 1226444 - Use helper function to identify preloads. r=sicking (d110669f73) - Bug 1214305 - Part 1: Refactor the logic for querying whether a connection should go through a secure upgrade into NS_ShouldSecureUpgrade; r=mcmanus (2d04c78290) - Bug 1137681 - Per-tab user agent emulation. r=bz (4ff70db690) - Bug 1227300, Part 3 - Implement showAlert for the OS X alerts backend. r=mstange (5eb05d0728) - Bug 1227300, Part 4 - Implement showAlert for the libnotify alerts backend. r=karlt (0942fa2764) - Bug 1227300, Part 5 - Implement showAlert for the B2G alerts backend. r=mhenretty (e39581aea5) - Bug 1227300, Part 6 - Use showAlert to display web notifications. r=wchen (ab79eaa0c8) - domBug 1227300, Part 7 - Update test interfaces. a=testonly (387cb62772) - Bug 1214305 - Part 3: Add a nsIInterceptedChannel.secureUpgradedChannelURI helper; r=jdm (811d25bd58) - Bug 1214305 - Part 4: Use the secure upgraded channel URI in ServiceWorkerManager::PrepareFetchEvent; r=jdm (0c44bf527c) - Bug 1214305 - Part 5: Use the secure upgraded channel URI in FetchEventRunnable::Init; r=jdm (a30f239261) - Bug 1214305 - Part 6: Use a non-IPC redirect for synthesized upgraded responses to ensure the response URL is correctly propagated; r=mcmanus (8ba8a5728c) - Bug 1214305 - Part 7: Decide in the child process whether an intercepted channel should go through a secure upgrade; r=mcmanus (93e27decae) - Bug 1198397 - Add a test for interception of requests upgraded through the CSP upgrade-insecure-requests directive; r=jdm (21eb14eb34) - Bug 1214305 - Part 8: Enable secure upgrade service worker tests on e10s; r=jdm (c14f5fb504) - Bug 1214305 - Part 10: Clean up global DataStorage references in the child process; r=keeler (ef0b52d049) - Bug 1224771 - Close all web notifications when the originating tab is closed. r=wchen (da295b4ba7) - Bug 1214305 - Part 2: Refactor the logic for obtaining the secure upgraded URI into HttpBaseChannel; r=mcmanus (3346078285) - Bug 1237151 (part 1) - Remove ignored qualifiers in dom/media/gmp/. r=cpearce. (18134820a6) - Bug 1237151 (part 2) - Remove ignored qualifiers in WebRTC-relate code. r=jesup. (effe5bd694) - Bug 1118820 part 1 (style system part) - [css-grid] Implement the 'auto-fill' and 'auto-fit' keywords in the repeat() function. r=dholbert (5db1a577db) - Bug 1118820 part 2a - [css-grid] Add a LineNameMap class that lets us lookup line names with a dynamic number of 'repeat(auto-fill/auto-fit)' tracks taken into account. r=dholbert (3ecf4b53f0) - Bug 1118820 part 2b - [css-grid] Move the static functions FindLine/RFindLine/FindNamedLine into the LineNameMap class (idempotent patch). r=dholbert (efb12c594b) - Bug 1118820 part 2c+2d - [css-grid] Modify the LineNameMap::FindLine/RFindLine/FindNamedLine methods to take line names associated with 'repeat(auto-fill/auto-fit)' tracks into account. Instantiate and pass around a LineNameMap object instead of an array of line name arrays. r=dholbert (a3db750297) - Bug 1118820 part 3a - [css-grid] Modify TrackSizingFunctions to take a dynamic number of 'repeat(auto-fill/auto-fit)' tracks taking into account. r=dholbert (9aa6033332) - Bug 1118820 part 3b - [css-grid] Implement the CalculateRepeatFillCount method that calculates the number of 'repeat(auto-fill/auto-fit)' tracks to use for the given sizes. r=dholbert (cf75fab8a8) - Bug 1118820 part 4 - [css-grid] Provide the sizes to use for CalculateRepeatFillCount. r=dholbert (8184c00dba) - Bug 1118820 part 5 - [css-grid] Remove any empty 'repeat(auto-fit)' tracks at the end of its range and adjust affected grid area line numbers accordingly. r=dholbert (c02ba6a6e3) - Bug 1229165 - [css-grid] Reftests for min/max-width/height properties on the grid container. (725097f878) - Bug 1229999 - [css-grid] Reftest. (51b5bc9535) - Bug 1237151 (part 3) - Remove ignored qualifiers in all remaining code. r=froydnj. (69917ebbad) - more bits of Bug 1178892 - Split the profiler into Core & Gecko files (41bb127b9c) - Bug 1199841 - Restructure private browsing to remember status after OnStopRequest r=jdm (16c2c1044d) - Bug 1233845 - Report an interception error and cancel the HTTP channel when encountering a known topcrash situation. r=ehsan (5d08075110) - Bug 664163 - Fix Get(Local|Remote)(Address|Port) in HttpChannelChild. r=jduell (cbf70af4e8) - Bug 1229177 - Show the tracking protection shield for fetch and XHR requests. r=jduell (5833b3e872) - Bug 1220678 Don't crash when DivertToParent() is called on an intercepted channel. r=jdm (5d7ff6ecc8) - Bug 1220681 P1 Make HttpChannelChild::DivertToParent() work with synthetic responses. r=jdm (67715703ef) - Bug 1169819 Add browser chrome test to validate SW force refresh. r=ehsan (c0b6b3e874) - Bug 1220681 P2 Test synthetic responses that trigger downloads. r=ehsan (c701f3ddb1) - Bug 1220681 P3 Delay diversion on parent side until response head has been synthesized. r=jdm (7c697aacee) - Bug 1220681 P4 Automatically suspend the parent channel after synthesizing the response for diverison. r=jdm (27f31bcb35) - Bug 1220681 P5 Don't double suspend parent channel during synthesized divert to parent. r=jdm (62081d4b56) - Bug 1220681 P6 Use clients.claim() in browser_download.js to avoid worker unregister race. r=jdm (c8de291727) - Bug 1240161 - Remove "only-if-cached" from RequestCache; r=bkelly (283486f584) - Bug 1184550 - Add a mochitest for the Request constructor that tests that the body is set to used after being fetched and then fails on the second fetch with the same Request. r=bkelly (db4a967203) - Bug 1205495 - Correctly use the requests's body and redirect mode in reroute.js; r=nsm (a36a96624a) - Bug 1189656 - Fix fetch-request-fallback test paths. r=bkelly (366c884179) - Bug 1219085 - Import the fetch-request-redirect.https.html test from Blink; r=jdm (bf6b484d82) - Bug 1209081 - Part 1: Implement the "navigate" value for RequestMode; r=bkelly (a22f19d94b) - Bug 1209081 - Part 2: Upgrade the saved Requests in the DOM Cache to reflect the "navigate" RequestMode if they represent navigation content policy types; r=bkelly (60d1da23bb) - Bug 1219469 - Part 1: Revert the error reporting added in bug 1233845; r=jdm (dcc022b9d3) - Bug 1219469 - Part 2: Make HttpChannelParentListener be the controller; r=jdm,jduell (9c5f0dfbe0) - Bug 1229369 - Intercept redirected network fetches that have their request mode set to manual; r=jdm (fb21d86ed2)
This commit is contained in:
@@ -66,23 +66,36 @@ AlertsService.prototype = {
|
||||
},
|
||||
|
||||
// nsIAlertsService
|
||||
showAlert: function(aAlert, aAlertListener) {
|
||||
if (!aAlert) {
|
||||
return;
|
||||
}
|
||||
cpmm.sendAsyncMessage(kMessageAlertNotificationSend, {
|
||||
imageURL: aAlert.imageURL,
|
||||
title: aAlert.title,
|
||||
text: aAlert.text,
|
||||
clickable: aAlert.textClickable,
|
||||
cookie: aAlert.cookie,
|
||||
listener: aAlertListener,
|
||||
id: aAlert.name,
|
||||
dir: aAlert.dir,
|
||||
lang: aAlert.lang,
|
||||
dataStr: aAlert.data,
|
||||
inPrivateBrowsing: aAlert.inPrivateBrowsing
|
||||
});
|
||||
},
|
||||
|
||||
showAlertNotification: function(aImageUrl, aTitle, aText, aTextClickable,
|
||||
aCookie, aAlertListener, aName, aBidi,
|
||||
aLang, aDataStr, aPrincipal,
|
||||
aInPrivateBrowsing) {
|
||||
cpmm.sendAsyncMessage(kMessageAlertNotificationSend, {
|
||||
imageURL: aImageUrl,
|
||||
title: aTitle,
|
||||
text: aText,
|
||||
clickable: aTextClickable,
|
||||
cookie: aCookie,
|
||||
listener: aAlertListener,
|
||||
id: aName,
|
||||
dir: aBidi,
|
||||
lang: aLang,
|
||||
dataStr: aDataStr,
|
||||
inPrivateBrowsing: aInPrivateBrowsing
|
||||
});
|
||||
let alert = Cc["@mozilla.org/alert-notification;1"].
|
||||
createInstance(Ci.nsIAlertNotification);
|
||||
|
||||
alert.init(aName, aImageUrl, aTitle, aText, aTextClickable, aCookie,
|
||||
aBidi, aLang, aDataStr, aPrincipal, aInPrivateBrowsing);
|
||||
|
||||
this.showAlert(alert, aAlertListener);
|
||||
},
|
||||
|
||||
closeAlert: function(aName) {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "mozilla/StartupTimeline.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "Navigator.h"
|
||||
#include "URIUtils.h"
|
||||
|
||||
#include "nsIContent.h"
|
||||
@@ -3128,6 +3129,38 @@ nsDocShell::NameEquals(const char16_t* aName, bool* aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetCustomUserAgent(nsAString& aCustomUserAgent)
|
||||
{
|
||||
aCustomUserAgent = mCustomUserAgent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::SetCustomUserAgent(const nsAString& aCustomUserAgent)
|
||||
{
|
||||
mCustomUserAgent = aCustomUserAgent;
|
||||
RefPtr<nsGlobalWindow> win = mScriptGlobal ?
|
||||
mScriptGlobal->GetCurrentInnerWindowInternal() : nullptr;
|
||||
if (win) {
|
||||
ErrorResult ignored;
|
||||
Navigator* navigator = win->GetNavigator(ignored);
|
||||
ignored.SuppressException();
|
||||
if (navigator) {
|
||||
navigator->ClearUserAgentCache();
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t childCount = mChildList.Length();
|
||||
for (uint32_t i = 0; i < childCount; ++i) {
|
||||
nsCOMPtr<nsIDocShell> childShell = do_QueryInterface(ChildAt(i));
|
||||
if (childShell) {
|
||||
childShell->SetCustomUserAgent(aCustomUserAgent);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* virtual */ int32_t
|
||||
nsDocShell::ItemType()
|
||||
{
|
||||
@@ -3255,6 +3288,7 @@ nsDocShell::SetDocLoaderParent(nsDocLoader* aParent)
|
||||
// If parent is another docshell, we inherit all their flags for
|
||||
// allowing plugins, scripting etc.
|
||||
bool value;
|
||||
nsString customUserAgent;
|
||||
nsCOMPtr<nsIDocShell_ESR38> parentAsDocShell(do_QueryInterface(parent));
|
||||
if (parentAsDocShell) {
|
||||
if (NS_SUCCEEDED(parentAsDocShell->GetAllowPlugins(&value))) {
|
||||
@@ -3284,6 +3318,10 @@ nsDocShell::SetDocLoaderParent(nsDocLoader* aParent)
|
||||
if (parentAsDocShell->GetIsPrerendered()) {
|
||||
SetIsPrerendered(true);
|
||||
}
|
||||
if (NS_SUCCEEDED(parentAsDocShell->GetCustomUserAgent(customUserAgent)) &&
|
||||
!customUserAgent.IsEmpty()) {
|
||||
SetCustomUserAgent(customUserAgent);
|
||||
}
|
||||
if (NS_FAILED(parentAsDocShell->GetAllowDNSPrefetch(&value))) {
|
||||
value = false;
|
||||
}
|
||||
|
||||
@@ -797,6 +797,7 @@ protected:
|
||||
nsIntRect mBounds;
|
||||
nsString mName;
|
||||
nsString mTitle;
|
||||
nsString mCustomUserAgent;
|
||||
|
||||
/**
|
||||
* Content-Type Hint of the most-recently initiated load. Used for
|
||||
|
||||
@@ -46,7 +46,7 @@ interface nsITabParent;
|
||||
|
||||
typedef unsigned long nsLoadFlags;
|
||||
|
||||
[scriptable, builtinclass, uuid(63adb599-6dc9-4746-972e-c22e9018020b)]
|
||||
[scriptable, builtinclass, uuid(bc3524bd-023c-4fc8-ace1-472bc999fb12)]
|
||||
interface nsIDocShell : nsIDocShellTreeItem
|
||||
{
|
||||
/**
|
||||
@@ -232,6 +232,11 @@ interface nsIDocShell : nsIDocShellTreeItem
|
||||
*/
|
||||
attribute nsIDOMEventTarget chromeEventHandler;
|
||||
|
||||
/**
|
||||
* This allows chrome to set a custom User agent on a specific docshell
|
||||
*/
|
||||
attribute DOMString customUserAgent;
|
||||
|
||||
/**
|
||||
* Whether to allow plugin execution
|
||||
*/
|
||||
@@ -245,7 +250,7 @@ interface nsIDocShell : nsIDocShellTreeItem
|
||||
/**
|
||||
* Attribute stating if refresh based redirects can be allowed
|
||||
*/
|
||||
attribute boolean allowMetaRedirects;
|
||||
attribute boolean allowMetaRedirects;
|
||||
|
||||
/**
|
||||
* Attribute stating if it should allow subframes (framesets/iframes) or not
|
||||
|
||||
@@ -49,8 +49,8 @@ public:
|
||||
DOMHighResTimeStamp GetTime() const { return mTime; }
|
||||
MarkerTracingType GetTracingType() const { return mTracingType; }
|
||||
|
||||
const uint8_t GetProcessType() const { return mProcessType; };
|
||||
const bool IsOffMainThread() const { return mIsOffMainThread; };
|
||||
uint8_t GetProcessType() const { return mProcessType; };
|
||||
bool IsOffMainThread() const { return mIsOffMainThread; };
|
||||
|
||||
private:
|
||||
const char* mName;
|
||||
|
||||
@@ -106,6 +106,7 @@ skip-if = e10s # Bug ?????? - event handler checks event.target is the content d
|
||||
[browser_onbeforeunload_navigation.js]
|
||||
skip-if = e10s
|
||||
[browser_search_notification.js]
|
||||
[browser_ua_emulation.js]
|
||||
[browser_timelineMarkers-01.js]
|
||||
[browser_timelineMarkers-02.js]
|
||||
[browser_timelineMarkers-03.js]
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Test that the docShell UA emulation works
|
||||
add_task(function*() {
|
||||
yield openUrl("data:text/html;charset=utf-8,<iframe id='test-iframe'></iframe>");
|
||||
|
||||
let docshell = content.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShell);
|
||||
is(docshell.customUserAgent, "", "There should initially be no customUserAgent");
|
||||
|
||||
docshell.customUserAgent = "foo";
|
||||
is(content.navigator.userAgent, "foo", "The user agent should be changed to foo");
|
||||
|
||||
let frameWin = content.document.querySelector("#test-iframe").contentWindow;
|
||||
is(frameWin.navigator.userAgent, "foo", "The UA should be passed on to frames.");
|
||||
|
||||
let newFrame = content.document.createElement("iframe");
|
||||
content.document.body.appendChild(newFrame);
|
||||
|
||||
let newFrameWin = newFrame.contentWindow;
|
||||
is(newFrameWin.navigator.userAgent, "foo", "Newly created frames should use the new UA");
|
||||
|
||||
newFrameWin.location.reload();
|
||||
yield waitForEvent(newFrameWin, "load");
|
||||
|
||||
is(newFrameWin.navigator.userAgent, "foo", "New UA should persist across reloads");
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
function waitForEvent(target, event) {
|
||||
return new Promise(function(resolve) {
|
||||
target.addEventListener(event, resolve);
|
||||
});
|
||||
}
|
||||
|
||||
function openUrl(url) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
window.focus();
|
||||
|
||||
let tab = window.gBrowser.selectedTab = window.gBrowser.addTab(url);
|
||||
let linkedBrowser = tab.linkedBrowser;
|
||||
|
||||
linkedBrowser.addEventListener("load", function onload() {
|
||||
linkedBrowser.removeEventListener("load", onload, true);
|
||||
resolve(tab);
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
+21
-4
@@ -356,11 +356,22 @@ Navigator::GetUserAgent(nsAString& aUserAgent)
|
||||
nsCOMPtr<nsIURI> codebaseURI;
|
||||
nsCOMPtr<nsPIDOMWindow> window;
|
||||
|
||||
if (mWindow && mWindow->GetDocShell()) {
|
||||
if (mWindow) {
|
||||
window = mWindow;
|
||||
nsIDocument* doc = mWindow->GetExtantDoc();
|
||||
if (doc) {
|
||||
doc->NodePrincipal()->GetURI(getter_AddRefs(codebaseURI));
|
||||
nsIDocShell* docshell = window->GetDocShell();
|
||||
nsString customUserAgent;
|
||||
if (docshell) {
|
||||
docshell->GetCustomUserAgent(customUserAgent);
|
||||
|
||||
if (!customUserAgent.IsEmpty()) {
|
||||
aUserAgent = customUserAgent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDocument* doc = mWindow->GetExtantDoc();
|
||||
if (doc) {
|
||||
doc->NodePrincipal()->GetURI(getter_AddRefs(codebaseURI));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2693,6 +2704,12 @@ Navigator::AppName(nsAString& aAppName, bool aUsePrefOverriddenValue)
|
||||
aAppName.AssignLiteral("Netscape");
|
||||
}
|
||||
|
||||
void
|
||||
Navigator::ClearUserAgentCache()
|
||||
{
|
||||
NavigatorBinding::ClearCachedUserAgentValue(this);
|
||||
}
|
||||
|
||||
nsresult
|
||||
Navigator::GetUserAgent(nsPIDOMWindow* aWindow, nsIURI* aURI,
|
||||
bool aIsCallerChrome,
|
||||
|
||||
@@ -179,6 +179,10 @@ public:
|
||||
bool aIsCallerChrome,
|
||||
nsAString& aUserAgent);
|
||||
|
||||
// Clears the user agent cache by calling:
|
||||
// NavigatorBinding::ClearCachedUserAgentValue(this);
|
||||
void ClearUserAgentCache();
|
||||
|
||||
already_AddRefed<Promise> GetDataStores(const nsAString& aName,
|
||||
const nsAString& aOwner,
|
||||
ErrorResult& aRv);
|
||||
|
||||
@@ -2573,7 +2573,10 @@ nsDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
|
||||
if (sameTypeParent) {
|
||||
mUpgradeInsecureRequests =
|
||||
sameTypeParent->GetDocument()->GetUpgradeInsecureRequests();
|
||||
// if the parent document makes use of upgrade-insecure-requests
|
||||
// then subdocument preloads should always be upgraded.
|
||||
mUpgradeInsecurePreloads =
|
||||
mUpgradeInsecureRequests ||
|
||||
sameTypeParent->GetDocument()->GetUpgradeInsecurePreloads();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ MSG_DEF(MSG_INVALID_HEADER_SEQUENCE, 0, JSEXN_TYPEERR, "Headers require name/val
|
||||
MSG_DEF(MSG_PERMISSION_DENIED_TO_PASS_ARG, 1, JSEXN_TYPEERR, "Permission denied to pass cross-origin object as {0}.")
|
||||
MSG_DEF(MSG_MISSING_REQUIRED_DICTIONARY_MEMBER, 1, JSEXN_TYPEERR, "Missing required {0}.")
|
||||
MSG_DEF(MSG_INVALID_REQUEST_METHOD, 1, JSEXN_TYPEERR, "Invalid request method {0}.")
|
||||
MSG_DEF(MSG_INVALID_REQUEST_MODE, 1, JSEXN_TYPEERR, "Invalid request mode {0}.")
|
||||
MSG_DEF(MSG_FETCH_BODY_CONSUMED_ERROR, 0, JSEXN_TYPEERR, "Body has already been consumed.")
|
||||
MSG_DEF(MSG_RESPONSE_INVALID_STATUSTEXT_ERROR, 0, JSEXN_TYPEERR, "Response statusText may not contain newline or carriage return.")
|
||||
MSG_DEF(MSG_FETCH_FAILED, 0, JSEXN_TYPEERR, "NetworkError when attempting to fetch resource.")
|
||||
|
||||
Vendored
+71
-4
@@ -37,7 +37,7 @@ const int32_t kFirstShippedSchemaVersion = 15;
|
||||
namespace {
|
||||
|
||||
// Update this whenever the DB schema is changed.
|
||||
const int32_t kLatestSchemaVersion = 17;
|
||||
const int32_t kLatestSchemaVersion = 19;
|
||||
|
||||
// ---------
|
||||
// The following constants define the SQL schema. These are defined in the
|
||||
@@ -192,7 +192,8 @@ static_assert(int(HeadersGuardEnum::None) == 0 &&
|
||||
static_assert(int(RequestMode::Same_origin) == 0 &&
|
||||
int(RequestMode::No_cors) == 1 &&
|
||||
int(RequestMode::Cors) == 2 &&
|
||||
int(RequestMode::EndGuard_) == 3,
|
||||
int(RequestMode::Navigate) == 3 &&
|
||||
int(RequestMode::EndGuard_) == 4,
|
||||
"RequestMode values are as expected");
|
||||
static_assert(int(RequestCredentials::Omit) == 0 &&
|
||||
int(RequestCredentials::Same_origin) == 1 &&
|
||||
@@ -204,8 +205,7 @@ static_assert(int(RequestCache::Default) == 0 &&
|
||||
int(RequestCache::Reload) == 2 &&
|
||||
int(RequestCache::No_cache) == 3 &&
|
||||
int(RequestCache::Force_cache) == 4 &&
|
||||
int(RequestCache::Only_if_cached) == 5 &&
|
||||
int(RequestCache::EndGuard_) == 6,
|
||||
int(RequestCache::EndGuard_) == 5,
|
||||
"RequestCache values are as expected");
|
||||
static_assert(int(RequestRedirect::Follow) == 0 &&
|
||||
int(RequestRedirect::Error) == 1 &&
|
||||
@@ -2411,11 +2411,15 @@ struct Migration
|
||||
// the version by a single increment. Don't skip versions.
|
||||
nsresult MigrateFrom15To16(mozIStorageConnection* aConn);
|
||||
nsresult MigrateFrom16To17(mozIStorageConnection* aConn);
|
||||
nsresult MigrateFrom17To18(mozIStorageConnection* aConn);
|
||||
nsresult MigrateFrom18To19(mozIStorageConnection* aConn);
|
||||
|
||||
// Configure migration functions to run for the given starting version.
|
||||
Migration sMigrationList[] = {
|
||||
Migration(15, MigrateFrom15To16),
|
||||
Migration(16, MigrateFrom16To17),
|
||||
Migration(17, MigrateFrom17To18),
|
||||
Migration(18, MigrateFrom18To19),
|
||||
};
|
||||
|
||||
uint32_t sMigrationListLength = sizeof(sMigrationList) / sizeof(Migration);
|
||||
@@ -2653,6 +2657,69 @@ MigrateFrom16To17(mozIStorageConnection* aConn)
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
MigrateFrom17To18(mozIStorageConnection* aConn)
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
MOZ_ASSERT(aConn);
|
||||
|
||||
mozStorageTransaction trans(aConn, true,
|
||||
mozIStorageConnection::TRANSACTION_IMMEDIATE);
|
||||
|
||||
// This migration is needed in order to remove "only-if-cached" RequestCache
|
||||
// values from the database. This enum value was removed from the spec in
|
||||
// https://github.com/whatwg/fetch/issues/39 but we unfortunately happily
|
||||
// accepted this value in the Request constructor.
|
||||
//
|
||||
// There is no good value to upgrade this to, so we just stick to "default".
|
||||
|
||||
static_assert(int(RequestCache::Default) == 0,
|
||||
"This is where the 0 below comes from!");
|
||||
nsresult rv = aConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"UPDATE entries SET request_cache = 0 "
|
||||
"WHERE request_cache = 5;"
|
||||
));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
rv = aConn->SetSchemaVersion(18);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
MigrateFrom18To19(mozIStorageConnection* aConn)
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
MOZ_ASSERT(aConn);
|
||||
|
||||
mozStorageTransaction trans(aConn, true,
|
||||
mozIStorageConnection::TRANSACTION_IMMEDIATE);
|
||||
|
||||
// This migration is needed in order to update the RequestMode values for
|
||||
// Request objects corresponding to a navigation content policy type to
|
||||
// "navigate".
|
||||
|
||||
static_assert(int(nsIContentPolicy::TYPE_DOCUMENT) == 6 &&
|
||||
int(nsIContentPolicy::TYPE_SUBDOCUMENT) == 7 &&
|
||||
int(nsIContentPolicy::TYPE_INTERNAL_FRAME) == 28 &&
|
||||
int(nsIContentPolicy::TYPE_INTERNAL_IFRAME) == 29 &&
|
||||
int(nsIContentPolicy::TYPE_REFRESH) == 8 &&
|
||||
int(RequestMode::Navigate) == 3,
|
||||
"This is where the numbers below come from!");
|
||||
nsresult rv = aConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"UPDATE entries SET request_mode = 3 "
|
||||
"WHERE request_contentpolicytype IN (6, 7, 28, 29, 8);"
|
||||
));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
rv = aConn->SetSchemaVersion(19);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
} // namespace db
|
||||
|
||||
Vendored
+3
@@ -18,6 +18,9 @@ var sts = Cc['@mozilla.org/network/stream-transport-service;1']
|
||||
var hash = Cc['@mozilla.org/security/hash;1']
|
||||
.createInstance(Ci.nsICryptoHash);
|
||||
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
prefs.setBoolPref("dom.requestcache.enabled", true);
|
||||
|
||||
// Expose Cache and Fetch symbols on the global
|
||||
Cu.importGlobalProperties(['caches', 'fetch']);
|
||||
|
||||
|
||||
BIN
Binary file not shown.
+2
@@ -20,6 +20,8 @@ function run_test() {
|
||||
requestList.forEach(function(request) {
|
||||
ok(request, 'each request in list should be non-null');
|
||||
ok(request.redirect === 'follow', 'request.redirect should default to "follow"');
|
||||
ok(request.cache === 'default', 'request.cache should have been updated to "default"' + request.cache);
|
||||
ok(request.mode === 'navigate', 'request.mode should have been updated to "navigate"');
|
||||
});
|
||||
return Promise.all(requestList.map(function(request) {
|
||||
return cache.match(request);
|
||||
|
||||
@@ -161,7 +161,8 @@ FetchDriver::HttpFetch()
|
||||
nsSecurityFlags secFlags = nsILoadInfo::SEC_ABOUT_BLANK_INHERITS;
|
||||
if (mRequest->Mode() == RequestMode::Cors) {
|
||||
secFlags |= nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS;
|
||||
} else if (mRequest->Mode() == RequestMode::Same_origin) {
|
||||
} else if (mRequest->Mode() == RequestMode::Same_origin ||
|
||||
mRequest->Mode() == RequestMode::Navigate) {
|
||||
secFlags |= nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS;
|
||||
} else if (mRequest->Mode() == RequestMode::No_cors) {
|
||||
secFlags |= nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS;
|
||||
|
||||
@@ -276,14 +276,13 @@ InternalRequest::MapChannelToRequestMode(nsIChannel* aChannel)
|
||||
nsCOMPtr<nsILoadInfo> loadInfo;
|
||||
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(aChannel->GetLoadInfo(getter_AddRefs(loadInfo))));
|
||||
|
||||
// RequestMode deviates from our internal security mode for navigations.
|
||||
// While navigations normally allow cross origin we must set a same-origin
|
||||
// RequestMode to get the correct service worker interception restrictions
|
||||
// in place.
|
||||
// TODO: remove the worker override once securityMode is fully implemented (bug 1189945)
|
||||
nsContentPolicyType contentPolicy = loadInfo->InternalContentPolicyType();
|
||||
if (IsNavigationContentPolicy(contentPolicy) ||
|
||||
IsWorkerContentPolicy(contentPolicy)) {
|
||||
if (IsNavigationContentPolicy(contentPolicy)) {
|
||||
return RequestMode::Navigate;
|
||||
}
|
||||
|
||||
// TODO: remove the worker override once securityMode is fully implemented (bug 1189945)
|
||||
if (IsWorkerContentPolicy(contentPolicy)) {
|
||||
return RequestMode::Same_origin;
|
||||
}
|
||||
|
||||
@@ -320,6 +319,7 @@ InternalRequest::MapChannelToRequestMode(nsIChannel* aChannel)
|
||||
|
||||
uint32_t corsMode;
|
||||
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(httpChannel->GetCorsMode(&corsMode)));
|
||||
MOZ_ASSERT(corsMode != nsIHttpChannelInternal::CORS_MODE_NAVIGATE);
|
||||
|
||||
// This cast is valid due to static asserts in ServiceWorkerManager.cpp.
|
||||
return static_cast<RequestMode>(corsMode);
|
||||
|
||||
@@ -284,6 +284,11 @@ Request::Constructor(const GlobalObject& aGlobal,
|
||||
aInit.mCredentials.WasPassed() ? aInit.mCredentials.Value()
|
||||
: fallbackCredentials;
|
||||
|
||||
if (mode == RequestMode::Navigate) {
|
||||
aRv.ThrowTypeError<MSG_INVALID_REQUEST_MODE>(NS_LITERAL_STRING("navigate"));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (mode != RequestMode::EndGuard_) {
|
||||
request->ClearCreatedByFetchEvent();
|
||||
request->SetMode(mode);
|
||||
|
||||
@@ -93,7 +93,7 @@ class Gamepad {
|
||||
// Index given by our superclass.
|
||||
uint32_t mSuperIndex;
|
||||
|
||||
const bool isDpad(IOHIDElementRef element) const
|
||||
bool isDpad(IOHIDElementRef element) const
|
||||
{
|
||||
return element == mDpad;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ InputPortData::GetId() const
|
||||
return mId;
|
||||
}
|
||||
|
||||
const InputPortType
|
||||
InputPortType
|
||||
InputPortData::GetType() const
|
||||
{
|
||||
return ToInputPortType(mType);
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
|
||||
const nsString& GetId() const;
|
||||
|
||||
const InputPortType GetType() const;
|
||||
InputPortType GetType() const;
|
||||
|
||||
private:
|
||||
~InputPortData();
|
||||
|
||||
@@ -98,7 +98,7 @@ ContentBridgeChild::SendPBrowserConstructor(PBrowserChild* aActor,
|
||||
jsipc::CPOWManager*
|
||||
ContentBridgeChild::GetCPOWManager()
|
||||
{
|
||||
if (PJavaScriptChild* c = LoneManagedOrNull(ManagedPJavaScriptChild())) {
|
||||
if (PJavaScriptChild* c = LoneManagedOrNullAsserts(ManagedPJavaScriptChild())) {
|
||||
return CPOWManagerFor(c);
|
||||
}
|
||||
return CPOWManagerFor(SendPJavaScriptConstructor());
|
||||
|
||||
@@ -180,7 +180,7 @@ ContentBridgeParent::NotifyTabDestroyed()
|
||||
jsipc::CPOWManager*
|
||||
ContentBridgeParent::GetCPOWManager()
|
||||
{
|
||||
if (PJavaScriptParent* p = LoneManagedOrNull(ManagedPJavaScriptParent())) {
|
||||
if (PJavaScriptParent* p = LoneManagedOrNullAsserts(ManagedPJavaScriptParent())) {
|
||||
return CPOWManagerFor(p);
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
@@ -1718,7 +1718,7 @@ ContentChild::DeallocPTestShellChild(PTestShellChild* shell)
|
||||
jsipc::CPOWManager*
|
||||
ContentChild::GetCPOWManager()
|
||||
{
|
||||
if (PJavaScriptChild* c = LoneManagedOrNull(ManagedPJavaScriptChild())) {
|
||||
if (PJavaScriptChild* c = LoneManagedOrNullAsserts(ManagedPJavaScriptChild())) {
|
||||
return CPOWManagerFor(c);
|
||||
}
|
||||
return CPOWManagerFor(SendPJavaScriptConstructor());
|
||||
@@ -2221,7 +2221,7 @@ ContentChild::ProcessingError(Result aCode, const char* aReason)
|
||||
}
|
||||
|
||||
#if defined(MOZ_CRASHREPORTER) && !defined(MOZ_B2G)
|
||||
if (PCrashReporterChild* c = LoneManagedOrNull(ManagedPCrashReporterChild())) {
|
||||
if (PCrashReporterChild* c = LoneManagedOrNullAsserts(ManagedPCrashReporterChild())) {
|
||||
CrashReporterChild* crashReporter =
|
||||
static_cast<CrashReporterChild*>(c);
|
||||
nsDependentCString reason(aReason);
|
||||
|
||||
+19
-15
@@ -2152,7 +2152,7 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
|
||||
// There's a window in which child processes can crash
|
||||
// after IPC is established, but before a crash reporter
|
||||
// is created.
|
||||
if (PCrashReporterParent* p = LoneManagedOrNull(ManagedPCrashReporterParent())) {
|
||||
if (PCrashReporterParent* p = LoneManagedOrNullAsserts(ManagedPCrashReporterParent())) {
|
||||
CrashReporterParent* crashReporter =
|
||||
static_cast<CrashReporterParent*>(p);
|
||||
|
||||
@@ -2333,7 +2333,7 @@ ContentParent::NotifyTabDestroyed(const TabId& aTabId,
|
||||
jsipc::CPOWManager*
|
||||
ContentParent::GetCPOWManager()
|
||||
{
|
||||
if (PJavaScriptParent* p = LoneManagedOrNull(ManagedPJavaScriptParent())) {
|
||||
if (PJavaScriptParent* p = LoneManagedOrNullAsserts(ManagedPJavaScriptParent())) {
|
||||
return CPOWManagerFor(p);
|
||||
}
|
||||
return nullptr;
|
||||
@@ -2354,7 +2354,7 @@ ContentParent::DestroyTestShell(TestShellParent* aTestShell)
|
||||
TestShellParent*
|
||||
ContentParent::GetTestShellSingleton()
|
||||
{
|
||||
PTestShellParent* p = LoneManagedOrNull(ManagedPTestShellParent());
|
||||
PTestShellParent* p = LoneManagedOrNullAsserts(ManagedPTestShellParent());
|
||||
return static_cast<TestShellParent*>(p);
|
||||
}
|
||||
|
||||
@@ -2741,6 +2741,9 @@ bool
|
||||
ContentParent::RecvReadDataStorageArray(const nsString& aFilename,
|
||||
InfallibleTArray<DataStorageItem>* aValues)
|
||||
{
|
||||
// Ensure the SSS is initialized before we try to use its storage.
|
||||
nsCOMPtr<nsISiteSecurityService> sss = do_GetService("@mozilla.org/ssservice;1");
|
||||
|
||||
RefPtr<DataStorage> storage = DataStorage::Get(aFilename);
|
||||
storage->GetAll(aValues);
|
||||
return true;
|
||||
@@ -3635,7 +3638,7 @@ ContentParent::KillHard(const char* aReason)
|
||||
// We're about to kill the child process associated with this content.
|
||||
// Something has gone wrong to get us here, so we generate a minidump
|
||||
// of the parent and child for submission to the crash server.
|
||||
if (PCrashReporterParent* p = LoneManagedOrNull(ManagedPCrashReporterParent())) {
|
||||
if (PCrashReporterParent* p = LoneManagedOrNullAsserts(ManagedPCrashReporterParent())) {
|
||||
CrashReporterParent* crashReporter =
|
||||
static_cast<CrashReporterParent*>(p);
|
||||
// GeneratePairedMinidump creates two minidumps for us - the main
|
||||
@@ -4395,23 +4398,24 @@ ContentParent::HasNotificationPermission(const IPC::Principal& aPrincipal)
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::RecvShowAlertNotification(const nsString& aImageUrl, const nsString& aTitle,
|
||||
const nsString& aText, const bool& aTextClickable,
|
||||
const nsString& aCookie, const nsString& aName,
|
||||
const nsString& aBidi, const nsString& aLang,
|
||||
const nsString& aData,
|
||||
const IPC::Principal& aPrincipal,
|
||||
const bool& aInPrivateBrowsing)
|
||||
ContentParent::RecvShowAlert(const AlertNotificationType& aAlert)
|
||||
{
|
||||
if (!HasNotificationPermission(aPrincipal)) {
|
||||
nsCOMPtr<nsIAlertNotification> alert(dont_AddRef(aAlert));
|
||||
if (NS_WARN_IF(!alert)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
nsresult rv = alert->GetPrincipal(getter_AddRefs(principal));
|
||||
if (NS_WARN_IF(NS_FAILED(rv)) ||
|
||||
!HasNotificationPermission(IPC::Principal(principal))) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAlertsService> sysAlerts(do_GetService(NS_ALERTSERVICE_CONTRACTID));
|
||||
if (sysAlerts) {
|
||||
sysAlerts->ShowAlertNotification(aImageUrl, aTitle, aText, aTextClickable,
|
||||
aCookie, this, aName, aBidi, aLang,
|
||||
aData, aPrincipal, aInPrivateBrowsing);
|
||||
sysAlerts->ShowAlert(alert, this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -780,13 +780,7 @@ private:
|
||||
|
||||
bool HasNotificationPermission(const IPC::Principal& aPrincipal);
|
||||
|
||||
virtual bool RecvShowAlertNotification(const nsString& aImageUrl, const nsString& aTitle,
|
||||
const nsString& aText, const bool& aTextClickable,
|
||||
const nsString& aCookie, const nsString& aName,
|
||||
const nsString& aBidi, const nsString& aLang,
|
||||
const nsString& aData,
|
||||
const IPC::Principal& aPrincipal,
|
||||
const bool& aInPrivateBrowsing) override;
|
||||
virtual bool RecvShowAlert(const AlertNotificationType& aAlert) override;
|
||||
|
||||
virtual bool RecvCloseAlert(const nsString& aName,
|
||||
const IPC::Principal& aPrincipal) override;
|
||||
|
||||
@@ -35,7 +35,7 @@ CrashReporterChild::GetCrashReporter()
|
||||
if (!reporters) {
|
||||
return nullptr;
|
||||
}
|
||||
return LoneManagedOrNull(*reporters);
|
||||
return LoneManagedOrNullAsserts(*reporters);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
||||
+2
-11
@@ -74,6 +74,7 @@ include "mozilla/dom/PContentBridgeParent.h";
|
||||
include "mozilla/dom/quota/SerializationHelpers.h";
|
||||
|
||||
using GeoPosition from "nsGeoPositionIPCSerialiser.h";
|
||||
using AlertNotificationType from "mozilla/AlertNotificationIPCSerializer.h";
|
||||
|
||||
using struct ChromePackage from "mozilla/chrome/RegistryMessageUtils.h";
|
||||
using struct SubstitutionMapping from "mozilla/chrome/RegistryMessageUtils.h";
|
||||
@@ -864,17 +865,7 @@ parent:
|
||||
CpowEntry[] aCpows, Principal aPrincipal)
|
||||
returns (StructuredCloneData[] retval);
|
||||
|
||||
ShowAlertNotification(nsString imageUrl,
|
||||
nsString title,
|
||||
nsString text,
|
||||
bool textClickable,
|
||||
nsString cookie,
|
||||
nsString name,
|
||||
nsString bidi,
|
||||
nsString lang,
|
||||
nsString data,
|
||||
Principal principal,
|
||||
bool inPrivateBrowsing);
|
||||
ShowAlert(AlertNotificationType alert);
|
||||
|
||||
CloseAlert(nsString name, Principal principal);
|
||||
|
||||
|
||||
@@ -2324,7 +2324,7 @@ TabParent::GetTabIdFrom(nsIDocShell *docShell)
|
||||
RenderFrameParent*
|
||||
TabParent::GetRenderFrame()
|
||||
{
|
||||
PRenderFrameParent* p = LoneManagedOrNull(ManagedPRenderFrameParent());
|
||||
PRenderFrameParent* p = LoneManagedOrNullAsserts(ManagedPRenderFrameParent());
|
||||
return static_cast<RenderFrameParent*>(p);
|
||||
}
|
||||
|
||||
|
||||
@@ -172,3 +172,6 @@ PEExpectedVariableName=Expected identifier for variable name but found '%1$S'.
|
||||
PEExpectedVariableFallback=Expected variable reference fallback after ','.
|
||||
PEExpectedVariableCommaOrCloseParen=Expected ',' or ')' after variable name in variable reference but found '%1$S'.
|
||||
PESubgridNotSupported=Support for the 'subgrid' keyword of CSS Grid is not enabled.
|
||||
PEMoreThanOneGridRepeatAutoFillInNameList=Only one repeat(auto-fill, ...) is allowed in a name list for a subgrid.
|
||||
PEMoreThanOneGridRepeatAutoFillFitInTrackList=Only one repeat(auto-fill, ...) or repeat(auto-fit, ...) is allowed in a track list.
|
||||
PEMoreThanOneGridRepeatTrackSize=Only one track size is allowed inside repeat(auto-fit/auto-fill, ...).
|
||||
|
||||
@@ -17,7 +17,7 @@ class AndroidMediaDecoder : public MediaDecoder
|
||||
public:
|
||||
AndroidMediaDecoder(MediaDecoderOwner* aOwner, const nsACString& aType);
|
||||
|
||||
const nsresult GetContentType(nsACString& aType) const {
|
||||
nsresult GetContentType(nsACString& aType) const {
|
||||
aType = mType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
{
|
||||
mPluginId = aPluginId;
|
||||
}
|
||||
const uint32_t GetPluginId()
|
||||
uint32_t GetPluginId() const
|
||||
{
|
||||
return mPluginId;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
|
||||
// GMPDecryptorProxy
|
||||
|
||||
virtual const uint32_t GetPluginId() const override { return mPluginId; }
|
||||
virtual uint32_t GetPluginId() const override { return mPluginId; }
|
||||
|
||||
virtual nsresult Init(GMPDecryptorProxyCallback* aCallback) override;
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class GMPDecryptorProxy {
|
||||
public:
|
||||
~GMPDecryptorProxy() {}
|
||||
|
||||
virtual const uint32_t GetPluginId() const = 0;
|
||||
virtual uint32_t GetPluginId() const = 0;
|
||||
|
||||
virtual nsresult Init(GMPDecryptorProxyCallback* aCallback) = 0;
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ GMPStringListImpl::GMPStringListImpl(const nsTArray<nsCString>& aStrings)
|
||||
{
|
||||
}
|
||||
|
||||
const uint32_t
|
||||
uint32_t
|
||||
GMPStringListImpl::Size() const
|
||||
{
|
||||
return mStrings.Length();
|
||||
|
||||
@@ -19,7 +19,7 @@ class GMPStringListImpl : public GMPStringList
|
||||
{
|
||||
public:
|
||||
explicit GMPStringListImpl(const nsTArray<nsCString>& aStrings);
|
||||
virtual const uint32_t Size() const override;
|
||||
virtual uint32_t Size() const override;
|
||||
virtual void StringAt(uint32_t aIndex,
|
||||
const char** aOutString, uint32_t *aOutLength) const override;
|
||||
virtual ~GMPStringListImpl() override;
|
||||
|
||||
@@ -582,7 +582,7 @@ void
|
||||
GMPParent::GetCrashID(nsString& aResult)
|
||||
{
|
||||
CrashReporterParent* cr =
|
||||
static_cast<CrashReporterParent*>(LoneManagedOrNull(ManagedPCrashReporterParent()));
|
||||
static_cast<CrashReporterParent*>(LoneManagedOrNullAsserts(ManagedPCrashReporterParent()));
|
||||
if (NS_WARN_IF(!cr)) {
|
||||
return;
|
||||
}
|
||||
@@ -936,7 +936,7 @@ GMPParent::GetVersion() const
|
||||
return mVersion;
|
||||
}
|
||||
|
||||
const uint32_t
|
||||
uint32_t
|
||||
GMPParent::GetPluginId() const
|
||||
{
|
||||
return mPluginId;
|
||||
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
|
||||
const nsCString& GetDisplayName() const;
|
||||
const nsCString& GetVersion() const;
|
||||
const uint32_t GetPluginId() const;
|
||||
uint32_t GetPluginId() const;
|
||||
nsString GetPluginBaseName() const;
|
||||
|
||||
// Returns true if a plugin can be or is being used across multiple NodeIds.
|
||||
|
||||
@@ -105,7 +105,7 @@ protected:
|
||||
nsIDocument* aDocument);
|
||||
void Run(const nsACString& aPluginName);
|
||||
bool IsStillValid();
|
||||
const uint32_t GetPluginId() const { return mPluginId; }
|
||||
uint32_t GetPluginId() const { return mPluginId; }
|
||||
private:
|
||||
virtual ~GMPCrashCallback() { MOZ_ASSERT(NS_IsMainThread()); }
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
int64_t aRenderTimeMs = -1) override;
|
||||
virtual nsresult Reset() override;
|
||||
virtual nsresult Drain() override;
|
||||
virtual const uint32_t GetPluginId() const override { return mPluginId; }
|
||||
virtual uint32_t GetPluginId() const override { return mPluginId; }
|
||||
virtual const nsCString& GetDisplayName() const override;
|
||||
|
||||
// GMPSharedMemManager
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
int64_t aRenderTimeMs = -1) = 0;
|
||||
virtual nsresult Reset() = 0;
|
||||
virtual nsresult Drain() = 0;
|
||||
virtual const uint32_t GetPluginId() const = 0;
|
||||
virtual uint32_t GetPluginId() const = 0;
|
||||
|
||||
// Call to tell GMP/plugin the consumer will no longer use this
|
||||
// interface/codec.
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
virtual GMPErr SetChannelParameters(uint32_t aPacketLoss, uint32_t aRTT) override;
|
||||
virtual GMPErr SetRates(uint32_t aNewBitRate, uint32_t aFrameRate) override;
|
||||
virtual GMPErr SetPeriodicKeyFrames(bool aEnable) override;
|
||||
virtual const uint32_t GetPluginId() const override { return mPluginId; }
|
||||
virtual uint32_t GetPluginId() const override { return mPluginId; }
|
||||
|
||||
// GMPSharedMemManager
|
||||
virtual bool Alloc(size_t aSize, Shmem::SharedMemory::SharedMemoryType aType, Shmem* aMem) override
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
virtual GMPErr SetChannelParameters(uint32_t aPacketLoss, uint32_t aRTT) = 0;
|
||||
virtual GMPErr SetRates(uint32_t aNewBitRate, uint32_t aFrameRate) = 0;
|
||||
virtual GMPErr SetPeriodicKeyFrames(bool aEnable) = 0;
|
||||
virtual const uint32_t GetPluginId() const = 0;
|
||||
virtual uint32_t GetPluginId() const = 0;
|
||||
|
||||
// Call to tell GMP/plugin the consumer will no longer use this
|
||||
// interface/codec.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
class GMPStringList {
|
||||
public:
|
||||
virtual const uint32_t Size() const = 0;
|
||||
virtual uint32_t Size() const = 0;
|
||||
|
||||
virtual void StringAt(uint32_t aIndex,
|
||||
const char** aOutString, uint32_t* aOutLength) const = 0;
|
||||
|
||||
@@ -713,7 +713,7 @@ public:
|
||||
private:
|
||||
uint8_t* GetPointer() { return mData + mOffset; }
|
||||
|
||||
const size_t AvailableSize() { return mCapicity - mOffset; }
|
||||
size_t AvailableSize() const { return mCapicity - mOffset; }
|
||||
|
||||
void IncreaseOffset(size_t aValue)
|
||||
{
|
||||
@@ -722,12 +722,12 @@ private:
|
||||
mOffset += aValue;
|
||||
}
|
||||
|
||||
bool IsEmpty()
|
||||
bool IsEmpty() const
|
||||
{
|
||||
return (mOffset == 0);
|
||||
}
|
||||
|
||||
const size_t GetCapacity()
|
||||
size_t GetCapacity() const
|
||||
{
|
||||
return mCapicity;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
virtual bool IsFake() = 0;
|
||||
|
||||
/* Returns the type of media source (camera, microphone, screen, window, etc) */
|
||||
virtual const dom::MediaSourceEnum GetMediaSource() = 0;
|
||||
virtual dom::MediaSourceEnum GetMediaSource() const = 0;
|
||||
|
||||
// Callback interface for TakePhoto(). Either PhotoComplete() or PhotoError()
|
||||
// should be called.
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual const dom::MediaSourceEnum GetMediaSource() override {
|
||||
virtual dom::MediaSourceEnum GetMediaSource() const override {
|
||||
return dom::MediaSourceEnum::Camera;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual const dom::MediaSourceEnum GetMediaSource() override {
|
||||
virtual dom::MediaSourceEnum GetMediaSource() const override {
|
||||
return dom::MediaSourceEnum::Microphone;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
SourceMediaStream* aSource,
|
||||
TrackID aId,
|
||||
StreamTime aDesiredTime) override;
|
||||
virtual const dom::MediaSourceEnum GetMediaSource() override {
|
||||
virtual dom::MediaSourceEnum GetMediaSource() const override {
|
||||
return dom::MediaSourceEnum::Camera;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
SourceMediaStream* aSource,
|
||||
TrackID aId,
|
||||
StreamTime aDesiredTime) override;
|
||||
virtual const dom::MediaSourceEnum GetMediaSource() override {
|
||||
virtual dom::MediaSourceEnum GetMediaSource() const override {
|
||||
return mMediaSource;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class MediaEngineTabVideoSource : public MediaEngineVideoSource, nsIDOMEventList
|
||||
const nsString& aDeviceId) override;
|
||||
virtual nsresult Config(bool, uint32_t, bool, uint32_t, bool, uint32_t, int32_t) override;
|
||||
virtual bool IsFake() override;
|
||||
virtual const dom::MediaSourceEnum GetMediaSource() override {
|
||||
virtual dom::MediaSourceEnum GetMediaSource() const override {
|
||||
return dom::MediaSourceEnum::Browser;
|
||||
}
|
||||
virtual uint32_t GetBestFitnessDistance(
|
||||
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
void NotifyPull(MediaStreamGraph* aGraph, SourceMediaStream* aSource,
|
||||
TrackID aID, StreamTime aDesiredTime) override
|
||||
{}
|
||||
const dom::MediaSourceEnum GetMediaSource() override
|
||||
dom::MediaSourceEnum GetMediaSource() const override
|
||||
{
|
||||
return dom::MediaSourceEnum::AudioCapture;
|
||||
}
|
||||
@@ -178,7 +178,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual const dom::MediaSourceEnum GetMediaSource() override {
|
||||
virtual dom::MediaSourceEnum GetMediaSource() const override {
|
||||
return dom::MediaSourceEnum::Microphone;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ uint32_t
|
||||
TCPServerSocketParent::GetAppId()
|
||||
{
|
||||
const PContentParent *content = Manager()->Manager();
|
||||
if (PBrowserParent* browser = LoneManagedOrNull(content->ManagedPBrowserParent())) {
|
||||
if (PBrowserParent* browser = SingleManagedOrNull(content->ManagedPBrowserParent())) {
|
||||
TabParent *tab = TabParent::GetFrom(browser);
|
||||
return tab->OwnAppId();
|
||||
} else {
|
||||
@@ -78,7 +78,7 @@ bool
|
||||
TCPServerSocketParent::GetInBrowser()
|
||||
{
|
||||
const PContentParent *content = Manager()->Manager();
|
||||
if (PBrowserParent* browser = LoneManagedOrNull(content->ManagedPBrowserParent())) {
|
||||
if (PBrowserParent* browser = SingleManagedOrNull(content->ManagedPBrowserParent())) {
|
||||
TabParent *tab = TabParent::GetFrom(browser);
|
||||
return tab->IsBrowserElement();
|
||||
} else {
|
||||
|
||||
@@ -68,7 +68,7 @@ uint32_t
|
||||
TCPSocketParent::GetAppId()
|
||||
{
|
||||
const PContentParent *content = Manager()->Manager();
|
||||
if (PBrowserParent* browser = LoneManagedOrNull(content->ManagedPBrowserParent())) {
|
||||
if (PBrowserParent* browser = SingleManagedOrNull(content->ManagedPBrowserParent())) {
|
||||
TabParent *tab = TabParent::GetFrom(browser);
|
||||
return tab->OwnAppId();
|
||||
} else {
|
||||
@@ -80,7 +80,7 @@ bool
|
||||
TCPSocketParent::GetInBrowser()
|
||||
{
|
||||
const PContentParent *content = Manager()->Manager();
|
||||
if (PBrowserParent* browser = LoneManagedOrNull(content->ManagedPBrowserParent())) {
|
||||
if (PBrowserParent* browser = SingleManagedOrNull(content->ManagedPBrowserParent())) {
|
||||
TabParent *tab = TabParent::GetFrom(browser);
|
||||
return tab->IsBrowserElement();
|
||||
} else {
|
||||
@@ -223,7 +223,9 @@ TCPSocketParent::RecvOpenBind(const nsCString& aRemoteHost,
|
||||
uint32_t appId = nsIScriptSecurityManager::NO_APP_ID;
|
||||
bool inBrowser = false;
|
||||
const PContentParent *content = Manager()->Manager();
|
||||
if (PBrowserParent* browser = LoneManagedOrNull(content->ManagedPBrowserParent())) {
|
||||
if (PBrowserParent* browser = SingleManagedOrNull(content->ManagedPBrowserParent())) {
|
||||
// appId's are for B2G only currently, where managees.Count() == 1
|
||||
// This is not guaranteed currently in Desktop, so skip this there.
|
||||
TabParent *tab = TabParent::GetFrom(browser);
|
||||
appId = tab->OwnAppId();
|
||||
inBrowser = tab->IsBrowserElement();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "mozilla/dom/DesktopNotificationBinding.h"
|
||||
#include "mozilla/dom/AppNotificationServiceOptionsBinding.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsContentPermissionHelper.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "mozilla/dom/PBrowserChild.h"
|
||||
@@ -114,16 +115,20 @@ DesktopNotification::PostDesktopNotification()
|
||||
nsIPrincipal* principal = doc->NodePrincipal();
|
||||
nsCOMPtr<nsILoadContext> loadContext = doc->GetLoadContext();
|
||||
bool inPrivateBrowsing = loadContext && loadContext->UsePrivateBrowsing();
|
||||
return alerts->ShowAlertNotification(mIconURL, mTitle, mDescription,
|
||||
true,
|
||||
uniqueName,
|
||||
mObserver,
|
||||
uniqueName,
|
||||
NS_LITERAL_STRING("auto"),
|
||||
EmptyString(),
|
||||
EmptyString(),
|
||||
principal,
|
||||
inPrivateBrowsing);
|
||||
nsCOMPtr<nsIAlertNotification> alert =
|
||||
do_CreateInstance(ALERT_NOTIFICATION_CONTRACTID);
|
||||
NS_ENSURE_TRUE(alert, NS_ERROR_FAILURE);
|
||||
nsresult rv = alert->Init(uniqueName, mIconURL, mTitle,
|
||||
mDescription,
|
||||
true,
|
||||
uniqueName,
|
||||
NS_LITERAL_STRING("auto"),
|
||||
EmptyString(),
|
||||
EmptyString(),
|
||||
principal,
|
||||
inPrivateBrowsing);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return alerts->ShowAlert(alert, mObserver);
|
||||
}
|
||||
|
||||
DesktopNotification::DesktopNotification(const nsAString & title,
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "mozilla/OwningNonNull.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
#include "mozilla/dom/AppNotificationServiceOptionsBinding.h"
|
||||
@@ -21,8 +22,11 @@
|
||||
#include "mozilla/dom/PromiseWorkerProxy.h"
|
||||
#include "mozilla/dom/ServiceWorkerGlobalScopeBinding.h"
|
||||
|
||||
#include "nsAlertsUtils.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsContentPermissionHelper.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCRTGlue.h"
|
||||
#include "nsDOMJSUtils.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsIAlertsService.h"
|
||||
@@ -32,8 +36,10 @@
|
||||
#include "nsILoadContext.h"
|
||||
#include "nsINotificationStorage.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsIPermission.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIServiceWorkerManager.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsIUUIDGenerator.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsNetUtil.h"
|
||||
@@ -659,6 +665,195 @@ NotificationPermissionRequest::GetTypes(nsIArray** aTypes)
|
||||
aTypes);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(NotificationTelemetryService, nsIObserver)
|
||||
|
||||
NotificationTelemetryService::NotificationTelemetryService()
|
||||
: mDNDRecorded(false)
|
||||
{}
|
||||
|
||||
NotificationTelemetryService::~NotificationTelemetryService()
|
||||
{
|
||||
Unused << NS_WARN_IF(NS_FAILED(RemovePermissionChangeObserver()));
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<NotificationTelemetryService>
|
||||
NotificationTelemetryService::GetInstance()
|
||||
{
|
||||
nsCOMPtr<nsISupports> telemetrySupports =
|
||||
do_GetService(NOTIFICATIONTELEMETRYSERVICE_CONTRACTID);
|
||||
if (!telemetrySupports) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<NotificationTelemetryService> telemetry =
|
||||
static_cast<NotificationTelemetryService*>(telemetrySupports.get());
|
||||
return telemetry.forget();
|
||||
}
|
||||
|
||||
nsresult
|
||||
NotificationTelemetryService::Init()
|
||||
{
|
||||
nsresult rv = AddPermissionChangeObserver();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
RecordPermissions();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NotificationTelemetryService::RemovePermissionChangeObserver()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (!obs) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return obs->RemoveObserver(this, "perm-changed");
|
||||
}
|
||||
|
||||
nsresult
|
||||
NotificationTelemetryService::AddPermissionChangeObserver()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (!obs) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return obs->AddObserver(this, "perm-changed", false);
|
||||
}
|
||||
|
||||
void
|
||||
NotificationTelemetryService::RecordPermissions()
|
||||
{
|
||||
if (!Telemetry::CanRecordBase() || !Telemetry::CanRecordExtended()) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPermissionManager> permissionManager =
|
||||
services::GetPermissionManager();
|
||||
if (!permissionManager) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
nsresult rv = permissionManager->GetEnumerator(getter_AddRefs(enumerator));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
bool hasMoreElements;
|
||||
nsresult rv = enumerator->HasMoreElements(&hasMoreElements);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
if (!hasMoreElements) {
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsISupports> supportsPermission;
|
||||
rv = enumerator->GetNext(getter_AddRefs(supportsPermission));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
uint32_t capability;
|
||||
if (!GetNotificationPermission(supportsPermission, &capability)) {
|
||||
continue;
|
||||
}
|
||||
if (capability == nsIPermissionManager::DENY_ACTION) {
|
||||
Telemetry::Accumulate(Telemetry::WEB_NOTIFICATION_PERMISSIONS, 0);
|
||||
} else if (capability == nsIPermissionManager::ALLOW_ACTION) {
|
||||
Telemetry::Accumulate(Telemetry::WEB_NOTIFICATION_PERMISSIONS, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
NotificationTelemetryService::GetNotificationPermission(nsISupports* aSupports,
|
||||
uint32_t* aCapability)
|
||||
{
|
||||
nsCOMPtr<nsIPermission> permission = do_QueryInterface(aSupports);
|
||||
if (!permission) {
|
||||
return false;
|
||||
}
|
||||
nsAutoCString type;
|
||||
permission->GetType(type);
|
||||
if (!type.Equals("desktop-notification")) {
|
||||
return false;
|
||||
}
|
||||
permission->GetCapability(aCapability);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
NotificationTelemetryService::RecordDNDSupported()
|
||||
{
|
||||
if (mDNDRecorded) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAlertsService> alertService =
|
||||
do_GetService(NS_ALERTSERVICE_CONTRACTID);
|
||||
if (!alertService) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAlertsDoNotDisturb> alertServiceDND =
|
||||
do_QueryInterface(alertService);
|
||||
if (!alertServiceDND) {
|
||||
return;
|
||||
}
|
||||
|
||||
mDNDRecorded = true;
|
||||
bool isEnabled;
|
||||
nsresult rv = alertServiceDND->GetManualDoNotDisturb(&isEnabled);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Telemetry::Accumulate(
|
||||
Telemetry::ALERTS_SERVICE_DND_SUPPORTED_FLAG, true);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NotificationTelemetryService::RecordSender(nsIPrincipal* aPrincipal)
|
||||
{
|
||||
if (!Telemetry::CanRecordBase() || !Telemetry::CanRecordExtended() ||
|
||||
!nsAlertsUtils::IsActionablePrincipal(aPrincipal)) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsAutoString origin;
|
||||
nsresult rv = Notification::GetOrigin(aPrincipal, origin);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
if (!mOrigins.Contains(origin)) {
|
||||
mOrigins.PutEntry(origin);
|
||||
Telemetry::Accumulate(Telemetry::WEB_NOTIFICATION_SENDERS, 1);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NotificationTelemetryService::Observe(nsISupports* aSubject,
|
||||
const char* aTopic,
|
||||
const char16_t* aData)
|
||||
{
|
||||
uint32_t capability;
|
||||
if (strcmp("perm-changed", aTopic) ||
|
||||
!NS_strcmp(MOZ_UTF16("cleared"), aData) ||
|
||||
!GetNotificationPermission(aSubject, &capability)) {
|
||||
return NS_OK;
|
||||
}
|
||||
if (!NS_strcmp(MOZ_UTF16("deleted"), aData)) {
|
||||
if (capability == nsIPermissionManager::DENY_ACTION) {
|
||||
Telemetry::Accumulate(
|
||||
Telemetry::WEB_NOTIFICATION_PERMISSION_REMOVED, 0);
|
||||
} else if (capability == nsIPermissionManager::ALLOW_ACTION) {
|
||||
Telemetry::Accumulate(
|
||||
Telemetry::WEB_NOTIFICATION_PERMISSION_REMOVED, 1);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Observer that the alert service calls to do common tasks and/or dispatch to the
|
||||
// specific observer for the context e.g. main thread, worker, or service worker.
|
||||
class NotificationObserver final : public nsIObserver
|
||||
@@ -666,11 +861,14 @@ class NotificationObserver final : public nsIObserver
|
||||
public:
|
||||
nsCOMPtr<nsIObserver> mObserver;
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
bool mInPrivateBrowsing;
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
NotificationObserver(nsIObserver* aObserver, nsIPrincipal* aPrincipal)
|
||||
: mObserver(aObserver), mPrincipal(aPrincipal)
|
||||
NotificationObserver(nsIObserver* aObserver, nsIPrincipal* aPrincipal,
|
||||
bool aInPrivateBrowsing)
|
||||
: mObserver(aObserver), mPrincipal(aPrincipal),
|
||||
mInPrivateBrowsing(aInPrivateBrowsing)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(mObserver);
|
||||
@@ -783,6 +981,23 @@ Notification::Notification(nsIGlobalObject* aGlobal, const nsAString& aID,
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
Notification::Init()
|
||||
{
|
||||
if (!mWorkerPrivate) {
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
NS_ENSURE_TRUE(obs, NS_ERROR_FAILURE);
|
||||
|
||||
nsresult rv = obs->AddObserver(this, DOM_WINDOW_DESTROYED_TOPIC, true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = obs->AddObserver(this, DOM_WINDOW_FROZEN_TOPIC, true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
Notification::SetAlertName()
|
||||
{
|
||||
@@ -952,6 +1167,7 @@ Notification::CreateInternal(nsIGlobalObject* aGlobal,
|
||||
const nsAString& aTitle,
|
||||
const NotificationOptions& aOptions)
|
||||
{
|
||||
nsresult rv;
|
||||
nsString id;
|
||||
if (!aID.IsEmpty()) {
|
||||
id = aID;
|
||||
@@ -960,7 +1176,7 @@ Notification::CreateInternal(nsIGlobalObject* aGlobal,
|
||||
do_GetService("@mozilla.org/uuid-generator;1");
|
||||
NS_ENSURE_TRUE(uuidgen, nullptr);
|
||||
nsID uuid;
|
||||
nsresult rv = uuidgen->GenerateUUIDInPlace(&uuid);
|
||||
rv = uuidgen->GenerateUUIDInPlace(&uuid);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
char buffer[NSID_LENGTH];
|
||||
@@ -976,6 +1192,8 @@ Notification::CreateInternal(nsIGlobalObject* aGlobal,
|
||||
aOptions.mTag,
|
||||
aOptions.mIcon,
|
||||
aOptions.mMozbehavior);
|
||||
rv = notification->Init();
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
return notification.forget();
|
||||
}
|
||||
|
||||
@@ -1004,6 +1222,8 @@ NS_IMPL_ADDREF_INHERITED(Notification, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(Notification, DOMEventTargetHelper)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(Notification)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
nsIPrincipal*
|
||||
@@ -1161,6 +1381,7 @@ NotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
AssertIsOnMainThread();
|
||||
|
||||
if (!strcmp("alertdisablecallback", aTopic)) {
|
||||
Telemetry::Accumulate(Telemetry::WEB_NOTIFICATION_MENU, 1);
|
||||
if (XRE_IsParentProcess()) {
|
||||
return Notification::RemovePermission(mPrincipal);
|
||||
}
|
||||
@@ -1170,7 +1391,10 @@ NotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
ContentChild::GetSingleton()->SendDisableNotifications(
|
||||
IPC::Principal(mPrincipal));
|
||||
return NS_OK;
|
||||
} else if (!strcmp("alertclickcallback", aTopic)) {
|
||||
Telemetry::Accumulate(Telemetry::WEB_NOTIFICATION_CLICKED, 1);
|
||||
} else if (!strcmp("alertsettingscallback", aTopic)) {
|
||||
Telemetry::Accumulate(Telemetry::WEB_NOTIFICATION_MENU, 2);
|
||||
if (XRE_IsParentProcess()) {
|
||||
return Notification::OpenSettings(mPrincipal);
|
||||
}
|
||||
@@ -1181,7 +1405,23 @@ NotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
return NS_OK;
|
||||
} else if (!strcmp("alertshow", aTopic) ||
|
||||
!strcmp("alertfinished", aTopic)) {
|
||||
RefPtr<NotificationTelemetryService> telemetry =
|
||||
NotificationTelemetryService::GetInstance();
|
||||
if (telemetry) {
|
||||
// Record whether "do not disturb" is supported after the first
|
||||
// notification, to account for falling back to XUL alerts.
|
||||
telemetry->RecordDNDSupported();
|
||||
if (!mInPrivateBrowsing) {
|
||||
// Ignore senders in private windows.
|
||||
Unused << NS_WARN_IF(NS_FAILED(telemetry->RecordSender(mPrincipal)));
|
||||
}
|
||||
}
|
||||
Unused << NS_WARN_IF(NS_FAILED(AdjustPushQuota(aTopic)));
|
||||
|
||||
if (!strcmp("alertshow", aTopic)) {
|
||||
// Record notifications actually shown (e.g. don't count if DND is on).
|
||||
Telemetry::Accumulate(Telemetry::WEB_NOTIFICATION_SHOWN, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return mObserver->Observe(aSubject, aTopic, aData);
|
||||
@@ -1416,6 +1656,30 @@ ServiceWorkerNotificationObserver::Observe(nsISupports* aSubject,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
Notification::IsInPrivateBrowsing()
|
||||
{
|
||||
nsIDocument* doc = mWorkerPrivate ? mWorkerPrivate->GetDocument()
|
||||
: GetOwner()->GetExtantDoc();
|
||||
if (doc) {
|
||||
nsCOMPtr<nsILoadContext> loadContext = doc->GetLoadContext();
|
||||
return loadContext && loadContext->UsePrivateBrowsing();
|
||||
}
|
||||
|
||||
if (mWorkerPrivate) {
|
||||
// Not all workers may have a document, but with Bug 1107516 fixed, they
|
||||
// should all have a loadcontext.
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = mWorkerPrivate->GetLoadGroup();
|
||||
nsCOMPtr<nsILoadContext> loadContext;
|
||||
NS_QueryNotificationCallbacks(nullptr, loadGroup, NS_GET_IID(nsILoadContext),
|
||||
getter_AddRefs(loadContext));
|
||||
return loadContext && loadContext->UsePrivateBrowsing();
|
||||
}
|
||||
|
||||
//XXXnsm Should this default to true?
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
Notification::ShowInternal()
|
||||
{
|
||||
@@ -1446,6 +1710,9 @@ Notification::ShowInternal()
|
||||
} else {
|
||||
permission = GetPermissionInternal(GetOwner(), result);
|
||||
}
|
||||
// We rely on GetPermissionInternal returning Denied on all failure codepaths.
|
||||
MOZ_ASSERT_IF(result.Failed(), permission == NotificationPermission::Denied);
|
||||
result.SuppressException();
|
||||
if (permission != NotificationPermission::Granted || !alertService) {
|
||||
if (mWorkerPrivate) {
|
||||
RefPtr<NotificationEventWorkerRunnable> r =
|
||||
@@ -1487,7 +1754,8 @@ Notification::ShowInternal()
|
||||
}
|
||||
MOZ_ASSERT(observer);
|
||||
nsCOMPtr<nsIObserver> alertObserver = new NotificationObserver(observer,
|
||||
GetPrincipal());
|
||||
GetPrincipal(),
|
||||
IsInPrivateBrowsing());
|
||||
|
||||
|
||||
#ifdef MOZ_B2G
|
||||
@@ -1538,30 +1806,23 @@ Notification::ShowInternal()
|
||||
// nsIObserver. Thus the cookie must be unique to differentiate observers.
|
||||
nsString uniqueCookie = NS_LITERAL_STRING("notification:");
|
||||
uniqueCookie.AppendInt(sCount++);
|
||||
//XXXnsm Should this default to true?
|
||||
bool inPrivateBrowsing = false;
|
||||
nsIDocument* doc = mWorkerPrivate ? mWorkerPrivate->GetDocument()
|
||||
: GetOwner()->GetExtantDoc();
|
||||
if (doc) {
|
||||
nsCOMPtr<nsILoadContext> loadContext = doc->GetLoadContext();
|
||||
inPrivateBrowsing = loadContext && loadContext->UsePrivateBrowsing();
|
||||
} else if (mWorkerPrivate) {
|
||||
// Not all workers may have a document, but with Bug 1107516 fixed, they
|
||||
// should all have a loadcontext.
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = mWorkerPrivate->GetLoadGroup();
|
||||
nsCOMPtr<nsILoadContext> loadContext;
|
||||
NS_QueryNotificationCallbacks(nullptr, loadGroup, NS_GET_IID(nsILoadContext),
|
||||
getter_AddRefs(loadContext));
|
||||
inPrivateBrowsing = loadContext && loadContext->UsePrivateBrowsing();
|
||||
}
|
||||
bool inPrivateBrowsing = IsInPrivateBrowsing();
|
||||
|
||||
nsAutoString alertName;
|
||||
GetAlertName(alertName);
|
||||
alertService->ShowAlertNotification(iconUrl, mTitle, mBody, true,
|
||||
uniqueCookie, alertObserver, alertName,
|
||||
DirectionToString(mDir), mLang,
|
||||
mDataAsBase64, GetPrincipal(),
|
||||
inPrivateBrowsing);
|
||||
nsCOMPtr<nsIAlertNotification> alert =
|
||||
do_CreateInstance(ALERT_NOTIFICATION_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(alert);
|
||||
rv = alert->Init(alertName, iconUrl, mTitle, mBody,
|
||||
true,
|
||||
uniqueCookie,
|
||||
DirectionToString(mDir),
|
||||
mLang,
|
||||
mDataAsBase64,
|
||||
GetPrincipal(),
|
||||
inPrivateBrowsing);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
alertService->ShowAlert(alert, alertObserver);
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
@@ -2478,6 +2739,46 @@ Notification::OpenSettings(nsIPrincipal* aPrincipal)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Notification::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const char16_t* aData)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
if (!strcmp(aTopic, DOM_WINDOW_DESTROYED_TOPIC) ||
|
||||
!strcmp(aTopic, DOM_WINDOW_FROZEN_TOPIC)) {
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> window = GetOwner();
|
||||
if (SameCOMIdentity(aSubject, window)) {
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
mozilla::services::GetObserverService();
|
||||
if (obs) {
|
||||
obs->RemoveObserver(this, DOM_WINDOW_DESTROYED_TOPIC);
|
||||
obs->RemoveObserver(this, DOM_WINDOW_FROZEN_TOPIC);
|
||||
}
|
||||
|
||||
uint16_t appStatus = nsIPrincipal::APP_STATUS_NOT_INSTALLED;
|
||||
uint32_t appId = nsIScriptSecurityManager::UNKNOWN_APP_ID;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
|
||||
nsCOMPtr<nsIPrincipal> nodePrincipal = doc ? doc->NodePrincipal() :
|
||||
nullptr;
|
||||
if (nodePrincipal) {
|
||||
appStatus = nodePrincipal->GetAppStatus();
|
||||
appId = nodePrincipal->GetAppId();
|
||||
}
|
||||
|
||||
if (appStatus == nsIPrincipal::APP_STATUS_NOT_INSTALLED ||
|
||||
appId == nsIScriptSecurityManager::NO_APP_ID ||
|
||||
appId == nsIScriptSecurityManager::UNKNOWN_APP_ID) {
|
||||
CloseInternal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
||||
@@ -15,6 +15,12 @@
|
||||
#include "nsIObserver.h"
|
||||
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
#define NOTIFICATIONTELEMETRYSERVICE_CONTRACTID \
|
||||
"@mozilla.org/notificationTelemetryService;1"
|
||||
|
||||
class nsIPrincipal;
|
||||
class nsIVariant;
|
||||
@@ -44,6 +50,35 @@ public:
|
||||
Notify(JSContext* aCx, workers::Status aStatus) override;
|
||||
};
|
||||
|
||||
// Records telemetry probes at application startup, when a notification is
|
||||
// shown, and when the notification permission is revoked for a site.
|
||||
class NotificationTelemetryService final : public nsIObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
NotificationTelemetryService();
|
||||
|
||||
static already_AddRefed<NotificationTelemetryService> GetInstance();
|
||||
|
||||
nsresult Init();
|
||||
void RecordDNDSupported();
|
||||
void RecordPermissions();
|
||||
nsresult RecordSender(nsIPrincipal* aPrincipal);
|
||||
|
||||
private:
|
||||
virtual ~NotificationTelemetryService();
|
||||
|
||||
nsresult AddPermissionChangeObserver();
|
||||
nsresult RemovePermissionChangeObserver();
|
||||
|
||||
bool GetNotificationPermission(nsISupports* aSupports,
|
||||
uint32_t* aCapability);
|
||||
|
||||
bool mDNDRecorded;
|
||||
nsTHashtable<nsStringHashKey> mOrigins;
|
||||
};
|
||||
|
||||
/*
|
||||
* Notifications on workers introduce some lifetime issues. The property we
|
||||
@@ -98,6 +133,8 @@ public:
|
||||
*
|
||||
*/
|
||||
class Notification : public DOMEventTargetHelper
|
||||
, public nsIObserver
|
||||
, public nsSupportsWeakReference
|
||||
{
|
||||
friend class CloseNotificationRunnable;
|
||||
friend class NotificationTask;
|
||||
@@ -107,6 +144,7 @@ class Notification : public DOMEventTargetHelper
|
||||
friend class ServiceWorkerNotificationObserver;
|
||||
friend class WorkerGetRunnable;
|
||||
friend class WorkerNotificationObserver;
|
||||
friend class NotificationTelemetryService;
|
||||
|
||||
public:
|
||||
IMPL_EVENT_HANDLER(click)
|
||||
@@ -116,6 +154,7 @@ public:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(Notification, DOMEventTargetHelper)
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
static bool PrefEnabled(JSContext* aCx, JSObject* aObj);
|
||||
// Returns if Notification.get() is allowed for the current global.
|
||||
@@ -290,6 +329,8 @@ protected:
|
||||
const nsAString& aTitle,
|
||||
const NotificationOptions& aOptions);
|
||||
|
||||
nsresult Init();
|
||||
bool IsInPrivateBrowsing();
|
||||
void ShowInternal();
|
||||
void CloseInternal();
|
||||
|
||||
@@ -308,7 +349,7 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
static const NotificationDirection StringToDirection(const nsAString& aDirection)
|
||||
static NotificationDirection StringToDirection(const nsAString& aDirection)
|
||||
{
|
||||
if (aDirection.EqualsLiteral("ltr")) {
|
||||
return NotificationDirection::Ltr;
|
||||
|
||||
@@ -117,7 +117,7 @@ typedef mozilla::null_t DXGISharedSurfaceHandle;
|
||||
// XXX maybe not the best place for these. better one?
|
||||
|
||||
#define VARSTR(v_) case v_: return #v_
|
||||
inline const char* const
|
||||
inline const char*
|
||||
NPPVariableToString(NPPVariable aVar)
|
||||
{
|
||||
switch (aVar) {
|
||||
|
||||
@@ -1514,7 +1514,7 @@ PluginModuleChromeParent::OnHangUIContinue()
|
||||
CrashReporterParent*
|
||||
PluginModuleChromeParent::CrashReporter()
|
||||
{
|
||||
return static_cast<CrashReporterParent*>(LoneManagedOrNull(ManagedPCrashReporterParent()));
|
||||
return static_cast<CrashReporterParent*>(LoneManagedOrNullAsserts(ManagedPCrashReporterParent()));
|
||||
}
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER_INJECTOR
|
||||
|
||||
@@ -86,12 +86,12 @@ private:
|
||||
return mAddress;
|
||||
}
|
||||
|
||||
const uint16_t Port() const
|
||||
uint16_t Port() const
|
||||
{
|
||||
return mPort;
|
||||
}
|
||||
|
||||
const DeviceState State() const
|
||||
DeviceState State() const
|
||||
{
|
||||
return mState;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ GetZeroValueForUnit(StyleAnimationValue::Unit aUnit)
|
||||
// with a eUnit_Float value. (See comment below.)
|
||||
//
|
||||
// Returns true on success, or false.
|
||||
static const bool
|
||||
static bool
|
||||
FinalizeStyleAnimationValues(const StyleAnimationValue*& aValue1,
|
||||
const StyleAnimationValue*& aValue2)
|
||||
{
|
||||
|
||||
@@ -134,7 +134,7 @@ protected:
|
||||
|
||||
// Interface for SVGMatrix's use
|
||||
friend class dom::SVGMatrix;
|
||||
const bool IsAnimVal() const {
|
||||
bool IsAnimVal() const {
|
||||
return mIsAnimValItem;
|
||||
}
|
||||
const gfxMatrix& Matrixgfx() const {
|
||||
|
||||
@@ -5,13 +5,18 @@ onfetch = function(e) {
|
||||
var url = e.request.url.substring(0, e.request.url.indexOf('?'));
|
||||
url += '?headers=' + ({ 'Referer': self.location.href }).toSource();
|
||||
|
||||
e.respondWith(fetch(url, {
|
||||
method: e.request.method,
|
||||
headers: e.request.headers,
|
||||
body: e.request.body,
|
||||
mode: e.request.mode,
|
||||
credentials: e.request.credentials,
|
||||
cache: e.request.cache,
|
||||
e.respondWith(e.request.text().then(function(text) {
|
||||
var body = text === '' ? undefined : text;
|
||||
var mode = e.request.mode == 'navigate' ? 'same-origin' : e.request.mode;
|
||||
return fetch(url, {
|
||||
method: e.request.method,
|
||||
headers: e.request.headers,
|
||||
body: body,
|
||||
mode: mode,
|
||||
credentials: e.request.credentials,
|
||||
redirect: e.request.redirect,
|
||||
cache: e.request.cache,
|
||||
});
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -124,6 +124,19 @@ function testBug1109574() {
|
||||
var r3 = new Request(r1);
|
||||
}
|
||||
|
||||
// Bug 1184550 - Request constructor should always throw if used flag is set,
|
||||
// even if body is null
|
||||
function testBug1184550() {
|
||||
var req = new Request("", { method: 'post', body: "Test" });
|
||||
fetch(req);
|
||||
ok(req.bodyUsed, "Request body should be used immediately after fetch()");
|
||||
return fetch(req).then(function(resp) {
|
||||
ok(false, "Second fetch with same request should fail.");
|
||||
}).catch(function(err) {
|
||||
is(err.name, 'TypeError', "Second fetch with same request should fail.");
|
||||
});
|
||||
}
|
||||
|
||||
function testHeaderGuard() {
|
||||
var headers = {
|
||||
"Cookie": "Custom cookie",
|
||||
@@ -138,6 +151,15 @@ function testHeaderGuard() {
|
||||
ok(!r2.headers.has("Non-Simple-Header"), "no-cors Request header should have guard request-no-cors and prevent setting non-simple header.");
|
||||
}
|
||||
|
||||
function testMode() {
|
||||
try {
|
||||
var req = new Request("http://example.com", {mode: "navigate"});
|
||||
ok(false, "Creating a Request with navigate RequestMode should throw a TypeError");
|
||||
} catch(e) {
|
||||
is(e.name, "TypeError", "Creating a Request with navigate RequestMode should throw a TypeError");
|
||||
}
|
||||
}
|
||||
|
||||
function testMethod() {
|
||||
// These get normalized.
|
||||
var allowed = ["delete", "get", "head", "options", "post", "put" ];
|
||||
@@ -498,8 +520,10 @@ function runTest() {
|
||||
testUrlFragment();
|
||||
testUrlCredentials();
|
||||
testUrlMalformed();
|
||||
testMode();
|
||||
testMethod();
|
||||
testBug1109574();
|
||||
testBug1184550();
|
||||
testHeaderGuard();
|
||||
testModeCorsPreflightEnumValue();
|
||||
testBug1154268();
|
||||
|
||||
@@ -29,26 +29,34 @@ var MockServices = (function () {
|
||||
});
|
||||
|
||||
var mockAlertsService = {
|
||||
showAlertNotification: function(imageUrl, title, text, textClickable,
|
||||
cookie, alertListener, name) {
|
||||
showAlert: function(alert, alertListener) {
|
||||
var listener = SpecialPowers.wrap(alertListener);
|
||||
activeAlertNotifications[name] = {
|
||||
activeAlertNotifications[alert.name] = {
|
||||
listener: listener,
|
||||
cookie: cookie,
|
||||
title: title
|
||||
cookie: alert.cookie,
|
||||
title: alert.title
|
||||
};
|
||||
|
||||
// fake async alert show event
|
||||
if (listener) {
|
||||
setTimeout(function () {
|
||||
listener.observe(null, "alertshow", cookie);
|
||||
listener.observe(null, "alertshow", alert.cookie);
|
||||
}, 100);
|
||||
setTimeout(function () {
|
||||
listener.observe(null, "alertclickcallback", cookie);
|
||||
listener.observe(null, "alertclickcallback", alert.cookie);
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
|
||||
showAlertNotification: function(imageUrl, title, text, textClickable,
|
||||
cookie, alertListener, name) {
|
||||
this.showAlert({
|
||||
name: name,
|
||||
cookie: cookie,
|
||||
title: title
|
||||
}, alertListener);
|
||||
},
|
||||
|
||||
showAppNotification: function(aImageUrl, aTitle, aText, aAlertListener, aDetails) {
|
||||
var listener = aAlertListener || (activeAlertNotifications[aDetails.id] ? activeAlertNotifications[aDetails.id].listener : undefined);
|
||||
activeAppNotifications[aDetails.id] = {
|
||||
|
||||
@@ -8,17 +8,23 @@ var registrar = SpecialPowers.wrap(SpecialPowers.Components).manager.
|
||||
QueryInterface(SpecialPowers.Ci.nsIComponentRegistrar);
|
||||
|
||||
var mockAlertsService = {
|
||||
showAlert: function(alert, alertListener) {
|
||||
// probably should do this async....
|
||||
SpecialPowers.wrap(alertListener).observe(null, "alertshow", alert.cookie);
|
||||
|
||||
if (SpecialPowers.getBoolPref("notification.prompt.testing.click_on_notification") == true) {
|
||||
SpecialPowers.wrap(alertListener).observe(null, "alertclickcallback", alert.cookie);
|
||||
}
|
||||
|
||||
SpecialPowers.wrap(alertListener).observe(null, "alertfinished", alert.cookie);
|
||||
},
|
||||
|
||||
showAlertNotification: function(imageUrl, title, text, textClickable,
|
||||
cookie, alertListener, name, bidi,
|
||||
lang, data) {
|
||||
// probably should do this async....
|
||||
SpecialPowers.wrap(alertListener).observe(null, "alertshow", cookie);
|
||||
|
||||
if (SpecialPowers.getBoolPref("notification.prompt.testing.click_on_notification") == true) {
|
||||
SpecialPowers.wrap(alertListener).observe(null, "alertclickcallback", cookie);
|
||||
}
|
||||
|
||||
SpecialPowers.wrap(alertListener).observe(null, "alertfinished", cookie);
|
||||
return this.showAlert({
|
||||
cookie: cookie
|
||||
}, alertListener);
|
||||
},
|
||||
|
||||
showAppNotification: function(imageUrl, title, text, alertListener, details) {
|
||||
|
||||
@@ -23,15 +23,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=782211
|
||||
const ALERTS_SERVICE_CONTRACT_ID = "@mozilla.org/alerts-service;1";
|
||||
|
||||
var mockAlertsService = {
|
||||
showAlertNotification: function(imageUrl, title, text, textClickable,
|
||||
cookie, alertListener, name, dir,
|
||||
lang, data) {
|
||||
notificationsCreated.push(name);
|
||||
showAlert: function(alert, alertListener) {
|
||||
notificationsCreated.push(alert.name);
|
||||
if (notificationsCreated.length == 3) {
|
||||
checkNotifications();
|
||||
}
|
||||
},
|
||||
|
||||
showAlertNotification: function(imageUrl, title, text, textClickable,
|
||||
cookie, alertListener, name, dir,
|
||||
lang, data) {
|
||||
this.showAlert({ name: name });
|
||||
},
|
||||
|
||||
QueryInterface: function(aIID) {
|
||||
if (SpecialPowers.wrap(aIID).equals(SpecialPowers.Ci.nsISupports) ||
|
||||
SpecialPowers.wrap(aIID).equals(SpecialPowers.Ci.nsIAlertsService)) {
|
||||
|
||||
@@ -23,13 +23,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=874090
|
||||
const ALERTS_SERVICE_CONTRACT_ID = "@mozilla.org/alerts-service;1";
|
||||
|
||||
var mockAlertsService = {
|
||||
showAlertNotification: function(imageUrl, title, text, textClickable,
|
||||
cookie, alertListener, name, dir, lang, data) {
|
||||
ok(true, "System principal was granted permission and is able to call showAlertNotification.");
|
||||
showAlert: function(alert, alertListener) {
|
||||
ok(true, "System principal was granted permission and is able to call showAlert.");
|
||||
unregisterMock();
|
||||
SimpleTest.finish();
|
||||
},
|
||||
|
||||
showAlertNotification: function(imageUrl, title, text, textClickable,
|
||||
cookie, alertListener, name, dir, lang, data) {
|
||||
this.showAlert();
|
||||
},
|
||||
|
||||
QueryInterface: function(aIID) {
|
||||
if (aIID.equals(Components.interfaces.nsISupports) ||
|
||||
aIID.equals(Components.interfaces.nsIAlertsService)) {
|
||||
|
||||
@@ -117,6 +117,9 @@ var AlertsService = {
|
||||
"", ALERTS_SERVICE_CONTRACT_ID, null);
|
||||
},
|
||||
|
||||
showAlert: function() {
|
||||
},
|
||||
|
||||
showAlertNotification: function() {
|
||||
},
|
||||
};
|
||||
|
||||
@@ -41,7 +41,7 @@ interface NavigatorID {
|
||||
readonly attribute DOMString appVersion;
|
||||
[Constant, Cached]
|
||||
readonly attribute DOMString platform;
|
||||
[Constant, Cached, Throws=Workers]
|
||||
[Pure, Cached, Throws=Workers]
|
||||
readonly attribute DOMString userAgent;
|
||||
[Constant, Cached]
|
||||
readonly attribute DOMString product; // constant "Gecko"
|
||||
|
||||
@@ -55,7 +55,7 @@ enum RequestContext {
|
||||
"xslt"
|
||||
};
|
||||
|
||||
enum RequestMode { "same-origin", "no-cors", "cors" };
|
||||
enum RequestMode { "same-origin", "no-cors", "cors", "navigate" };
|
||||
enum RequestCredentials { "omit", "same-origin", "include" };
|
||||
enum RequestCache { "default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached" };
|
||||
enum RequestCache { "default", "no-store", "reload", "no-cache", "force-cache" };
|
||||
enum RequestRedirect { "follow", "error", "manual" };
|
||||
|
||||
@@ -563,7 +563,8 @@ RespondWithHandler::ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValu
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT_IF(mIsClientRequest, mRequestMode == RequestMode::Same_origin);
|
||||
MOZ_ASSERT_IF(mIsClientRequest, mRequestMode == RequestMode::Same_origin ||
|
||||
mRequestMode == RequestMode::Navigate);
|
||||
|
||||
if (response->Type() == ResponseType::Opaque && mRequestMode != RequestMode::No_cors) {
|
||||
uint32_t mode = static_cast<uint32_t>(mRequestMode);
|
||||
|
||||
@@ -105,6 +105,8 @@ static_assert(nsIHttpChannelInternal::CORS_MODE_NO_CORS == static_cast<uint32_t>
|
||||
"RequestMode enumeration value should match Necko CORS mode value.");
|
||||
static_assert(nsIHttpChannelInternal::CORS_MODE_CORS == static_cast<uint32_t>(RequestMode::Cors),
|
||||
"RequestMode enumeration value should match Necko CORS mode value.");
|
||||
static_assert(nsIHttpChannelInternal::CORS_MODE_NAVIGATE == static_cast<uint32_t>(RequestMode::Navigate),
|
||||
"RequestMode enumeration value should match Necko CORS mode value.");
|
||||
|
||||
static_assert(nsIHttpChannelInternal::REDIRECT_MODE_FOLLOW == static_cast<uint32_t>(RequestRedirect::Follow),
|
||||
"RequestRedirect enumeration value should make Necko Redirect mode value.");
|
||||
@@ -3466,7 +3468,7 @@ ServiceWorkerManager::PrepareFetchEvent(const OriginAttributes& aOriginAttribute
|
||||
documentId = aDocumentIdForTopLevelNavigation;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
aRv = internalChannel->GetURI(getter_AddRefs(uri));
|
||||
aRv = aChannel->GetSecureUpgradedChannelURI(getter_AddRefs(uri));
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1052,7 +1052,7 @@ public:
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = channel->GetURI(getter_AddRefs(uri));
|
||||
rv = mInterceptedChannel->GetSecureUpgradedChannelURI(getter_AddRefs(uri));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = uri->GetSpec(mSpec);
|
||||
|
||||
@@ -121,6 +121,10 @@ MOCHITEST_CHROME_MANIFESTS += [
|
||||
'test/serviceworkers/chrome.ini'
|
||||
]
|
||||
|
||||
BROWSER_CHROME_MANIFESTS += [
|
||||
'test/serviceworkers/browser.ini',
|
||||
]
|
||||
|
||||
XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell/xpcshell.ini']
|
||||
|
||||
TEST_DIRS += ['test/gtest']
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
[DEFAULT]
|
||||
support-files =
|
||||
browser_base_force_refresh.html
|
||||
browser_cached_force_refresh.html
|
||||
download_window.html
|
||||
download_worker.js
|
||||
force_refresh_browser_worker.js
|
||||
|
||||
[browser_force_refresh.js]
|
||||
[browser_download.js]
|
||||
@@ -0,0 +1,30 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
addEventListener('load', function(event) {
|
||||
navigator.serviceWorker.register('force_refresh_browser_worker.js').then(function(swr) {
|
||||
if (!swr) {
|
||||
return;
|
||||
}
|
||||
var custom = new Event('base-register', { bubbles: true });
|
||||
document.dispatchEvent(custom);
|
||||
});
|
||||
|
||||
navigator.serviceWorker.ready.then(function() {
|
||||
var custom = new Event('base-sw-ready', { bubbles: true });
|
||||
document.dispatchEvent(custom);
|
||||
});
|
||||
|
||||
var custom = new Event('base-load', { bubbles: true });
|
||||
document.dispatchEvent(custom);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,17 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
addEventListener('load', function(event) {
|
||||
var custom = new Event('cached-load', { bubbles: true });
|
||||
document.dispatchEvent(custom);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,82 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
Cu.import('resource://gre/modules/Services.jsm');
|
||||
var Downloads = Cu.import("resource://gre/modules/Downloads.jsm", {}).Downloads;
|
||||
Cu.import('resource://gre/modules/NetUtil.jsm');
|
||||
|
||||
var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/",
|
||||
"http://mochi.test:8888/")
|
||||
|
||||
function getFile(aFilename) {
|
||||
if (aFilename.startsWith('file:')) {
|
||||
var url = NetUtil.newURI(aFilename).QueryInterface(Ci.nsIFileURL);
|
||||
return url.file.clone();
|
||||
}
|
||||
|
||||
var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);
|
||||
file.initWithPath(aFilename);
|
||||
return file;
|
||||
}
|
||||
|
||||
function windowObserver(win, topic) {
|
||||
if (topic !== 'domwindowopened') {
|
||||
return;
|
||||
}
|
||||
|
||||
win.addEventListener('load', function onLoadWindow() {
|
||||
win.removeEventListener('load', onLoadWindow, false);
|
||||
if (win.document.documentURI ===
|
||||
'chrome://mozapps/content/downloads/unknownContentType.xul') {
|
||||
executeSoon(function() {
|
||||
var button = win.document.documentElement.getButton('accept');
|
||||
button.disabled = false;
|
||||
win.document.documentElement.acceptDialog();
|
||||
});
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
Services.ww.registerNotification(windowObserver);
|
||||
|
||||
SpecialPowers.pushPrefEnv({'set': [['dom.serviceWorkers.enabled', true],
|
||||
['dom.serviceWorkers.exemptFromPerDomainMax', true],
|
||||
['dom.serviceWorkers.testing.enabled', true],
|
||||
['dom.serviceWorkers.interception.enabled', true]]},
|
||||
function() {
|
||||
var url = gTestRoot + 'download_window.html';
|
||||
var tab = gBrowser.addTab();
|
||||
gBrowser.selectedTab = tab;
|
||||
|
||||
Downloads.getList(Downloads.ALL).then(function(downloadList) {
|
||||
var downloadListener;
|
||||
|
||||
function downloadVerifier(aDownload) {
|
||||
if (aDownload.succeeded) {
|
||||
var file = getFile(aDownload.target.path);
|
||||
ok(file.exists(), 'download completed');
|
||||
is(file.fileSize, 33, 'downloaded file has correct size');
|
||||
file.remove(false);
|
||||
|
||||
downloadList.removeView(downloadListener);
|
||||
gBrowser.removeTab(tab);
|
||||
Services.ww.unregisterNotification(windowObserver);
|
||||
|
||||
executeSoon(finish);
|
||||
}
|
||||
}
|
||||
|
||||
downloadListener = {
|
||||
onDownloadAdded: downloadVerifier,
|
||||
onDownloadChanged: downloadVerifier
|
||||
};
|
||||
|
||||
return downloadList.addView(downloadListener);
|
||||
}).then(function() {
|
||||
gBrowser.loadURI(url);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/",
|
||||
"http://mochi.test:8888/")
|
||||
|
||||
function refresh() {
|
||||
EventUtils.synthesizeKey('R', { accelKey: true });
|
||||
}
|
||||
|
||||
function forceRefresh() {
|
||||
EventUtils.synthesizeKey('R', { accelKey: true, shiftKey: true });
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({'set': [['dom.serviceWorkers.enabled', true],
|
||||
['dom.serviceWorkers.exemptFromPerDomainMax', true],
|
||||
['dom.serviceWorkers.testing.enabled', true],
|
||||
['dom.caches.enabled', true]]},
|
||||
function() {
|
||||
var url = gTestRoot + 'browser_base_force_refresh.html';
|
||||
var tab = gBrowser.addTab(url);
|
||||
gBrowser.selectedTab = tab;
|
||||
|
||||
var cachedLoad = false;
|
||||
|
||||
function eventHandler(event) {
|
||||
if (event.type === 'base-load') {
|
||||
if (cachedLoad) {
|
||||
gBrowser.removeTab(tab);
|
||||
executeSoon(finish);
|
||||
}
|
||||
} else if (event.type === 'base-register') {
|
||||
ok(!cachedLoad, 'cached load should not occur before base register');
|
||||
refresh();
|
||||
} else if (event.type === 'base-sw-ready') {
|
||||
ok(!cachedLoad, 'cached load should not occur before base ready');
|
||||
refresh();
|
||||
} else if (event.type === 'cached-load') {
|
||||
ok(!cachedLoad, 'cached load should not occur twice');
|
||||
cachedLoad = true;
|
||||
forceRefresh();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
addEventListener('base-load', eventHandler, true, true);
|
||||
addEventListener('base-register', eventHandler, true, true);
|
||||
addEventListener('base-sw-ready', eventHandler, true, true);
|
||||
addEventListener('cached-load', eventHandler, true, true);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
|
||||
function wait_until_controlled() {
|
||||
return new Promise(function(resolve) {
|
||||
if (navigator.serviceWorker.controller) {
|
||||
return resolve();
|
||||
}
|
||||
navigator.serviceWorker.addEventListener('controllerchange', function onController() {
|
||||
if (navigator.serviceWorker.controller) {
|
||||
navigator.serviceWorker.removeEventListener('controllerchange', onController);
|
||||
return resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
addEventListener('load', function(event) {
|
||||
var registration;
|
||||
navigator.serviceWorker.register('download_worker.js').then(function(swr) {
|
||||
registration = swr;
|
||||
|
||||
// While the iframe below is a navigation, we still wait until we are
|
||||
// controlled here. We want an active client to hold the service worker
|
||||
// alive since it calls unregister() on itself.
|
||||
return wait_until_controlled();
|
||||
|
||||
}).then(function() {
|
||||
var frame = document.createElement('iframe');
|
||||
document.body.appendChild(frame);
|
||||
frame.src = 'fake_download';
|
||||
|
||||
// The service worker is unregistered in the fetch event. The window and
|
||||
// frame are cleaned up from the browser chrome script.
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,28 @@
|
||||
addEventListener('install', function(evt) {
|
||||
evt.waitUntil(self.skipWaiting());
|
||||
});
|
||||
|
||||
addEventListener('activate', function(evt) {
|
||||
// We claim the current clients in order to ensure that we have an
|
||||
// active client when we call unregister in the fetch handler. Otherwise
|
||||
// the unregister() can kill the current worker before returning a
|
||||
// response.
|
||||
evt.waitUntil(clients.claim());
|
||||
});
|
||||
|
||||
addEventListener('fetch', function(evt) {
|
||||
// This worker may live long enough to receive a fetch event from the next
|
||||
// test. Just pass such requests through to the network.
|
||||
if (evt.request.url.indexOf('fake_download') === -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We should only get a single download fetch event. Automatically unregister.
|
||||
evt.respondWith(registration.unregister().then(function() {
|
||||
return new Response('service worker generated download', {
|
||||
headers: {
|
||||
'Content-Disposition': 'attachment; filename="fake_download.bin"'
|
||||
}
|
||||
});
|
||||
}));
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<script>
|
||||
window.onmessage = function(e) {
|
||||
window.parent.postMessage(e.data, "*");
|
||||
if (e.data.status == "protocol") {
|
||||
document.querySelector("iframe").src = "image.html";
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<iframe src="http://example.com/tests/dom/workers/test/serviceworkers/fetch/upgrade-insecure/index.html"></iframe>
|
||||
@@ -0,0 +1 @@
|
||||
Content-Security-Policy: upgrade-insecure-requests
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 87 B |
Binary file not shown.
|
After Width: | Height: | Size: 123 B |
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<script>
|
||||
onload=function(){
|
||||
var img = new Image();
|
||||
img.src = "http://example.com/tests/dom/workers/test/serviceworkers/fetch/upgrade-insecure/image-20px.png";
|
||||
img.onload = function() {
|
||||
window.parent.postMessage({status: "image", data: img.width}, "*");
|
||||
};
|
||||
img.onerror = function() {
|
||||
window.parent.postMessage({status: "image", data: "error"}, "*");
|
||||
};
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<script>
|
||||
window.parent.postMessage({status: "protocol", data: location.protocol}, "*");
|
||||
</script>
|
||||
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<script>
|
||||
function ok(v, msg) {
|
||||
window.parent.postMessage({status: "ok", result: !!v, message: msg}, "*");
|
||||
}
|
||||
|
||||
function done(reg) {
|
||||
ok(reg.active, "The active worker should be available.");
|
||||
window.parent.postMessage({status: "registrationdone"}, "*");
|
||||
}
|
||||
|
||||
navigator.serviceWorker.ready.then(done);
|
||||
navigator.serviceWorker.register("upgrade-insecure_test.js", {scope: "."});
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<script>
|
||||
navigator.serviceWorker.getRegistration(".").then(function(registration) {
|
||||
registration.unregister().then(function(success) {
|
||||
if (success) {
|
||||
window.parent.postMessage({status: "unregistrationdone"}, "*");
|
||||
}
|
||||
}, function(e) {
|
||||
dump("Unregistering the SW failed with " + e + "\n");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,11 @@
|
||||
self.addEventListener("fetch", function(event) {
|
||||
if (event.request.url.indexOf("index.html") >= 0) {
|
||||
event.respondWith(fetch("realindex.html"));
|
||||
} else if (event.request.url.indexOf("image-20px.png") >= 0) {
|
||||
if (event.request.url.indexOf("https://") == 0) {
|
||||
event.respondWith(fetch("image-40px.png"));
|
||||
} else {
|
||||
event.respondWith(Response.error());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
var name = 'browserRefresherCache';
|
||||
|
||||
self.addEventListener('install', function(event) {
|
||||
event.waitUntil(
|
||||
Promise.all([caches.open(name),
|
||||
fetch('./browser_cached_force_refresh.html')]).then(function(results) {
|
||||
var cache = results[0];
|
||||
var response = results[1];
|
||||
return cache.put('./browser_base_force_refresh.html', response);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', function (event) {
|
||||
event.respondWith(
|
||||
caches.open(name).then(function(cache) {
|
||||
return cache.match(event.request);
|
||||
}).then(function(response) {
|
||||
return response || fetch(event.request);
|
||||
})
|
||||
);
|
||||
});
|
||||
@@ -98,6 +98,15 @@ support-files =
|
||||
fetch/sandbox/register.html
|
||||
fetch/sandbox/unregister.html
|
||||
fetch/sandbox/sandbox_test.js
|
||||
fetch/upgrade-insecure/upgrade-insecure_test.js
|
||||
fetch/upgrade-insecure/embedder.html
|
||||
fetch/upgrade-insecure/embedder.html^headers^
|
||||
fetch/upgrade-insecure/image.html
|
||||
fetch/upgrade-insecure/image-20px.png
|
||||
fetch/upgrade-insecure/image-40px.png
|
||||
fetch/upgrade-insecure/realindex.html
|
||||
fetch/upgrade-insecure/register.html
|
||||
fetch/upgrade-insecure/unregister.html
|
||||
match_all_properties_worker.js
|
||||
match_all_clients/match_all_controlled.html
|
||||
test_serviceworker_interfaces.js
|
||||
@@ -274,7 +283,7 @@ skip-if = toolkit == "android" || toolkit == "gonk"
|
||||
[test_file_blob_upload.html]
|
||||
[test_unresolved_fetch_interception.html]
|
||||
[test_hsts_upgrade_intercept.html]
|
||||
skip-if = e10s # Bug 1214305
|
||||
[test_csp_upgrade-insecure_intercept.html]
|
||||
[test_serviceworker_header.html]
|
||||
[test_openWindow.html]
|
||||
skip-if = toolkit == "android" || toolkit == "gonk"
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test that a CSP upgraded request can be intercepted by a service worker</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<iframe></iframe>
|
||||
</div>
|
||||
<pre id="test"></pre>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var iframe;
|
||||
function runTest() {
|
||||
iframe = document.querySelector("iframe");
|
||||
iframe.src = "https://example.com/tests/dom/workers/test/serviceworkers/fetch/upgrade-insecure/register.html";
|
||||
window.onmessage = function(e) {
|
||||
if (e.data.status == "ok") {
|
||||
ok(e.data.result, e.data.message);
|
||||
} else if (e.data.status == "registrationdone") {
|
||||
iframe.src = "https://example.com/tests/dom/workers/test/serviceworkers/fetch/upgrade-insecure/embedder.html";
|
||||
} else if (e.data.status == "protocol") {
|
||||
is(e.data.data, "https:", "Correct protocol expected");
|
||||
} else if (e.data.status == "image") {
|
||||
is(e.data.data, 40, "The image request was upgraded before interception");
|
||||
iframe.src = "https://example.com/tests/dom/workers/test/serviceworkers/fetch/upgrade-insecure/unregister.html";
|
||||
} else if (e.data.status == "unregistrationdone") {
|
||||
window.onmessage = null;
|
||||
SimpleTest.finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
onload = function() {
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["dom.serviceWorkers.exemptFromPerDomainMax", true],
|
||||
["dom.serviceWorkers.enabled", true],
|
||||
["dom.serviceWorkers.testing.enabled", true],
|
||||
["dom.serviceWorkers.interception.enabled", true],
|
||||
// This is needed so that we can test upgrading a non-secure load inside an https iframe.
|
||||
["security.mixed_content.block_active_content", false],
|
||||
["security.mixed_content.block_display_content", false],
|
||||
]}, runTest);
|
||||
};
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
return CallCreateInstance(NS_DIALOGPARAMBLOCK_CONTRACTID, &mBlock);
|
||||
}
|
||||
nsIDialogParamBlock * operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN { return mBlock; }
|
||||
operator nsIDialogParamBlock * const () { return mBlock; }
|
||||
operator nsIDialogParamBlock * () const { return mBlock; }
|
||||
|
||||
private:
|
||||
nsIDialogParamBlock *mBlock;
|
||||
|
||||
@@ -941,7 +941,7 @@ Layer::ApplyPendingUpdatesForThisTransaction()
|
||||
}
|
||||
}
|
||||
|
||||
const float
|
||||
float
|
||||
Layer::GetLocalOpacity()
|
||||
{
|
||||
float opacity = mOpacity;
|
||||
|
||||
+2
-2
@@ -1354,7 +1354,7 @@ public:
|
||||
* Returns the local opacity for this layer: either mOpacity or,
|
||||
* for shadow layers, GetShadowOpacity()
|
||||
*/
|
||||
const float GetLocalOpacity();
|
||||
float GetLocalOpacity();
|
||||
|
||||
/**
|
||||
* DRAWING PHASE ONLY
|
||||
@@ -1637,7 +1637,7 @@ public:
|
||||
* marked as needed to be recomposited.
|
||||
*/
|
||||
const nsIntRegion& GetInvalidRegion() { return mInvalidRegion; }
|
||||
const void AddInvalidRegion(const nsIntRegion& aRegion) {
|
||||
void AddInvalidRegion(const nsIntRegion& aRegion) {
|
||||
mInvalidRegion.Or(mInvalidRegion, aRegion);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,11 +92,11 @@ void mozilla_dump_image(void* bytes, int width, int height, int bytepp,
|
||||
|
||||
}
|
||||
|
||||
static const uint8_t PremultiplyValue(uint8_t a, uint8_t v) {
|
||||
static uint8_t PremultiplyValue(uint8_t a, uint8_t v) {
|
||||
return gfxUtils::sPremultiplyTable[a*256+v];
|
||||
}
|
||||
|
||||
static const uint8_t UnpremultiplyValue(uint8_t a, uint8_t v) {
|
||||
static uint8_t UnpremultiplyValue(uint8_t a, uint8_t v) {
|
||||
return gfxUtils::sUnpremultiplyTable[a*256+v];
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ class Message : public Pickle {
|
||||
header()->seqno = aSeqno;
|
||||
}
|
||||
|
||||
const char* const name() const {
|
||||
const char* name() const {
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class MessageIterator {
|
||||
NOTREACHED();
|
||||
return val;
|
||||
}
|
||||
const void NextData(const char** data, int* length) const {
|
||||
void NextData(const char** data, int* length) const {
|
||||
if (!msg_.ReadData(&iter_, data, length)) {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ using ManagedContainer = nsTHashtable<nsPtrHashKey<Protocol>>;
|
||||
|
||||
template<typename Protocol>
|
||||
Protocol*
|
||||
LoneManagedOrNull(const ManagedContainer<Protocol>& aManagees)
|
||||
LoneManagedOrNullAsserts(const ManagedContainer<Protocol>& aManagees)
|
||||
{
|
||||
if (aManagees.IsEmpty()) {
|
||||
return nullptr;
|
||||
@@ -345,6 +345,19 @@ LoneManagedOrNull(const ManagedContainer<Protocol>& aManagees)
|
||||
return aManagees.ConstIter().Get()->GetKey();
|
||||
}
|
||||
|
||||
// appId's are for B2G only currently, where managees.Count() == 1. This is
|
||||
// not guaranteed currently in Desktop, so for paths used for desktop,
|
||||
// don't assert there's one managee.
|
||||
template<typename Protocol>
|
||||
Protocol*
|
||||
SingleManagedOrNull(const ManagedContainer<Protocol>& aManagees)
|
||||
{
|
||||
if (aManagees.Count() != 1) {
|
||||
return nullptr;
|
||||
}
|
||||
return aManagees.ConstIter().Get()->GetKey();
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user