summaryrefslogtreecommitdiffstats
path: root/dom
diff options
context:
space:
mode:
Diffstat (limited to 'dom')
-rw-r--r--dom/base/nsJSEnvironment.cpp5
-rw-r--r--dom/base/nsScriptLoader.cpp5
-rw-r--r--dom/canvas/CanvasRenderingContext2D.cpp73
-rw-r--r--dom/system/NetworkGeolocationProvider.js41
-rw-r--r--dom/workers/RuntimeService.cpp67
-rw-r--r--dom/workers/RuntimeService.h13
-rw-r--r--dom/workers/WorkerPrefs.h3
-rw-r--r--dom/workers/WorkerPrivate.cpp60
-rw-r--r--dom/workers/WorkerPrivate.h5
-rw-r--r--dom/workers/Workers.h8
10 files changed, 101 insertions, 179 deletions
diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp
index b273d00c9..576f3052a 100644
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -2282,6 +2282,7 @@ SetMemoryGCModePrefChangedCallback(const char* aPrefName, void* aClosure)
{
bool enableZoneGC = Preferences::GetBool("javascript.options.mem.gc_per_zone");
bool enableIncrementalGC = Preferences::GetBool("javascript.options.mem.gc_incremental");
+ bool enableGenerationalGC = Preferences::GetBool("javascript.options.mem.gc_generational");
JSGCMode mode;
if (enableIncrementalGC) {
mode = JSGC_MODE_INCREMENTAL;
@@ -2291,6 +2292,7 @@ SetMemoryGCModePrefChangedCallback(const char* aPrefName, void* aClosure)
mode = JSGC_MODE_GLOBAL;
}
JS_SetGCParameter(sContext, JSGC_MODE, mode);
+ JS_SetGGCMode(sContext, enableGenerationalGC);
}
static void
@@ -2485,6 +2487,9 @@ nsJSContext::EnsureStatics()
Preferences::RegisterCallbackAndCall(SetMemoryGCSliceTimePrefChangedCallback,
"javascript.options.mem.gc_incremental_slice_ms");
+ Preferences::RegisterCallbackAndCall(SetMemoryGCModePrefChangedCallback,
+ "javascript.options.mem.gc_generational");
+
Preferences::RegisterCallbackAndCall(SetMemoryGCCompactingPrefChangedCallback,
"javascript.options.mem.gc_compacting");
diff --git a/dom/base/nsScriptLoader.cpp b/dom/base/nsScriptLoader.cpp
index 6c732db6c..a6d20e363 100644
--- a/dom/base/nsScriptLoader.cpp
+++ b/dom/base/nsScriptLoader.cpp
@@ -2630,7 +2630,10 @@ nsScriptLoader::PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
}
nsAutoCString sourceMapURL;
- rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("X-SourceMap"), sourceMapURL);
+ rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("SourceMap"), sourceMapURL);
+ if (NS_FAILED(rv)) {
+ rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("X-SourceMap"), sourceMapURL);
+ }
if (NS_SUCCEEDED(rv)) {
aRequest->mHasSourceMapURL = true;
aRequest->mSourceMapURL = NS_ConvertUTF8toUTF16(sourceMapURL);
diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp
index 2ed39627e..b0a430fe4 100644
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -68,6 +68,8 @@
#include "CanvasImageCache.h"
#include <algorithm>
+#include <stdlib.h>
+#include <time.h>
#include "jsapi.h"
#include "jsfriendapi.h"
@@ -2083,6 +2085,18 @@ CanvasRenderingContext2D::GetInputStream(const char* aMimeType,
return NS_ERROR_FAILURE;
}
+ bool PoisonData = Preferences::GetBool("canvas.poisondata",false);
+ if (PoisonData) {
+ srand(time(NULL));
+ // Image buffer is always a packed BGRA array (BGRX -> BGR[FF])
+ // so always 4-byte pixels.
+ // GetImageBuffer => SurfaceToPackedBGRA [=> ConvertBGRXToBGRA]
+ for (int32_t j = 0; j < mWidth * mHeight * 4; ++j) {
+ if (imageBuffer[j] !=0 && imageBuffer[j] != 255)
+ imageBuffer[j] += rand() % 3 - 1;
+ }
+ }
+
return ImageEncoder::GetInputStream(mWidth, mHeight, imageBuffer.get(),
format, encoder, aEncoderOptions,
aStream);
@@ -5698,6 +5712,14 @@ CanvasRenderingContext2D::GetImageData(JSContext* aCx, double aSx,
return imageData.forget();
}
+inline uint8_t PoisonValue(uint8_t v)
+{
+ if (v==0 || v==255)
+ return v; //don't fuzz edges to prevent overflow/underflow
+
+ return v + rand() %3 -1;
+}
+
nsresult
CanvasRenderingContext2D::GetImageDataArray(JSContext* aCx,
int32_t aX,
@@ -5712,6 +5734,10 @@ CanvasRenderingContext2D::GetImageDataArray(JSContext* aCx,
MOZ_ASSERT(aWidth && aHeight);
+ bool PoisonData = Preferences::GetBool("canvas.poisondata",false);
+ if (PoisonData)
+ srand(time(NULL));
+
CheckedInt<uint32_t> len = CheckedInt<uint32_t>(aWidth) * aHeight * 4;
if (!len.isValid()) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
@@ -5784,21 +5810,31 @@ CanvasRenderingContext2D::GetImageDataArray(JSContext* aCx,
uint8_t* dst = data + dstWriteRect.y * (aWidth * 4) + dstWriteRect.x * 4;
+ uint8_t a,r,g,b;
+
if (mOpaque) {
for (int32_t j = 0; j < dstWriteRect.height; ++j) {
for (int32_t i = 0; i < dstWriteRect.width; ++i) {
// XXX Is there some useful swizzle MMX we can use here?
#if MOZ_LITTLE_ENDIAN
- uint8_t b = *src++;
- uint8_t g = *src++;
- uint8_t r = *src++;
+ b = *src++;
+ g = *src++;
+ r = *src++;
src++;
#else
src++;
- uint8_t r = *src++;
- uint8_t g = *src++;
- uint8_t b = *src++;
+ r = *src++;
+ g = *src++;
+ b = *src++;
#endif
+
+ // Poison data for trackers if enabled
+ if (PoisonData) {
+ PoisonValue(r);
+ PoisonValue(g);
+ PoisonValue(b);
+ }
+
*dst++ = r;
*dst++ = g;
*dst++ = b;
@@ -5812,16 +5848,25 @@ CanvasRenderingContext2D::GetImageDataArray(JSContext* aCx,
for (int32_t i = 0; i < dstWriteRect.width; ++i) {
// XXX Is there some useful swizzle MMX we can use here?
#if MOZ_LITTLE_ENDIAN
- uint8_t b = *src++;
- uint8_t g = *src++;
- uint8_t r = *src++;
- uint8_t a = *src++;
+ b = *src++;
+ g = *src++;
+ r = *src++;
+ a = *src++;
#else
- uint8_t a = *src++;
- uint8_t r = *src++;
- uint8_t g = *src++;
- uint8_t b = *src++;
+ a = *src++;
+ r = *src++;
+ g = *src++;
+ b = *src++;
#endif
+
+ // Poison data for trackers if enabled
+ if (PoisonData) {
+ PoisonValue(a);
+ PoisonValue(r);
+ PoisonValue(g);
+ PoisonValue(b);
+ }
+
// Convert to non-premultiplied color
*dst++ = gfxUtils::sUnpremultiplyTable[a * 256 + r];
*dst++ = gfxUtils::sUnpremultiplyTable[a * 256 + g];
diff --git a/dom/system/NetworkGeolocationProvider.js b/dom/system/NetworkGeolocationProvider.js
index ea2abe55f..ad15ed802 100644
--- a/dom/system/NetworkGeolocationProvider.js
+++ b/dom/system/NetworkGeolocationProvider.js
@@ -219,9 +219,20 @@ WifiGeoCoordsObject.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPositionCoords])
};
-function WifiGeoPositionObject(lat, lng, acc) {
+function WifiGeoPositionObject(lat, lng, acc, cc, tz, zip, city, rc, region, country, isp, org, as) {
this.coords = new WifiGeoCoordsObject(lat, lng, acc, 0, 0);
this.address = null;
+ this.countrycode = cc;
+ this.timezone = tz;
+ this.zipcode = zip;
+ this.postalcode = zip;
+ this.city = city;
+ this.regioncode = rc;
+ this.region = region;
+ this.country = country;
+ this.isp = isp;
+ this.org = org;
+ this.as = as;
this.timestamp = Date.now();
}
@@ -431,41 +442,54 @@ WifiGeoPositionProvider.prototype = {
let xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance(Ci.nsIXMLHttpRequest);
- this.notifyListener("locationUpdatePending");
+ // XXX: Dead code?
+ // this.notifyListener("locationUpdatePending");
try {
- xhr.open("POST", url, true);
+ xhr.open("GET", url, true);
xhr.channel.loadFlags = Ci.nsIChannel.LOAD_ANONYMOUS;
} catch (e) {
this.notifyListener("notifyError",
[POSITION_UNAVAILABLE]);
return;
}
- xhr.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
xhr.responseType = "json";
xhr.mozBackgroundRequest = true;
xhr.timeout = Services.prefs.getIntPref("geo.wifi.xhr.timeout");
+
xhr.ontimeout = (function() {
LOG("Location request XHR timed out.")
this.notifyListener("notifyError",
[POSITION_UNAVAILABLE]);
}).bind(this);
+
xhr.onerror = (function() {
this.notifyListener("notifyError",
[POSITION_UNAVAILABLE]);
}).bind(this);
+
xhr.onload = (function() {
LOG("server returned status: " + xhr.status + " --> " + JSON.stringify(xhr.response));
if ((xhr.channel instanceof Ci.nsIHttpChannel && xhr.status != 200) ||
- !xhr.response || !xhr.response.location) {
+ !xhr.response || xhr.response.status == 'fail') {
this.notifyListener("notifyError",
[POSITION_UNAVAILABLE]);
return;
}
- let newLocation = new WifiGeoPositionObject(xhr.response.location.lat,
- xhr.response.location.lng,
- xhr.response.accuracy);
+ let newLocation = new WifiGeoPositionObject(xhr.response.lat,
+ xhr.response.lon,
+ null, //accuracy not provided
+ xhr.response.countryCode,
+ xhr.response.timezone,
+ xhr.response.zip,
+ xhr.response.city,
+ xhr.response.region,
+ xhr.response.regionName,
+ xhr.response.country,
+ xhr.response.isp,
+ xhr.response.org,
+ xhr.response.as);
this.notifyListener("update", [newLocation]);
gCachedRequest = new CachedRequest(newLocation, data.cellTowers, data.wifiAccessPoints);
@@ -478,6 +502,7 @@ WifiGeoPositionProvider.prototype = {
notifyListener: function(listenerFunc, args) {
args = args || [];
+ LOG("Notify listener " + listenerFunc);
try {
this.listener[listenerFunc].apply(this.listener, args);
} catch(e) {
diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp
index d1d76e3d1..1f5616873 100644
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -290,13 +290,6 @@ LoadContextOptions(const char* aPrefName, void* /* aClosure */)
return;
}
-#ifdef JS_GC_ZEAL
- if (prefName.EqualsLiteral(PREF_JS_OPTIONS_PREFIX PREF_GCZEAL) ||
- prefName.EqualsLiteral(PREF_WORKERS_OPTIONS_PREFIX PREF_GCZEAL)) {
- return;
- }
-#endif
-
// Context options.
JS::ContextOptions contextOptions;
contextOptions.setAsmJS(GetWorkerPref<bool>(NS_LITERAL_CSTRING("asmjs")))
@@ -317,37 +310,6 @@ LoadContextOptions(const char* aPrefName, void* /* aClosure */)
}
}
-#ifdef JS_GC_ZEAL
-void
-LoadGCZealOptions(const char* /* aPrefName */, void* /* aClosure */)
-{
- AssertIsOnMainThread();
-
- RuntimeService* rts = RuntimeService::GetService();
- if (!rts) {
- // May be shutting down, just bail.
- return;
- }
-
- int32_t gczeal = GetWorkerPref<int32_t>(NS_LITERAL_CSTRING(PREF_GCZEAL), -1);
- if (gczeal < 0) {
- gczeal = 0;
- }
-
- int32_t frequency =
- GetWorkerPref<int32_t>(NS_LITERAL_CSTRING("gcZeal.frequency"), -1);
- if (frequency < 0) {
- frequency = JS_DEFAULT_ZEAL_FREQ;
- }
-
- RuntimeService::SetDefaultGCZeal(uint8_t(gczeal), uint32_t(frequency));
-
- if (rts) {
- rts->UpdateAllWorkerGCZeal();
- }
-}
-#endif
-
void
UpdateCommonJSGCMemoryOption(RuntimeService* aRuntimeService,
const nsACString& aPrefName, JSGCParamKey aKey)
@@ -994,10 +956,6 @@ InitJSContextForWorker(WorkerPrivate* aWorkerPrivate, JSContext* aWorkerCx)
js::SetCTypesActivityCallback(aWorkerCx, CTypesActivityCallback);
-#ifdef JS_GC_ZEAL
- JS_SetGCZeal(aWorkerCx, settings.gcZeal, settings.gcZealFrequency);
-#endif
-
return true;
}
@@ -1981,10 +1939,6 @@ RuntimeService::Init()
sDefaultJSSettings.chrome.maxScriptRuntime = -1;
sDefaultJSSettings.chrome.compartmentOptions.behaviors().setVersion(JSVERSION_LATEST);
sDefaultJSSettings.content.maxScriptRuntime = MAX_SCRIPT_RUN_TIME_SEC;
-#ifdef JS_GC_ZEAL
- sDefaultJSSettings.gcZealFrequency = JS_DEFAULT_ZEAL_FREQ;
- sDefaultJSSettings.gcZeal = 0;
-#endif
SetDefaultJSGCSettings(JSGC_MAX_BYTES, WORKER_DEFAULT_RUNTIME_HEAPSIZE);
SetDefaultJSGCSettings(JSGC_ALLOCATION_THRESHOLD,
WORKER_DEFAULT_ALLOCATION_THRESHOLD);
@@ -2033,12 +1987,6 @@ RuntimeService::Init()
LoadJSGCMemoryOptions,
PREF_WORKERS_OPTIONS_PREFIX PREF_MEM_OPTIONS_PREFIX,
nullptr)) ||
-#ifdef JS_GC_ZEAL
- NS_FAILED(Preferences::RegisterCallback(
- LoadGCZealOptions,
- PREF_JS_OPTIONS_PREFIX PREF_GCZEAL,
- nullptr)) ||
-#endif
#define WORKER_SIMPLE_PREF(name, getter, NAME) \
NS_FAILED(Preferences::RegisterCallbackAndCall( \
@@ -2227,12 +2175,6 @@ RuntimeService::Cleanup()
#undef WORKER_SIMPLE_PREF
#undef WORKER_PREF
-#ifdef JS_GC_ZEAL
- NS_FAILED(Preferences::UnregisterCallback(
- LoadGCZealOptions,
- PREF_JS_OPTIONS_PREFIX PREF_GCZEAL,
- nullptr)) ||
-#endif
NS_FAILED(Preferences::UnregisterCallback(
LoadJSGCMemoryOptions,
PREF_JS_OPTIONS_PREFIX PREF_MEM_OPTIONS_PREFIX,
@@ -2644,15 +2586,6 @@ RuntimeService::UpdateAllWorkerMemoryParameter(JSGCParamKey aKey,
BROADCAST_ALL_WORKERS(UpdateJSWorkerMemoryParameter, aKey, aValue);
}
-#ifdef JS_GC_ZEAL
-void
-RuntimeService::UpdateAllWorkerGCZeal()
-{
- BROADCAST_ALL_WORKERS(UpdateGCZeal, sDefaultJSSettings.gcZeal,
- sDefaultJSSettings.gcZealFrequency);
-}
-#endif
-
void
RuntimeService::GarbageCollectAllWorkers(bool aShrinking)
{
diff --git a/dom/workers/RuntimeService.h b/dom/workers/RuntimeService.h
index 2e5cc1dad..2ab8cbabe 100644
--- a/dom/workers/RuntimeService.h
+++ b/dom/workers/RuntimeService.h
@@ -215,19 +215,6 @@ public:
void
UpdateAllWorkerMemoryParameter(JSGCParamKey aKey, uint32_t aValue);
-#ifdef JS_GC_ZEAL
- static void
- SetDefaultGCZeal(uint8_t aGCZeal, uint32_t aFrequency)
- {
- AssertIsOnMainThread();
- sDefaultJSSettings.gcZeal = aGCZeal;
- sDefaultJSSettings.gcZealFrequency = aFrequency;
- }
-
- void
- UpdateAllWorkerGCZeal();
-#endif
-
void
GarbageCollectAllWorkers(bool aShrinking);
diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
index c9b605a84..9a1be4801 100644
--- a/dom/workers/WorkerPrefs.h
+++ b/dom/workers/WorkerPrefs.h
@@ -44,6 +44,3 @@ WORKER_PREF("intl.accept_languages", PrefLanguagesChanged)
WORKER_PREF("general.appname.override", AppNameOverrideChanged)
WORKER_PREF("general.appversion.override", AppVersionOverrideChanged)
WORKER_PREF("general.platform.override", PlatformOverrideChanged)
-#ifdef JS_GC_ZEAL
-WORKER_PREF("dom.workers.options.gcZeal", LoadGCZealOptions)
-#endif
diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
index 1df4e5551..c2ab4aca3 100644
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -1391,30 +1391,6 @@ private:
}
};
-#ifdef JS_GC_ZEAL
-class UpdateGCZealRunnable final : public WorkerControlRunnable
-{
- uint8_t mGCZeal;
- uint32_t mFrequency;
-
-public:
- UpdateGCZealRunnable(WorkerPrivate* aWorkerPrivate,
- uint8_t aGCZeal,
- uint32_t aFrequency)
- : WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount),
- mGCZeal(aGCZeal), mFrequency(aFrequency)
- { }
-
-private:
- virtual bool
- WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
- {
- aWorkerPrivate->UpdateGCZealInternal(aCx, mGCZeal, mFrequency);
- return true;
- }
-};
-#endif
-
class GarbageCollectRunnable final : public WorkerControlRunnable
{
bool mShrinking;
@@ -3148,27 +3124,6 @@ WorkerPrivateParent<Derived>::UpdateJSWorkerMemoryParameter(JSGCParamKey aKey,
}
}
-#ifdef JS_GC_ZEAL
-template <class Derived>
-void
-WorkerPrivateParent<Derived>::UpdateGCZeal(uint8_t aGCZeal, uint32_t aFrequency)
-{
- AssertIsOnParentThread();
-
- {
- MutexAutoLock lock(mMutex);
- mJSSettings.gcZeal = aGCZeal;
- mJSSettings.gcZealFrequency = aFrequency;
- }
-
- RefPtr<UpdateGCZealRunnable> runnable =
- new UpdateGCZealRunnable(ParentAsWorkerPrivate(), aGCZeal, aFrequency);
- if (!runnable->Dispatch()) {
- NS_WARNING("Failed to update worker gczeal!");
- }
-}
-#endif
-
template <class Derived>
void
WorkerPrivateParent<Derived>::GarbageCollect(bool aShrinking)
@@ -6323,21 +6278,6 @@ WorkerPrivate::UpdateJSWorkerMemoryParameterInternal(JSContext* aCx,
}
}
-#ifdef JS_GC_ZEAL
-void
-WorkerPrivate::UpdateGCZealInternal(JSContext* aCx, uint8_t aGCZeal,
- uint32_t aFrequency)
-{
- AssertIsOnWorkerThread();
-
- JS_SetGCZeal(aCx, aGCZeal, aFrequency);
-
- for (uint32_t index = 0; index < mChildWorkers.Length(); index++) {
- mChildWorkers[index]->UpdateGCZeal(aGCZeal, aFrequency);
- }
-}
-#endif
-
void
WorkerPrivate::GarbageCollectInternal(JSContext* aCx, bool aShrinking,
bool aCollectChildren)
diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h
index ad906b054..8008f30e5 100644
--- a/dom/workers/WorkerPrivate.h
+++ b/dom/workers/WorkerPrivate.h
@@ -386,11 +386,6 @@ public:
void
UpdateJSWorkerMemoryParameter(JSGCParamKey key, uint32_t value);
-#ifdef JS_GC_ZEAL
- void
- UpdateGCZeal(uint8_t aGCZeal, uint32_t aFrequency);
-#endif
-
void
GarbageCollect(bool aShrinking);
diff --git a/dom/workers/Workers.h b/dom/workers/Workers.h
index 89e2ccfca..ad083d3b8 100644
--- a/dom/workers/Workers.h
+++ b/dom/workers/Workers.h
@@ -143,15 +143,7 @@ struct JSSettings
JSGCSettingsArray gcSettings;
JS::ContextOptions contextOptions;
-#ifdef JS_GC_ZEAL
- uint8_t gcZeal;
- uint32_t gcZealFrequency;
-#endif
-
JSSettings()
-#ifdef JS_GC_ZEAL
- : gcZeal(0), gcZealFrequency(0)
-#endif
{
for (uint32_t index = 0; index < ArrayLength(gcSettings); index++) {
new (gcSettings + index) JSGCSetting();