Merge inbound to m-c. a=merge

This commit is contained in:
Ryan VanderMeulen
2017-01-07 11:22:47 -05:00
258 changed files with 4983 additions and 2151 deletions

View File

@@ -848,8 +848,9 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
Accessible* parent = childDoc->Parent();
DocAccessibleChild* parentIPCDoc = mDocument->IPCDoc();
MOZ_DIAGNOSTIC_ASSERT(parentIPCDoc);
uint64_t id = reinterpret_cast<uintptr_t>(parent->UniqueID());
MOZ_ASSERT(id);
MOZ_DIAGNOSTIC_ASSERT(id);
DocAccessibleChild* ipcDoc = childDoc->IPCDoc();
if (ipcDoc) {
parentIPCDoc->SendBindChildDoc(ipcDoc, id);
@@ -860,14 +861,12 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
childDoc->SetIPCDoc(ipcDoc);
#if defined(XP_WIN)
MOZ_ASSERT(parentIPCDoc);
parentIPCDoc->ConstructChildDocInParentProcess(ipcDoc, id,
AccessibleWrap::GetChildIDFor(childDoc));
#else
nsCOMPtr<nsITabChild> tabChild =
do_GetInterface(mDocument->DocumentNode()->GetDocShell());
if (tabChild) {
MOZ_ASSERT(parentIPCDoc);
static_cast<TabChild*>(tabChild.get())->
SendPDocAccessibleConstructor(ipcDoc, parentIPCDoc, id, 0, 0);
}

View File

@@ -34,3 +34,6 @@ BROWSER_CHROME_MANIFESTS += [
'tests/browser/browser.ini',
'tests/browser/e10s/browser.ini'
]
with Files("**"):
BUG_COMPONENT = ("Core", "Disability Access APIs")

View File

@@ -540,3 +540,6 @@ EXTRA_JS_MODULES.commonjs.toolkit += [
'source/lib/toolkit/loader.js',
'source/lib/toolkit/require.js',
]
with Files("**"):
BUG_COMPONENT = ("Add-on SDK", "General")

View File

@@ -1161,6 +1161,9 @@ sticky_pref("browser.newtabpage.enhanced", true);
// enables Activity Stream inspired layout
pref("browser.newtabpage.compact", false);
// enables showing basic placeholders for missing thumbnails
pref("browser.newtabpage.thumbnailPlaceholder", false);
// number of rows of newtab grid
pref("browser.newtabpage.rows", 3);

View File

@@ -173,7 +173,8 @@ var gGrid = {
site.innerHTML =
'<span class="newtab-sponsored">' + newTabString("sponsored.button") + '</span>' +
'<a class="newtab-link">' +
' <span class="newtab-thumbnail"/>' +
' <span class="newtab-thumbnail placeholder"/>' +
' <span class="newtab-thumbnail thumbnail"/>' +
' <span class="newtab-thumbnail enhanced-content"/>' +
' <span class="newtab-title"/>' +
'</a>' +

View File

@@ -4,6 +4,9 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#endif
const THUMBNAIL_PLACEHOLDER_ENABLED =
Services.prefs.getBoolPref("browser.newtabpage.thumbnailPlaceholder");
/**
* This class represents a site that is contained in a cell and can be pinned,
* moved around or deleted.
@@ -244,14 +247,26 @@ Site.prototype = {
let link = gAllPages.enhanced && DirectoryLinksProvider.getEnhancedLink(this.link) ||
this.link;
let thumbnail = this._querySelector(".newtab-thumbnail");
let thumbnail = this._querySelector(".newtab-thumbnail.thumbnail");
if (link.bgColor) {
thumbnail.style.backgroundColor = link.bgColor;
}
let uri = link.imageURI || PageThumbs.getThumbnailURL(this.url);
thumbnail.style.backgroundImage = 'url("' + uri + '")';
if (THUMBNAIL_PLACEHOLDER_ENABLED &&
link.type == "history" &&
link.baseDomain) {
let placeholder = this._querySelector(".newtab-thumbnail.placeholder");
let hue = 0;
for (let c of link.baseDomain) {
hue += c.charCodeAt(0);
}
hue %= 256;
placeholder.style.backgroundColor = "hsl(" + hue + ",50%,60%)";
placeholder.textContent = link.baseDomain.substr(0,1);
}
if (link.enhancedImageURI) {
let enhanced = this._querySelector(".enhanced-content");
enhanced.style.backgroundImage = 'url("' + link.enhancedImageURI + '")';

View File

@@ -31,7 +31,7 @@ add_task(function* () {
let siteNode = cell.site.node;
return {
type: siteNode.getAttribute("type"),
thumbnail: siteNode.querySelector(".newtab-thumbnail").style.backgroundImage,
thumbnail: siteNode.querySelector(".newtab-thumbnail.thumbnail").style.backgroundImage,
enhanced: siteNode.querySelector(".enhanced-content").style.backgroundImage,
title: siteNode.querySelector(".newtab-title").textContent,
suggested: siteNode.getAttribute("suggested"),

View File

@@ -29,7 +29,7 @@ add_task(function* () {
let siteNode = cell.site.node;
return {
type: siteNode.getAttribute("type"),
thumbnail: siteNode.querySelector(".newtab-thumbnail").style.backgroundImage,
thumbnail: siteNode.querySelector(".newtab-thumbnail.thumbnail").style.backgroundImage,
enhanced: siteNode.querySelector(".enhanced-content").style.backgroundImage,
title: siteNode.querySelector(".newtab-title").textContent,
suggested: siteNode.getAttribute("suggested"),

View File

@@ -844,6 +844,11 @@ extensions.registerSchemaAPI("tabs", "addon_parent", context => {
} else {
options.run_at = "document_idle";
}
if (details.cssOrigin !== null) {
options.css_origin = details.cssOrigin;
} else {
options.css_origin = "author";
}
return tabListener.awaitTabReady(tab).then(() => {
let browser = tab.linkedBrowser;

View File

@@ -30,6 +30,33 @@ add_task(function* testExecuteScript() {
});
},
},
{
background: "rgb(42, 42, 42)",
foreground: "rgb(0, 113, 4)",
promise: () => {
return browser.tabs.insertCSS({
code: "* { background: rgb(100, 100, 100) !important }",
cssOrigin: "author",
}).then(r => browser.tabs.insertCSS({
code: "* { background: rgb(42, 42, 42) !important }",
cssOrigin: "author",
}));
},
},
{
background: "rgb(100, 100, 100)",
foreground: "rgb(0, 113, 4)",
promise: () => {
// User has higher importance
return browser.tabs.insertCSS({
code: "* { background: rgb(100, 100, 100) !important }",
cssOrigin: "user",
}).then(r => browser.tabs.insertCSS({
code: "* { background: rgb(42, 42, 42) !important }",
cssOrigin: "author",
}));
},
},
];
function checkCSS() {

View File

@@ -47,6 +47,28 @@ add_task(function* testExecuteScript() {
});
},
},
// Insert CSS code.
{
background: "rgb(42, 42, 42)",
foreground: "rgb(0, 0, 0)",
promise: () => {
return browser.tabs.insertCSS({
code: "* { background: rgb(42, 42, 42) }",
cssOrigin: "user",
});
},
},
// Remove CSS code again.
{
background: "transparent",
foreground: "rgb(0, 0, 0)",
promise: () => {
return browser.tabs.removeCSS({
code: "* { background: rgb(42, 42, 42) }",
cssOrigin: "user",
});
},
},
];
function checkCSS() {

View File

@@ -115,10 +115,11 @@
#identity-box[sharing] > #identity-icon,
#sharing-icon {
animation: 3s linear pulse infinite;
animation: 3s linear identity-box-sharing-icon-pulse infinite;
}
@keyframes pulse {
/* This should remain identical to tab-sharing-icon-pulse in tabs.inc.css */
@keyframes identity-box-sharing-icon-pulse {
0%, 16.66%, 83.33%, 100% {
opacity: 0;
}

View File

@@ -167,6 +167,16 @@ body.compact .newtab-thumbnail {
outline-offset: -1px;
}
.newtab-thumbnail.placeholder {
color: white;
font-size: 85px;
line-height: 200%;
}
body.compact .newtab-thumbnail.placeholder {
font-size: 45px;
}
.newtab-cell:not([ignorehover]) .newtab-site:hover .newtab-thumbnail.enhanced-content {
opacity: 0;
}

View File

@@ -91,10 +91,11 @@
.tab-icon-image[sharing]:not([selected]),
.tab-sharing-icon-overlay {
animation: 3s linear pulse infinite;
animation: 3s linear tab-sharing-icon-pulse infinite;
}
@keyframes pulse {
/* This should remain identical to identity-box-sharing-icon-pulse in identity-block.inc.css */
@keyframes tab-sharing-icon-pulse {
0%, 16.66%, 83.33%, 100% {
opacity: 0;
}

View File

@@ -45,7 +45,7 @@ build-clang.py accepts a JSON config format with the following fields:
* patches: Optional list of patches to apply per platform. Supported platforms: macosx64, linux32, linux64. The default is Release.
* build_type: The type of build to make. Supported types: Release, Debug, RelWithDebInfo or MinSizeRel.
* build_libcxx: Whether to build with libcxx. The default is false.
* import_clang_tidy: Whether to import Mozilla checks into clang-tidy before building. The default is false.
* build_clang_tidy: Whether to build clang-tidy with the Mozilla checks imported. The default is false.
* osx_cross_compile: Whether to invoke CMake for OS X cross compile builds.
* assertions: Whether to enable LLVM assertions. The default is false.

View File

@@ -57,7 +57,7 @@ def patch(patch, srcdir):
'-s'])
def do_import_clang_tidy(source_dir):
def import_clang_tidy(source_dir):
clang_plugin_path = os.path.join(os.path.dirname(sys.argv[0]),
'..', 'clang-plugin')
clang_tidy_path = os.path.join(source_dir,
@@ -128,6 +128,16 @@ def mkdir_p(path):
raise
def delete(path):
if os.path.isdir(path):
shutil.rmtree(path)
else:
try:
os.unlink(path)
except:
pass
def install_libgcc(gcc_dir, clang_dir):
out = subprocess.check_output([os.path.join(gcc_dir, "bin", "gcc"),
'-print-libgcc-file-name'])
@@ -205,6 +215,8 @@ def build_one_stage(cc, cxx, ld, ar, ranlib,
# previous CMake run is cleared before running it again.
if os.path.exists(build_dir + "/CMakeCache.txt"):
os.remove(build_dir + "/CMakeCache.txt")
if os.path.exists(build_dir + "/CMakeFiles"):
shutil.rmtree(build_dir + "/CMakeFiles")
# cmake doesn't deal well with backslashes in paths.
def slashify_path(path):
@@ -279,6 +291,72 @@ def get_tool(config, key):
except which.WhichError:
raise ValueError("%s not found on PATH" % f)
# This function is intended to be called on the final build directory when
# building clang-tidy. Its job is to remove all of the files which won't
# be used for clang-tidy to reduce the download size. Currently when this
# function finishes its job, it will leave final_dir with a layout like this:
#
# clang/
# bin/
# clang-tidy
# include/
# * (nothing will be deleted here)
# lib/
# clang/
# 4.0.0/
# include/
# * (nothing will be deleted here)
# share/
# clang/
# clang-tidy-diff.py
# run-clang-tidy.py
def prune_final_dir_for_clang_tidy(final_dir):
# Make sure we only have what we expect.
dirs = ("bin", "include", "lib", "libexec", "msbuild-bin", "share", "tools")
for f in glob.glob("%s/*" % final_dir):
if os.path.basename(f) not in dirs:
raise Exception("Found unknown file %s in the final directory" % f)
if not os.path.isdir(f):
raise Exception("Expected %s to be a directory" %f)
# In bin/, only keep clang-tidy.
re_clang_tidy = re.compile(r"^clang-tidy(\.exe)?$", re.I)
for f in glob.glob("%s/bin/*" % final_dir):
if re_clang_tidy.search(os.path.basename(f)) is None:
delete(f)
# Keep include/ intact.
# In lib/, only keep lib/clang/N.M.O/include.
re_ver_num = re.compile(r"^\d+\.\d+\.\d+$", re.I)
for f in glob.glob("%s/lib/*" % final_dir):
if os.path.basename(f) != "clang":
delete(f)
for f in glob.glob("%s/lib/clang/*" % final_dir):
if re_ver_num.search(os.path.basename(f)) is None:
delete(f)
for f in glob.glob("%s/lib/clang/*/*" % final_dir):
if os.path.basename(f) != "include":
delete(f)
# Completely remove libexec/, msbuilld-bin and tools, if it exists.
shutil.rmtree(os.path.join(final_dir, "libexec"))
for d in ("msbuild-bin", "tools"):
d = os.path.join(final_dir, d)
if os.path.exists(d):
shutil.rmtree(d)
# In share/, only keep share/clang/*tidy*
re_clang_tidy = re.compile(r"tidy", re.I)
for f in glob.glob("%s/share/*" % final_dir):
if os.path.basename(f) != "clang":
delete(f)
for f in glob.glob("%s/share/clang/*" % final_dir):
if re_clang_tidy.search(os.path.basename(f)) is None:
delete(f)
if __name__ == "__main__":
# The directories end up in the debug info, so the easy way of getting
# a reproducible build is to run it in a know absolute directory.
@@ -356,11 +434,11 @@ if __name__ == "__main__":
build_libcxx = config["build_libcxx"]
if build_libcxx not in (True, False):
raise ValueError("Only boolean values are accepted for build_libcxx.")
import_clang_tidy = False
if "import_clang_tidy" in config:
import_clang_tidy = config["import_clang_tidy"]
if import_clang_tidy not in (True, False):
raise ValueError("Only boolean values are accepted for import_clang_tidy.")
build_clang_tidy = False
if "build_clang_tidy" in config:
build_clang_tidy = config["build_clang_tidy"]
if build_clang_tidy not in (True, False):
raise ValueError("Only boolean values are accepted for build_clang_tidy.")
osx_cross_compile = False
if "osx_cross_compile" in config:
osx_cross_compile = config["osx_cross_compile"]
@@ -435,15 +513,12 @@ if __name__ == "__main__":
# On Windows, we have to re-copy the whole directory every time.
if not is_windows() and os.path.islink(l[1]):
continue
if os.path.isdir(l[1]):
shutil.rmtree(l[1])
elif os.path.exists(l[1]):
os.unlink(l[1])
delete(l[1]);
if os.path.exists(l[0]):
symlink(l[0], l[1])
if import_clang_tidy:
do_import_clang_tidy(llvm_source_dir)
if build_clang_tidy:
import_clang_tidy(llvm_source_dir)
if not os.path.exists(build_dir):
os.makedirs(build_dir)
@@ -536,7 +611,12 @@ if __name__ == "__main__":
llvm_source_dir, stage3_dir, build_libcxx, osx_cross_compile,
build_type, assertions, python_path, gcc_dir)
package_name = "clang"
if build_clang_tidy:
prune_final_dir_for_clang_tidy(os.path.join(final_stage_dir, "clang"))
package_name = "clang-tidy"
if is_darwin() or is_windows():
build_tar_package("tar", "clang.tar.bz2", final_stage_dir, "clang")
build_tar_package("tar", package_name + ".tar.bz2", final_stage_dir, "clang")
else:
build_tar_package("tar", "clang.tar.xz", final_stage_dir, "clang")
build_tar_package("tar", package_name + ".tar.xz", final_stage_dir, "clang")

View File

@@ -4,7 +4,7 @@
"build_libcxx": true,
"build_type": "Release",
"assertions": false,
"import_clang_tidy": true,
"build_clang_tidy": true,
"llvm_repo": "https://llvm.org/svn/llvm-project/llvm/trunk",
"clang_repo": "https://llvm.org/svn/llvm-project/cfe/trunk",
"extra_repo": "https://llvm.org/svn/llvm-project/clang-tools-extra/trunk",

View File

@@ -4,7 +4,7 @@
"build_libcxx": true,
"build_type": "Release",
"assertions": false,
"import_clang_tidy": true,
"build_clang_tidy": true,
"osx_cross_compile": true,
"llvm_repo": "https://llvm.org/svn/llvm-project/llvm/trunk",
"clang_repo": "https://llvm.org/svn/llvm-project/cfe/trunk",

View File

@@ -4,7 +4,7 @@
"build_libcxx": false,
"build_type": "Release",
"assertions": false,
"import_clang_tidy": true,
"build_clang_tidy": true,
"llvm_repo": "https://llvm.org/svn/llvm-project/llvm/trunk",
"clang_repo": "https://llvm.org/svn/llvm-project/cfe/trunk",
"extra_repo": "https://llvm.org/svn/llvm-project/clang-tools-extra/trunk",

View File

@@ -4,7 +4,7 @@
"build_libcxx": false,
"build_type": "Release",
"assertions": false,
"import_clang_tidy": true,
"build_clang_tidy": true,
"llvm_repo": "https://llvm.org/svn/llvm-project/llvm/trunk",
"clang_repo": "https://llvm.org/svn/llvm-project/cfe/trunk",
"extra_repo": "https://llvm.org/svn/llvm-project/clang-tools-extra/trunk",

View File

@@ -389,6 +389,7 @@ class RemoteAutomation(Automation):
while (top == self.procName):
# Get log updates on each interval, but if it is taking
# too long, only do it every 60 seconds
hasOutput = False
if (not slowLog) or (timer % 60 == 0):
startRead = datetime.datetime.now()
hasOutput = self.read_stdout()
@@ -405,6 +406,7 @@ class RemoteAutomation(Automation):
if (noOutputTimeout and noOutputTimer > noOutputTimeout):
status = 2
break
if not hasOutput:
top = self.dm.getTopActivity()
# Flush anything added to stdout during the sleep
self.read_stdout()

View File

@@ -38,3 +38,6 @@ LOCAL_INCLUDES += [
if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
CXXFLAGS += CONFIG['TK_CFLAGS']
with Files("**"):
BUG_COMPONENT = ("Toolkit", "Startup and Profile System")

View File

@@ -59,8 +59,8 @@ define(function (require, exports, module) {
return true;
}
let json = JSON.stringify(object).toLowerCase();
return json.indexOf(this.props.searchFilter.toLowerCase()) >= 0;
let json = object.name + JSON.stringify(object.value);
return json.toLowerCase().indexOf(this.props.searchFilter.toLowerCase()) >= 0;
},
getExpandedNodes: function (object, path = "", level = 0) {

View File

@@ -716,11 +716,20 @@ TimeoutManager::RescheduleTimeout(Timeout* aTimeout, const TimeStamp& now,
}
if (!aTimeout->mTimer) {
NS_ASSERTION(mWindow.IsFrozen() || mWindow.IsSuspended(),
"How'd our timer end up null if we're not frozen or "
"suspended?");
if (mWindow.IsFrozen()) {
// If we are frozen simply set timeout->mTimeRemaining to be the
// "time remaining" in the timeout (i.e., the interval itself). This
// will be used to create a new mWhen time when the window is thawed.
// The end effect is that time does not appear to pass for frozen windows.
aTimeout->mTimeRemaining = delay;
} else if (mWindow.IsSuspended()) {
// Since we are not frozen we must set a precise mWhen target wakeup
// time. Even if we are suspended we want to use this target time so
// that it appears time passes while suspended.
aTimeout->mWhen = currentNow + delay;
} else {
MOZ_ASSERT_UNREACHABLE("Window should be frozen or suspended.");
}
return true;
}

View File

@@ -9723,7 +9723,7 @@ nsContentUtils::AttemptLargeAllocationLoad(nsIHttpChannel* aChannel)
NS_LITERAL_CSTRING("DOM"),
doc,
nsContentUtils::eDOM_PROPERTIES,
"LargeAllocationRelatedBrowsingContexts");
"LargeAllocationNotOnlyToplevelInTabGroup");
}
return false;
}

View File

@@ -731,7 +731,7 @@ IsSelectionInsideRuby(nsISelection* aSelection)
if (NS_FAILED(rv)) {
return false;
}
for (auto i : MakeRange(rangeCount)) {
for (auto i : IntegerRange(rangeCount)) {
nsCOMPtr<nsIDOMRange> range;
aSelection->GetRangeAt(i, getter_AddRefs(range));
nsCOMPtr<nsIDOMNode> node;

View File

@@ -7918,14 +7918,6 @@ nsDocument::IsScriptEnabled()
nsRadioGroupStruct*
nsDocument::GetRadioGroupInternal(const nsAString& aName) const
{
#ifdef DEBUG
if (IsHTMLDocument()) {
nsAutoString lcName;
ToLowerCase(aName, lcName);
MOZ_ASSERT(aName == lcName);
}
#endif
nsRadioGroupStruct* radioGroup;
if (!mRadioGroups.Get(aName, &radioGroup)) {
return nullptr;
@@ -7938,9 +7930,6 @@ nsRadioGroupStruct*
nsDocument::GetRadioGroup(const nsAString& aName) const
{
nsAutoString tmKey(aName);
if (IsHTMLDocument()) {
ToLowerCase(tmKey); //should case-insensitive.
}
return GetRadioGroupInternal(tmKey);
}
@@ -7949,9 +7938,6 @@ nsRadioGroupStruct*
nsDocument::GetOrCreateRadioGroup(const nsAString& aName)
{
nsAutoString tmKey(aName);
if (IsHTMLDocument()) {
ToLowerCase(tmKey); //should case-insensitive.
}
if (nsRadioGroupStruct* radioGroup = GetRadioGroupInternal(tmKey)) {
return radioGroup;
@@ -9994,8 +9980,8 @@ nsDocument::FindImageMap(const nsAString& aUseMapValue)
nsIContent* map = mImageMaps->Item(i);
if (map->AttrValueIs(kNameSpaceID_None, nsGkAtoms::id, mapName,
eCaseMatters) ||
(map->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name) &&
mapName.Equals(name, nsCaseInsensitiveStringComparator()))) {
map->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, mapName,
eCaseMatters)) {
return map->AsElement();
}
}
@@ -10805,7 +10791,7 @@ nsDocument::RestorePreviousFullScreenState()
UnlockPointer();
// All documents listed in the array except the last one are going to
// completely exit from the fullscreen state.
for (auto i : MakeRange(exitDocs.Length() - 1)) {
for (auto i : IntegerRange(exitDocs.Length() - 1)) {
exitDocs[i]->CleanupFullscreenState();
}
// The last document will either rollback one fullscreen element, or

View File

@@ -43,6 +43,7 @@ tags = webrtc
[test_namedNoIndexed.html]
[test_named_getter_enumerability.html]
[test_Object.prototype_props.html]
[test_proxy_expandos.html]
[test_queryInterface.html]
[test_returnUnion.html]
skip-if = debug == false

View File

@@ -0,0 +1,75 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=965992
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 965992</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=965992">Mozilla Bug 965992</a>
<p id="display"></p>
<form id="theform"></form>
<pre id="test">
<script type="application/javascript">
// Ensure we are in JIT code and attach IC stubs.
const iterations = 50;
function testFoo(obj, expected, kind) {
for (var i = 0; i < iterations; i++) {
is(obj.foo, expected, "Looking up an expando should work - " + kind);
}
}
function getPropTests(obj) {
// Start with a plain data property.
obj.foo = "bar";
testFoo(obj, "bar", "plain");
// Now change it to a scripted getter.
var count = 0;
Object.defineProperty(obj, "foo", {get:function() {
is(this, obj, "Getter should have the proxy as |this|");
is(arguments.length, 0, "Shouldn't pass arguments to getters");
count++;
return 123;
}, configurable: true});
testFoo(obj, 123, "scripted getter");
is(count, iterations, "Should have called the getter enough times");
// Now try a native getter.
Object.defineProperty(obj, "foo", {get: Object.prototype.valueOf, configurable: true});
testFoo(obj, obj, "native getter");
}
function getElemTests(obj) {
// Define two expando properties, then test inline caches for obj[prop]
// correctly guard on prop being the same.
var count = 0;
obj.elem1 = 1;
Object.defineProperty(obj, "elem2", {get: function() { count++; return 2; }});
for (var i = 0; i < iterations; i++) {
var prop = ((i & 1) == 0) ? "elem1" : "elem2";
is(obj[prop], (i & 1) + 1, "Should return correct property value");
}
is(count, iterations / 2, "Should have called the getter enough times");
}
var directExpando = document.getElementsByTagName("*");
var indirectExpando = document.getElementById("theform");
getPropTests(directExpando);
getPropTests(indirectExpando);
getElemTests(indirectExpando);
getElemTests(directExpando);
</script>
</pre>
</body>
</html>

View File

@@ -20,7 +20,7 @@ ActorChild::SetWorkerHolder(CacheWorkerHolder* aWorkerHolder)
// them. In this case the workerHolder will be added multiple times. This is
// permitted, but the workerHolder should be the same each time.
if (mWorkerHolder) {
MOZ_ASSERT(mWorkerHolder == aWorkerHolder);
MOZ_DIAGNOSTIC_ASSERT(mWorkerHolder == aWorkerHolder);
return;
}
@@ -58,7 +58,7 @@ ActorChild::ActorChild()
ActorChild::~ActorChild()
{
MOZ_ASSERT(!mWorkerHolder);
MOZ_DIAGNOSTIC_ASSERT(!mWorkerHolder);
}
} // namespace cache

View File

@@ -66,7 +66,7 @@ AutoChildOpArgs::AutoChildOpArgs(TypeUtils* aTypeUtils,
, mOpArgs(aOpArgs)
, mSent(false)
{
MOZ_ASSERT(mTypeUtils);
MOZ_DIAGNOSTIC_ASSERT(mTypeUtils);
MOZ_RELEASE_ASSERT(aEntryCount != 0);
// We are using AutoIPCStream objects to cleanup target IPCStream
// structures embedded in our CacheOpArgs. These IPCStream structs
@@ -78,7 +78,7 @@ AutoChildOpArgs::AutoChildOpArgs(TypeUtils* aTypeUtils,
CachePutAllArgs& args = mOpArgs.get_CachePutAllArgs();
args.requestResponseList().SetCapacity(aEntryCount);
} else {
MOZ_ASSERT(aEntryCount == 1);
MOZ_DIAGNOSTIC_ASSERT(aEntryCount == 1);
}
}
@@ -145,7 +145,7 @@ void
AutoChildOpArgs::Add(InternalRequest* aRequest, BodyAction aBodyAction,
SchemeAction aSchemeAction, ErrorResult& aRv)
{
MOZ_ASSERT(!mSent);
MOZ_DIAGNOSTIC_ASSERT(!mSent);
switch(mOpArgs.type()) {
case CacheOpArgs::TCacheMatchArgs:
@@ -158,7 +158,7 @@ AutoChildOpArgs::Add(InternalRequest* aRequest, BodyAction aBodyAction,
case CacheOpArgs::TCacheMatchAllArgs:
{
CacheMatchAllArgs& args = mOpArgs.get_CacheMatchAllArgs();
MOZ_ASSERT(args.requestOrVoid().type() == CacheRequestOrVoid::Tvoid_t);
MOZ_DIAGNOSTIC_ASSERT(args.requestOrVoid().type() == CacheRequestOrVoid::Tvoid_t);
args.requestOrVoid() = CacheRequest();
mTypeUtils->ToCacheRequest(args.requestOrVoid().get_CacheRequest(),
aRequest, aBodyAction, aSchemeAction,
@@ -175,7 +175,7 @@ AutoChildOpArgs::Add(InternalRequest* aRequest, BodyAction aBodyAction,
case CacheOpArgs::TCacheKeysArgs:
{
CacheKeysArgs& args = mOpArgs.get_CacheKeysArgs();
MOZ_ASSERT(args.requestOrVoid().type() == CacheRequestOrVoid::Tvoid_t);
MOZ_DIAGNOSTIC_ASSERT(args.requestOrVoid().type() == CacheRequestOrVoid::Tvoid_t);
args.requestOrVoid() = CacheRequest();
mTypeUtils->ToCacheRequest(args.requestOrVoid().get_CacheRequest(),
aRequest, aBodyAction, aSchemeAction,
@@ -200,7 +200,7 @@ bool
MatchInPutList(InternalRequest* aRequest,
const nsTArray<CacheRequestResponse>& aPutList)
{
MOZ_ASSERT(aRequest);
MOZ_DIAGNOSTIC_ASSERT(aRequest);
// This method implements the SW spec QueryCache algorithm against an
// in memory array of Request/Response objects. This essentially the
@@ -253,7 +253,7 @@ MatchInPutList(InternalRequest* aRequest,
for (; token;
token = nsCRT::strtok(rawBuffer, NS_HTTP_HEADER_SEPS, &rawBuffer)) {
nsDependentCString header(token);
MOZ_ASSERT(!header.EqualsLiteral("*"),
MOZ_DIAGNOSTIC_ASSERT(!header.EqualsLiteral("*"),
"We should have already caught this in "
"TypeUtils::ToPCacheResponseWithoutBody()");
@@ -262,14 +262,14 @@ MatchInPutList(InternalRequest* aRequest,
requestHeaders->Get(header, value, headerRv);
if (NS_WARN_IF(headerRv.Failed())) {
headerRv.SuppressException();
MOZ_ASSERT(value.IsEmpty());
MOZ_DIAGNOSTIC_ASSERT(value.IsEmpty());
}
nsAutoCString cachedValue;
cachedRequestHeaders->Get(header, cachedValue, headerRv);
if (NS_WARN_IF(headerRv.Failed())) {
headerRv.SuppressException();
MOZ_ASSERT(cachedValue.IsEmpty());
MOZ_DIAGNOSTIC_ASSERT(cachedValue.IsEmpty());
}
if (value != cachedValue) {
@@ -294,7 +294,7 @@ AutoChildOpArgs::Add(InternalRequest* aRequest, BodyAction aBodyAction,
SchemeAction aSchemeAction, Response& aResponse,
ErrorResult& aRv)
{
MOZ_ASSERT(!mSent);
MOZ_DIAGNOSTIC_ASSERT(!mSent);
switch(mOpArgs.type()) {
case CacheOpArgs::TCachePutAllArgs:
@@ -350,7 +350,7 @@ AutoChildOpArgs::Add(InternalRequest* aRequest, BodyAction aBodyAction,
const CacheOpArgs&
AutoChildOpArgs::SendAsOpArgs()
{
MOZ_ASSERT(!mSent);
MOZ_DIAGNOSTIC_ASSERT(!mSent);
mSent = true;
for (UniquePtr<AutoIPCStream>& autoStream : mStreamCleanupList) {
autoStream->TakeValue();
@@ -368,7 +368,7 @@ AutoParentOpResult::AutoParentOpResult(mozilla::ipc::PBackgroundParent* aManager
, mStreamControl(nullptr)
, mSent(false)
{
MOZ_ASSERT(mManager);
MOZ_DIAGNOSTIC_ASSERT(mManager);
MOZ_RELEASE_ASSERT(aEntryCount != 0);
// We are using AutoIPCStream objects to cleanup target IPCStream
// structures embedded in our CacheOpArgs. These IPCStream structs
@@ -383,7 +383,7 @@ AutoParentOpResult::AutoParentOpResult(mozilla::ipc::PBackgroundParent* aManager
CacheKeysResult& result = mOpResult.get_CacheKeysResult();
result.requestList().SetCapacity(aEntryCount);
} else {
MOZ_ASSERT(aEntryCount == 1);
MOZ_DIAGNOSTIC_ASSERT(aEntryCount == 1);
}
}
@@ -416,8 +416,8 @@ AutoParentOpResult::~AutoParentOpResult()
void
AutoParentOpResult::Add(CacheId aOpenedCacheId, Manager* aManager)
{
MOZ_ASSERT(mOpResult.type() == CacheOpResult::TStorageOpenResult);
MOZ_ASSERT(mOpResult.get_StorageOpenResult().actorParent() == nullptr);
MOZ_DIAGNOSTIC_ASSERT(mOpResult.type() == CacheOpResult::TStorageOpenResult);
MOZ_DIAGNOSTIC_ASSERT(mOpResult.get_StorageOpenResult().actorParent() == nullptr);
mOpResult.get_StorageOpenResult().actorParent() =
mManager->SendPCacheConstructor(new CacheParent(aManager, aOpenedCacheId));
}
@@ -426,13 +426,13 @@ void
AutoParentOpResult::Add(const SavedResponse& aSavedResponse,
StreamList* aStreamList)
{
MOZ_ASSERT(!mSent);
MOZ_DIAGNOSTIC_ASSERT(!mSent);
switch (mOpResult.type()) {
case CacheOpResult::TCacheMatchResult:
{
CacheMatchResult& result = mOpResult.get_CacheMatchResult();
MOZ_ASSERT(result.responseOrVoid().type() == CacheResponseOrVoid::Tvoid_t);
MOZ_DIAGNOSTIC_ASSERT(result.responseOrVoid().type() == CacheResponseOrVoid::Tvoid_t);
result.responseOrVoid() = aSavedResponse.mValue;
SerializeResponseBody(aSavedResponse, aStreamList,
&result.responseOrVoid().get_CacheResponse());
@@ -455,7 +455,7 @@ AutoParentOpResult::Add(const SavedResponse& aSavedResponse,
case CacheOpResult::TStorageMatchResult:
{
StorageMatchResult& result = mOpResult.get_StorageMatchResult();
MOZ_ASSERT(result.responseOrVoid().type() == CacheResponseOrVoid::Tvoid_t);
MOZ_DIAGNOSTIC_ASSERT(result.responseOrVoid().type() == CacheResponseOrVoid::Tvoid_t);
result.responseOrVoid() = aSavedResponse.mValue;
SerializeResponseBody(aSavedResponse, aStreamList,
&result.responseOrVoid().get_CacheResponse());
@@ -470,7 +470,7 @@ void
AutoParentOpResult::Add(const SavedRequest& aSavedRequest,
StreamList* aStreamList)
{
MOZ_ASSERT(!mSent);
MOZ_DIAGNOSTIC_ASSERT(!mSent);
switch (mOpResult.type()) {
case CacheOpResult::TCacheKeysResult:
@@ -503,7 +503,7 @@ AutoParentOpResult::Add(const SavedRequest& aSavedRequest,
const CacheOpResult&
AutoParentOpResult::SendAsOpResult()
{
MOZ_ASSERT(!mSent);
MOZ_DIAGNOSTIC_ASSERT(!mSent);
mSent = true;
for (UniquePtr<AutoIPCStream>& autoStream : mStreamCleanupList) {
autoStream->TakeValue();
@@ -516,7 +516,7 @@ AutoParentOpResult::SerializeResponseBody(const SavedResponse& aSavedResponse,
StreamList* aStreamList,
CacheResponse* aResponseOut)
{
MOZ_ASSERT(aResponseOut);
MOZ_DIAGNOSTIC_ASSERT(aResponseOut);
if (!aSavedResponse.mHasBodyId) {
aResponseOut->body() = void_t();
@@ -532,12 +532,12 @@ void
AutoParentOpResult::SerializeReadStream(const nsID& aId, StreamList* aStreamList,
CacheReadStream* aReadStreamOut)
{
MOZ_ASSERT(aStreamList);
MOZ_ASSERT(aReadStreamOut);
MOZ_ASSERT(!mSent);
MOZ_DIAGNOSTIC_ASSERT(aStreamList);
MOZ_DIAGNOSTIC_ASSERT(aReadStreamOut);
MOZ_DIAGNOSTIC_ASSERT(!mSent);
nsCOMPtr<nsIInputStream> stream = aStreamList->Extract(aId);
MOZ_ASSERT(stream);
MOZ_DIAGNOSTIC_ASSERT(stream);
if (!mStreamControl) {
mStreamControl = static_cast<CacheStreamControlParent*>(
@@ -557,7 +557,7 @@ AutoParentOpResult::SerializeReadStream(const nsID& aId, StreamList* aStreamList
aId, stream);
ErrorResult rv;
readStream->Serialize(aReadStreamOut, mStreamCleanupList, rv);
MOZ_ASSERT(!rv.Failed());
MOZ_DIAGNOSTIC_ASSERT(!rv.Failed());
}
} // namespace cache

28
dom/cache/Cache.cpp vendored
View File

@@ -122,8 +122,8 @@ public:
, mPromise(aPromise)
{
MOZ_ASSERT_IF(!NS_IsMainThread(), mWorkerHolder);
MOZ_ASSERT(mCache);
MOZ_ASSERT(mPromise);
MOZ_DIAGNOSTIC_ASSERT(mCache);
MOZ_DIAGNOSTIC_ASSERT(mPromise);
}
virtual void
@@ -198,7 +198,7 @@ public:
responseList.AppendElement(Move(response));
}
MOZ_ASSERT(mRequestList.Length() == responseList.Length());
MOZ_DIAGNOSTIC_ASSERT(mRequestList.Length() == responseList.Length());
// Now store the unwrapped Response list in the Cache.
ErrorResult result;
@@ -257,8 +257,8 @@ Cache::Cache(nsIGlobalObject* aGlobal, CacheChild* aActor)
: mGlobal(aGlobal)
, mActor(aActor)
{
MOZ_ASSERT(mGlobal);
MOZ_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mGlobal);
MOZ_DIAGNOSTIC_ASSERT(mActor);
mActor->SetListener(this);
}
@@ -339,7 +339,7 @@ Cache::Add(JSContext* aContext, const RequestOrUSVString& aRequest,
}
GlobalObject global(aContext, mGlobal->GetGlobalJSObject());
MOZ_ASSERT(!global.Failed());
MOZ_DIAGNOSTIC_ASSERT(!global.Failed());
nsTArray<RefPtr<Request>> requestList(1);
RefPtr<Request> request = Request::Constructor(global, aRequest,
@@ -371,7 +371,7 @@ Cache::AddAll(JSContext* aContext,
CacheChild::AutoLock actorLock(mActor);
GlobalObject global(aContext, mGlobal->GetGlobalJSObject());
MOZ_ASSERT(!global.Failed());
MOZ_DIAGNOSTIC_ASSERT(!global.Failed());
nsTArray<RefPtr<Request>> requestList(aRequestList.Length());
for (uint32_t i = 0; i < aRequestList.Length(); ++i) {
@@ -541,8 +541,8 @@ Cache::WrapObject(JSContext* aContext, JS::Handle<JSObject*> aGivenProto)
void
Cache::DestroyInternal(CacheChild* aActor)
{
MOZ_ASSERT(mActor);
MOZ_ASSERT(mActor == aActor);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mActor == aActor);
mActor->ClearListener();
mActor = nullptr;
}
@@ -565,7 +565,7 @@ PBackgroundChild*
Cache::GetIPCManager()
{
NS_ASSERT_OWNINGTHREAD(Cache);
MOZ_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mActor);
return mActor->Manager();
}
@@ -576,14 +576,14 @@ Cache::~Cache()
mActor->StartDestroyFromListener();
// DestroyInternal() is called synchronously by StartDestroyFromListener().
// So we should have already cleared the mActor.
MOZ_ASSERT(!mActor);
MOZ_DIAGNOSTIC_ASSERT(!mActor);
}
}
already_AddRefed<Promise>
Cache::ExecuteOp(AutoChildOpArgs& aOpArgs, ErrorResult& aRv)
{
MOZ_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mActor);
RefPtr<Promise> promise = Promise::Create(mGlobal, aRv);
if (NS_WARN_IF(!promise)) {
@@ -598,7 +598,7 @@ already_AddRefed<Promise>
Cache::AddAll(const GlobalObject& aGlobal,
nsTArray<RefPtr<Request>>&& aRequestList, ErrorResult& aRv)
{
MOZ_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mActor);
// If there is no work to do, then resolve immediately
if (aRequestList.IsEmpty()) {
@@ -653,7 +653,7 @@ Cache::PutAll(const nsTArray<RefPtr<Request>>& aRequestList,
const nsTArray<RefPtr<Response>>& aResponseList,
ErrorResult& aRv)
{
MOZ_ASSERT(aRequestList.Length() == aResponseList.Length());
MOZ_DIAGNOSTIC_ASSERT(aRequestList.Length() == aResponseList.Length());
if (NS_WARN_IF(!mActor)) {
aRv.Throw(NS_ERROR_UNEXPECTED);

View File

@@ -42,25 +42,25 @@ CacheChild::~CacheChild()
{
MOZ_COUNT_DTOR(cache::CacheChild);
NS_ASSERT_OWNINGTHREAD(CacheChild);
MOZ_ASSERT(!mListener);
MOZ_ASSERT(!mNumChildActors);
MOZ_ASSERT(!mLocked);
MOZ_DIAGNOSTIC_ASSERT(!mListener);
MOZ_DIAGNOSTIC_ASSERT(!mNumChildActors);
MOZ_DIAGNOSTIC_ASSERT(!mLocked);
}
void
CacheChild::SetListener(Cache* aListener)
{
NS_ASSERT_OWNINGTHREAD(CacheChild);
MOZ_ASSERT(!mListener);
MOZ_DIAGNOSTIC_ASSERT(!mListener);
mListener = aListener;
MOZ_ASSERT(mListener);
MOZ_DIAGNOSTIC_ASSERT(mListener);
}
void
CacheChild::ClearListener()
{
NS_ASSERT_OWNINGTHREAD(CacheChild);
MOZ_ASSERT(mListener);
MOZ_DIAGNOSTIC_ASSERT(mListener);
mListener = nullptr;
}
@@ -81,7 +81,7 @@ CacheChild::StartDestroyFromListener()
// The listener should be held alive by any async operations, so if it
// is going away then there must not be any child actors. This in turn
// ensures that StartDestroy() will not trigger the delayed path.
MOZ_ASSERT(!mNumChildActors);
MOZ_DIAGNOSTIC_ASSERT(!mNumChildActors);
StartDestroy();
}
@@ -113,7 +113,7 @@ CacheChild::StartDestroy()
listener->DestroyInternal(this);
// Cache listener should call ClearListener() in DestroyInternal()
MOZ_ASSERT(!mListener);
MOZ_DIAGNOSTIC_ASSERT(!mListener);
// Start actor destruction from parent process
Unused << SendTeardown();
@@ -127,7 +127,7 @@ CacheChild::ActorDestroy(ActorDestroyReason aReason)
if (listener) {
listener->DestroyInternal(this);
// Cache listener should call ClearListener() in DestroyInternal()
MOZ_ASSERT(!mListener);
MOZ_DIAGNOSTIC_ASSERT(!mListener);
}
RemoveWorkerHolder();
@@ -167,7 +167,7 @@ void
CacheChild::Lock()
{
NS_ASSERT_OWNINGTHREAD(CacheChild);
MOZ_ASSERT(!mLocked);
MOZ_DIAGNOSTIC_ASSERT(!mLocked);
mLocked = true;
}
@@ -175,7 +175,7 @@ void
CacheChild::Unlock()
{
NS_ASSERT_OWNINGTHREAD(CacheChild);
MOZ_ASSERT(mLocked);
MOZ_DIAGNOSTIC_ASSERT(mLocked);
mLocked = false;
MaybeFlushDelayedDestroy();
}

View File

@@ -35,7 +35,7 @@ public:
explicit AutoLock(CacheChild* aActor)
: mActor(aActor)
{
MOZ_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mActor);
mActor->Lock();
}

View File

@@ -70,9 +70,9 @@ CacheOpChild::CacheOpChild(CacheWorkerHolder* aWorkerHolder,
, mParent(aParent)
, mPromise(aPromise)
{
MOZ_ASSERT(mGlobal);
MOZ_ASSERT(mParent);
MOZ_ASSERT(mPromise);
MOZ_DIAGNOSTIC_ASSERT(mGlobal);
MOZ_DIAGNOSTIC_ASSERT(mParent);
MOZ_DIAGNOSTIC_ASSERT(mPromise);
MOZ_ASSERT_IF(!NS_IsMainThread(), aWorkerHolder);
SetWorkerHolder(aWorkerHolder);
@@ -81,7 +81,7 @@ CacheOpChild::CacheOpChild(CacheWorkerHolder* aWorkerHolder,
CacheOpChild::~CacheOpChild()
{
NS_ASSERT_OWNINGTHREAD(CacheOpChild);
MOZ_ASSERT(!mPromise);
MOZ_DIAGNOSTIC_ASSERT(!mPromise);
}
void
@@ -106,7 +106,7 @@ CacheOpChild::Recv__delete__(const ErrorResult& aRv,
NS_ASSERT_OWNINGTHREAD(CacheOpChild);
if (NS_WARN_IF(aRv.Failed())) {
MOZ_ASSERT(aResult.type() == CacheOpResult::Tvoid_t);
MOZ_DIAGNOSTIC_ASSERT(aResult.type() == CacheOpResult::Tvoid_t);
// TODO: Remove this const_cast (bug 1152078).
// It is safe for now since this ErrorResult is handed off to us by IPDL
// and is thrown into the trash afterwards.

View File

@@ -29,7 +29,7 @@ CacheOpParent::CacheOpParent(PBackgroundParent* aIpcManager, CacheId aCacheId,
, mNamespace(INVALID_NAMESPACE)
, mOpArgs(aOpArgs)
{
MOZ_ASSERT(mIpcManager);
MOZ_DIAGNOSTIC_ASSERT(mIpcManager);
}
CacheOpParent::CacheOpParent(PBackgroundParent* aIpcManager,
@@ -39,7 +39,7 @@ CacheOpParent::CacheOpParent(PBackgroundParent* aIpcManager,
, mNamespace(aNamespace)
, mOpArgs(aOpArgs)
{
MOZ_ASSERT(mIpcManager);
MOZ_DIAGNOSTIC_ASSERT(mIpcManager);
}
CacheOpParent::~CacheOpParent()
@@ -51,8 +51,8 @@ void
CacheOpParent::Execute(ManagerId* aManagerId)
{
NS_ASSERT_OWNINGTHREAD(CacheOpParent);
MOZ_ASSERT(!mManager);
MOZ_ASSERT(!mVerifier);
MOZ_DIAGNOSTIC_ASSERT(!mManager);
MOZ_DIAGNOSTIC_ASSERT(!mVerifier);
RefPtr<cache::Manager> manager;
nsresult rv = cache::Manager::GetOrCreate(aManagerId, getter_AddRefs(manager));
@@ -70,14 +70,14 @@ void
CacheOpParent::Execute(cache::Manager* aManager)
{
NS_ASSERT_OWNINGTHREAD(CacheOpParent);
MOZ_ASSERT(!mManager);
MOZ_ASSERT(!mVerifier);
MOZ_DIAGNOSTIC_ASSERT(!mManager);
MOZ_DIAGNOSTIC_ASSERT(!mVerifier);
mManager = aManager;
// Handle put op
if (mOpArgs.type() == CacheOpArgs::TCachePutAllArgs) {
MOZ_ASSERT(mCacheId != INVALID_CACHE_ID);
MOZ_DIAGNOSTIC_ASSERT(mCacheId != INVALID_CACHE_ID);
const CachePutAllArgs& args = mOpArgs.get_CachePutAllArgs();
const nsTArray<CacheRequestResponse>& list = args.requestResponseList();
@@ -99,13 +99,13 @@ CacheOpParent::Execute(cache::Manager* aManager)
// Handle all other cache ops
if (mCacheId != INVALID_CACHE_ID) {
MOZ_ASSERT(mNamespace == INVALID_NAMESPACE);
MOZ_DIAGNOSTIC_ASSERT(mNamespace == INVALID_NAMESPACE);
mManager->ExecuteCacheOp(this, mCacheId, mOpArgs);
return;
}
// Handle all storage ops
MOZ_ASSERT(mNamespace != INVALID_NAMESPACE);
MOZ_DIAGNOSTIC_ASSERT(mNamespace != INVALID_NAMESPACE);
mManager->ExecuteStorageOp(this, mNamespace, mOpArgs);
}
@@ -113,8 +113,8 @@ void
CacheOpParent::WaitForVerification(PrincipalVerifier* aVerifier)
{
NS_ASSERT_OWNINGTHREAD(CacheOpParent);
MOZ_ASSERT(!mManager);
MOZ_ASSERT(!mVerifier);
MOZ_DIAGNOSTIC_ASSERT(!mManager);
MOZ_DIAGNOSTIC_ASSERT(!mVerifier);
mVerifier = aVerifier;
mVerifier->AddListener(this);
@@ -164,8 +164,8 @@ CacheOpParent::OnOpComplete(ErrorResult&& aRv, const CacheOpResult& aResult,
StreamList* aStreamList)
{
NS_ASSERT_OWNINGTHREAD(CacheOpParent);
MOZ_ASSERT(mIpcManager);
MOZ_ASSERT(mManager);
MOZ_DIAGNOSTIC_ASSERT(mIpcManager);
MOZ_DIAGNOSTIC_ASSERT(mManager);
// Never send an op-specific result if we have an error. Instead, send
// void_t() to ensure that we don't leak actors on the child side.

View File

@@ -25,20 +25,20 @@ CacheParent::CacheParent(cache::Manager* aManager, CacheId aCacheId)
, mCacheId(aCacheId)
{
MOZ_COUNT_CTOR(cache::CacheParent);
MOZ_ASSERT(mManager);
MOZ_DIAGNOSTIC_ASSERT(mManager);
mManager->AddRefCacheId(mCacheId);
}
CacheParent::~CacheParent()
{
MOZ_COUNT_DTOR(cache::CacheParent);
MOZ_ASSERT(!mManager);
MOZ_DIAGNOSTIC_ASSERT(!mManager);
}
void
CacheParent::ActorDestroy(ActorDestroyReason aReason)
{
MOZ_ASSERT(mManager);
MOZ_DIAGNOSTIC_ASSERT(mManager);
mManager->ReleaseCacheId(mCacheId);
mManager = nullptr;
}

View File

@@ -141,8 +141,8 @@ CacheStorage::CreateOnMainThread(Namespace aNamespace, nsIGlobalObject* aGlobal,
nsIPrincipal* aPrincipal, bool aStorageDisabled,
bool aForceTrustedOrigin, ErrorResult& aRv)
{
MOZ_ASSERT(aGlobal);
MOZ_ASSERT(aPrincipal);
MOZ_DIAGNOSTIC_ASSERT(aGlobal);
MOZ_DIAGNOSTIC_ASSERT(aPrincipal);
MOZ_ASSERT(NS_IsMainThread());
if (aStorageDisabled) {
@@ -178,8 +178,8 @@ already_AddRefed<CacheStorage>
CacheStorage::CreateOnWorker(Namespace aNamespace, nsIGlobalObject* aGlobal,
WorkerPrivate* aWorkerPrivate, ErrorResult& aRv)
{
MOZ_ASSERT(aGlobal);
MOZ_ASSERT(aWorkerPrivate);
MOZ_DIAGNOSTIC_ASSERT(aGlobal);
MOZ_DIAGNOSTIC_ASSERT(aWorkerPrivate);
aWorkerPrivate->AssertIsOnWorkerThread();
if (!aWorkerPrivate->IsStorageAllowed()) {
@@ -238,7 +238,7 @@ bool
CacheStorage::DefineCaches(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(js::GetObjectClass(aGlobal)->flags & JSCLASS_DOM_GLOBAL,
MOZ_DIAGNOSTIC_ASSERT(js::GetObjectClass(aGlobal)->flags & JSCLASS_DOM_GLOBAL,
"Passed object is not a global object!");
js::AssertSameCompartment(aCx, aGlobal);
@@ -248,7 +248,7 @@ CacheStorage::DefineCaches(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
}
nsIPrincipal* principal = nsContentUtils::ObjectPrincipal(aGlobal);
MOZ_ASSERT(principal);
MOZ_DIAGNOSTIC_ASSERT(principal);
ErrorResult rv;
RefPtr<CacheStorage> storage =
@@ -278,7 +278,7 @@ CacheStorage::CacheStorage(Namespace aNamespace, nsIGlobalObject* aGlobal,
, mActor(nullptr)
, mStatus(NS_OK)
{
MOZ_ASSERT(mGlobal);
MOZ_DIAGNOSTIC_ASSERT(mGlobal);
// If the PBackground actor is already initialized then we can
// immediately use it
@@ -302,7 +302,7 @@ CacheStorage::CacheStorage(nsresult aFailureResult)
, mActor(nullptr)
, mStatus(aFailureResult)
{
MOZ_ASSERT(NS_FAILED(mStatus));
MOZ_DIAGNOSTIC_ASSERT(NS_FAILED(mStatus));
}
already_AddRefed<Promise>
@@ -501,7 +501,7 @@ void
CacheStorage::ActorCreated(PBackgroundChild* aActor)
{
NS_ASSERT_OWNINGTHREAD(CacheStorage);
MOZ_ASSERT(aActor);
MOZ_DIAGNOSTIC_ASSERT(aActor);
if (NS_WARN_IF(mWorkerHolder && mWorkerHolder->Notified())) {
ActorFailed();
@@ -522,18 +522,18 @@ CacheStorage::ActorCreated(PBackgroundChild* aActor)
mWorkerHolder = nullptr;
MOZ_ASSERT(constructedActor == newActor);
MOZ_DIAGNOSTIC_ASSERT(constructedActor == newActor);
mActor = newActor;
MaybeRunPendingRequests();
MOZ_ASSERT(mPendingRequests.IsEmpty());
MOZ_DIAGNOSTIC_ASSERT(mPendingRequests.IsEmpty());
}
void
CacheStorage::ActorFailed()
{
NS_ASSERT_OWNINGTHREAD(CacheStorage);
MOZ_ASSERT(!NS_FAILED(mStatus));
MOZ_DIAGNOSTIC_ASSERT(!NS_FAILED(mStatus));
mStatus = NS_ERROR_UNEXPECTED;
mWorkerHolder = nullptr;
@@ -549,8 +549,8 @@ void
CacheStorage::DestroyInternal(CacheStorageChild* aActor)
{
NS_ASSERT_OWNINGTHREAD(CacheStorage);
MOZ_ASSERT(mActor);
MOZ_ASSERT(mActor == aActor);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mActor == aActor);
mActor->ClearListener();
mActor = nullptr;
@@ -589,7 +589,7 @@ CacheStorage::~CacheStorage()
mActor->StartDestroyFromListener();
// DestroyInternal() is called synchronously by StartDestroyFromListener().
// So we should have already cleared the mActor.
MOZ_ASSERT(!mActor);
MOZ_DIAGNOSTIC_ASSERT(!mActor);
}
}

View File

@@ -29,7 +29,7 @@ CacheStorageChild::CacheStorageChild(CacheStorage* aListener,
, mDelayedDestroy(false)
{
MOZ_COUNT_CTOR(cache::CacheStorageChild);
MOZ_ASSERT(mListener);
MOZ_DIAGNOSTIC_ASSERT(mListener);
SetWorkerHolder(aWorkerHolder);
}
@@ -38,14 +38,14 @@ CacheStorageChild::~CacheStorageChild()
{
MOZ_COUNT_DTOR(cache::CacheStorageChild);
NS_ASSERT_OWNINGTHREAD(CacheStorageChild);
MOZ_ASSERT(!mListener);
MOZ_DIAGNOSTIC_ASSERT(!mListener);
}
void
CacheStorageChild::ClearListener()
{
NS_ASSERT_OWNINGTHREAD(CacheStorageChild);
MOZ_ASSERT(mListener);
MOZ_DIAGNOSTIC_ASSERT(mListener);
mListener = nullptr;
}
@@ -66,7 +66,7 @@ CacheStorageChild::StartDestroyFromListener()
// The listener should be held alive by any async operations, so if it
// is going away then there must not be any child actors. This in turn
// ensures that StartDestroy() will not trigger the delayed path.
MOZ_ASSERT(!mNumChildActors);
MOZ_DIAGNOSTIC_ASSERT(!mNumChildActors);
StartDestroy();
}
@@ -98,7 +98,7 @@ CacheStorageChild::StartDestroy()
listener->DestroyInternal(this);
// CacheStorage listener should call ClearListener() in DestroyInternal()
MOZ_ASSERT(!mListener);
MOZ_DIAGNOSTIC_ASSERT(!mListener);
// Start actor destruction from parent process
Unused << SendTeardown();
@@ -112,7 +112,7 @@ CacheStorageChild::ActorDestroy(ActorDestroyReason aReason)
if (listener) {
listener->DestroyInternal(this);
// CacheStorage listener should call ClearListener() in DestroyInternal()
MOZ_ASSERT(!mListener);
MOZ_DIAGNOSTIC_ASSERT(!mListener);
}
RemoveWorkerHolder();
@@ -136,7 +136,7 @@ CacheStorageChild::DeallocPCacheOpChild(PCacheOpChild* aActor)
void
CacheStorageChild::NoteDeletedActor()
{
MOZ_ASSERT(mNumChildActors);
MOZ_DIAGNOSTIC_ASSERT(mNumChildActors);
mNumChildActors -= 1;
if (!mNumChildActors && mDelayedDestroy) {
StartDestroy();

View File

@@ -43,18 +43,18 @@ CacheStorageParent::CacheStorageParent(PBackgroundParent* aManagingActor,
, mVerifiedStatus(NS_OK)
{
MOZ_COUNT_CTOR(cache::CacheStorageParent);
MOZ_ASSERT(aManagingActor);
MOZ_DIAGNOSTIC_ASSERT(aManagingActor);
// Start the async principal verification process immediately.
mVerifier = PrincipalVerifier::CreateAndDispatch(this, aManagingActor,
aPrincipalInfo);
MOZ_ASSERT(mVerifier);
MOZ_DIAGNOSTIC_ASSERT(mVerifier);
}
CacheStorageParent::~CacheStorageParent()
{
MOZ_COUNT_DTOR(cache::CacheStorageParent);
MOZ_ASSERT(!mVerifier);
MOZ_DIAGNOSTIC_ASSERT(!mVerifier);
}
void
@@ -95,7 +95,7 @@ CacheStorageParent::RecvPCacheOpConstructor(PCacheOpParent* aActor,
auto actor = static_cast<CacheOpParent*>(aActor);
if (mVerifier) {
MOZ_ASSERT(!mManagerId);
MOZ_DIAGNOSTIC_ASSERT(!mManagerId);
actor->WaitForVerification(mVerifier);
return IPC_OK();
}
@@ -107,7 +107,7 @@ CacheStorageParent::RecvPCacheOpConstructor(PCacheOpParent* aActor,
return IPC_OK();
}
MOZ_ASSERT(mManagerId);
MOZ_DIAGNOSTIC_ASSERT(mManagerId);
actor->Execute(mManagerId);
return IPC_OK();
}
@@ -125,9 +125,9 @@ CacheStorageParent::RecvTeardown()
void
CacheStorageParent::OnPrincipalVerified(nsresult aRv, ManagerId* aManagerId)
{
MOZ_ASSERT(mVerifier);
MOZ_ASSERT(!mManagerId);
MOZ_ASSERT(NS_SUCCEEDED(mVerifiedStatus));
MOZ_DIAGNOSTIC_ASSERT(mVerifier);
MOZ_DIAGNOSTIC_ASSERT(!mManagerId);
MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(mVerifiedStatus));
if (NS_WARN_IF(NS_FAILED(aRv))) {
mVerifiedStatus = aRv;

View File

@@ -6,7 +6,6 @@
#include "mozilla/dom/cache/CacheStreamControlChild.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/Unused.h"
#include "mozilla/dom/cache/ActorUtils.h"
#include "mozilla/dom/cache/CacheTypes.h"
@@ -89,6 +88,7 @@ void
CacheStreamControlChild::SerializeControl(CacheReadStream* aReadStreamOut)
{
NS_ASSERT_OWNINGTHREAD(CacheStreamControlChild);
MOZ_DIAGNOSTIC_ASSERT(aReadStreamOut);
aReadStreamOut->controlParent() = nullptr;
aReadStreamOut->controlChild() = this;
}
@@ -99,8 +99,8 @@ CacheStreamControlChild::SerializeStream(CacheReadStream* aReadStreamOut,
nsTArray<UniquePtr<AutoIPCStream>>& aStreamCleanupList)
{
NS_ASSERT_OWNINGTHREAD(CacheStreamControlChild);
MOZ_ASSERT(aReadStreamOut);
MOZ_ASSERT(aStream);
MOZ_DIAGNOSTIC_ASSERT(aReadStreamOut);
MOZ_DIAGNOSTIC_ASSERT(aStream);
UniquePtr<AutoIPCStream> autoStream(new AutoIPCStream(aReadStreamOut->stream()));
autoStream->Serialize(aStream, Manager());
aStreamCleanupList.AppendElement(Move(autoStream));

View File

@@ -6,7 +6,6 @@
#include "mozilla/dom/cache/CacheStreamControlParent.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/Unused.h"
#include "mozilla/dom/cache/CacheTypes.h"
#include "mozilla/dom/cache/ReadStream.h"
@@ -40,7 +39,7 @@ CacheStreamControlParent::CacheStreamControlParent()
CacheStreamControlParent::~CacheStreamControlParent()
{
NS_ASSERT_OWNINGTHREAD(CacheStreamControlParent);
MOZ_ASSERT(!mStreamList);
MOZ_DIAGNOSTIC_ASSERT(!mStreamList);
MOZ_COUNT_DTOR(cache::CacheStreamControlParent);
}
@@ -48,6 +47,7 @@ void
CacheStreamControlParent::SerializeControl(CacheReadStream* aReadStreamOut)
{
NS_ASSERT_OWNINGTHREAD(CacheStreamControlParent);
MOZ_DIAGNOSTIC_ASSERT(aReadStreamOut);
aReadStreamOut->controlChild() = nullptr;
aReadStreamOut->controlParent() = this;
}
@@ -58,7 +58,8 @@ CacheStreamControlParent::SerializeStream(CacheReadStream* aReadStreamOut,
nsTArray<UniquePtr<AutoIPCStream>>& aStreamCleanupList)
{
NS_ASSERT_OWNINGTHREAD(CacheStreamControlParent);
MOZ_ASSERT(aStream);
MOZ_DIAGNOSTIC_ASSERT(aReadStreamOut);
MOZ_DIAGNOSTIC_ASSERT(aStream);
UniquePtr<AutoIPCStream> autoStream(new AutoIPCStream(aReadStreamOut->stream()));
autoStream->Serialize(aStream, Manager());
aStreamCleanupList.AppendElement(Move(autoStream));
@@ -93,7 +94,7 @@ mozilla::ipc::IPCResult
CacheStreamControlParent::RecvNoteClosed(const nsID& aId)
{
NS_ASSERT_OWNINGTHREAD(CacheStreamControlParent);
MOZ_ASSERT(mStreamList);
MOZ_DIAGNOSTIC_ASSERT(mStreamList);
mStreamList->NoteClosed(aId);
return IPC_OK();
}
@@ -102,7 +103,7 @@ void
CacheStreamControlParent::SetStreamList(StreamList* aStreamList)
{
NS_ASSERT_OWNINGTHREAD(CacheStreamControlParent);
MOZ_ASSERT(!mStreamList);
MOZ_DIAGNOSTIC_ASSERT(!mStreamList);
mStreamList = aStreamList;
}

View File

@@ -21,7 +21,7 @@ using mozilla::dom::workers::WorkerPrivate;
already_AddRefed<CacheWorkerHolder>
CacheWorkerHolder::Create(WorkerPrivate* aWorkerPrivate)
{
MOZ_ASSERT(aWorkerPrivate);
MOZ_DIAGNOSTIC_ASSERT(aWorkerPrivate);
RefPtr<CacheWorkerHolder> workerHolder = new CacheWorkerHolder();
if (NS_WARN_IF(!workerHolder->HoldWorker(aWorkerPrivate, Terminating))) {
@@ -35,7 +35,7 @@ void
CacheWorkerHolder::AddActor(ActorChild* aActor)
{
NS_ASSERT_OWNINGTHREAD(CacheWorkerHolder);
MOZ_ASSERT(aActor);
MOZ_DIAGNOSTIC_ASSERT(aActor);
MOZ_ASSERT(!mActorList.Contains(aActor));
mActorList.AppendElement(aActor);
@@ -53,11 +53,14 @@ void
CacheWorkerHolder::RemoveActor(ActorChild* aActor)
{
NS_ASSERT_OWNINGTHREAD(CacheWorkerHolder);
MOZ_ASSERT(aActor);
MOZ_DIAGNOSTIC_ASSERT(aActor);
DebugOnly<bool> removed = mActorList.RemoveElement(aActor);
#if defined(RELEASE_OR_BETA)
mActorList.RemoveElement(aActor);
#else
MOZ_DIAGNOSTIC_ASSERT(mActorList.RemoveElement(aActor));
#endif
MOZ_ASSERT(removed);
MOZ_ASSERT(!mActorList.Contains(aActor));
}
@@ -83,6 +86,7 @@ CacheWorkerHolder::Notify(Status aStatus)
// Start the asynchronous destruction of our actors. These will call back
// into RemoveActor() once the actor is destroyed.
for (uint32_t i = 0; i < mActorList.Length(); ++i) {
MOZ_DIAGNOSTIC_ASSERT(mActorList[i]);
mActorList[i]->StartDestroy();
}
@@ -97,7 +101,7 @@ CacheWorkerHolder::CacheWorkerHolder()
CacheWorkerHolder::~CacheWorkerHolder()
{
NS_ASSERT_OWNINGTHREAD(CacheWorkerHolder);
MOZ_ASSERT(mActorList.IsEmpty());
MOZ_DIAGNOSTIC_ASSERT(mActorList.IsEmpty());
}
} // namespace cache

View File

@@ -22,7 +22,7 @@ Connection::Connection(mozIStorageConnection* aBase)
: mBase(aBase)
, mClosed(false)
{
MOZ_ASSERT(mBase);
MOZ_DIAGNOSTIC_ASSERT(mBase);
}
Connection::~Connection()

132
dom/cache/Context.cpp vendored
View File

@@ -7,7 +7,6 @@
#include "mozilla/dom/cache/Context.h"
#include "mozilla/AutoRestore.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/dom/cache/Action.h"
#include "mozilla/dom/cache/FileUtils.h"
#include "mozilla/dom/cache/Manager.h"
@@ -35,7 +34,7 @@ public:
RunOnTarget(Resolver* aResolver, const QuotaInfo&, Data*) override
{
// Resolve success immediately. This Action does no actual work.
MOZ_ASSERT(aResolver);
MOZ_DIAGNOSTIC_ASSERT(aResolver);
aResolver->Resolve(NS_OK);
}
};
@@ -46,7 +45,6 @@ namespace mozilla {
namespace dom {
namespace cache {
using mozilla::DebugOnly;
using mozilla::dom::quota::AssertIsOnIOThread;
using mozilla::dom::quota::OpenDirectoryListener;
using mozilla::dom::quota::QuotaManager;
@@ -59,7 +57,7 @@ public:
explicit Data(nsIThread* aTarget)
: mTarget(aTarget)
{
MOZ_ASSERT(mTarget);
MOZ_DIAGNOSTIC_ASSERT(mTarget);
}
virtual mozIStorageConnection*
@@ -73,9 +71,9 @@ public:
SetConnection(mozIStorageConnection* aConn) override
{
MOZ_ASSERT(mTarget == NS_GetCurrentThread());
MOZ_ASSERT(!mConnection);
MOZ_DIAGNOSTIC_ASSERT(!mConnection);
mConnection = aConn;
MOZ_ASSERT(mConnection);
MOZ_DIAGNOSTIC_ASSERT(mConnection);
}
private:
@@ -119,18 +117,18 @@ public:
, mState(STATE_INIT)
, mCanceled(false)
{
MOZ_ASSERT(mContext);
MOZ_ASSERT(mManager);
MOZ_ASSERT(mData);
MOZ_ASSERT(mTarget);
MOZ_ASSERT(mInitiatingThread);
MOZ_ASSERT(mInitAction);
MOZ_DIAGNOSTIC_ASSERT(mContext);
MOZ_DIAGNOSTIC_ASSERT(mManager);
MOZ_DIAGNOSTIC_ASSERT(mData);
MOZ_DIAGNOSTIC_ASSERT(mTarget);
MOZ_DIAGNOSTIC_ASSERT(mInitiatingThread);
MOZ_DIAGNOSTIC_ASSERT(mInitAction);
}
nsresult Dispatch()
{
NS_ASSERT_OWNINGTHREAD(QuotaInitRunnable);
MOZ_ASSERT(mState == STATE_INIT);
MOZ_DIAGNOSTIC_ASSERT(mState == STATE_INIT);
mState = STATE_GET_INFO;
nsresult rv = NS_DispatchToMainThread(this, nsIThread::DISPATCH_NORMAL);
@@ -144,7 +142,7 @@ public:
void Cancel()
{
NS_ASSERT_OWNINGTHREAD(QuotaInitRunnable);
MOZ_ASSERT(!mCanceled);
MOZ_DIAGNOSTIC_ASSERT(!mCanceled);
mCanceled = true;
mInitAction->CancelOnInitiatingThread();
}
@@ -170,7 +168,7 @@ private:
virtual void
Resolve(nsresult aRv) override
{
MOZ_ASSERT(!mResolved);
MOZ_DIAGNOSTIC_ASSERT(!mResolved);
mResolved = true;
mResult = aRv;
};
@@ -189,9 +187,9 @@ private:
~QuotaInitRunnable()
{
MOZ_ASSERT(mState == STATE_COMPLETE);
MOZ_ASSERT(!mContext);
MOZ_ASSERT(!mInitAction);
MOZ_DIAGNOSTIC_ASSERT(mState == STATE_COMPLETE);
MOZ_DIAGNOSTIC_ASSERT(!mContext);
MOZ_DIAGNOSTIC_ASSERT(!mInitAction);
}
enum State
@@ -210,9 +208,9 @@ private:
void Complete(nsresult aResult)
{
MOZ_ASSERT(mState == STATE_RUNNING || NS_FAILED(aResult));
MOZ_DIAGNOSTIC_ASSERT(mState == STATE_RUNNING || NS_FAILED(aResult));
MOZ_ASSERT(NS_SUCCEEDED(mResult));
MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(mResult));
mResult = aResult;
mState = STATE_COMPLETING;
@@ -223,7 +221,7 @@ private:
void Clear()
{
NS_ASSERT_OWNINGTHREAD(QuotaInitRunnable);
MOZ_ASSERT(mContext);
MOZ_DIAGNOSTIC_ASSERT(mContext);
mContext = nullptr;
mManager = nullptr;
mInitAction = nullptr;
@@ -251,9 +249,9 @@ void
Context::QuotaInitRunnable::OpenDirectory()
{
NS_ASSERT_OWNINGTHREAD(QuotaInitRunnable);
MOZ_ASSERT(mState == STATE_CREATE_QUOTA_MANAGER ||
MOZ_DIAGNOSTIC_ASSERT(mState == STATE_CREATE_QUOTA_MANAGER ||
mState == STATE_OPEN_DIRECTORY);
MOZ_ASSERT(QuotaManager::Get());
MOZ_DIAGNOSTIC_ASSERT(QuotaManager::Get());
// QuotaManager::OpenDirectory() will hold a reference to us as
// a listener. We will then get DirectoryLockAcquired() on the owning
@@ -272,8 +270,8 @@ void
Context::QuotaInitRunnable::DirectoryLockAcquired(DirectoryLock* aLock)
{
NS_ASSERT_OWNINGTHREAD(QuotaInitRunnable);
MOZ_ASSERT(mState == STATE_WAIT_FOR_DIRECTORY_LOCK);
MOZ_ASSERT(!mDirectoryLock);
MOZ_DIAGNOSTIC_ASSERT(mState == STATE_WAIT_FOR_DIRECTORY_LOCK);
MOZ_DIAGNOSTIC_ASSERT(!mDirectoryLock);
mDirectoryLock = aLock;
@@ -283,7 +281,7 @@ Context::QuotaInitRunnable::DirectoryLockAcquired(DirectoryLock* aLock)
}
QuotaManager* qm = QuotaManager::Get();
MOZ_ASSERT(qm);
MOZ_DIAGNOSTIC_ASSERT(qm);
mState = STATE_ENSURE_ORIGIN_INITIALIZED;
nsresult rv = qm->IOThread()->Dispatch(this, nsIThread::DISPATCH_NORMAL);
@@ -297,8 +295,8 @@ void
Context::QuotaInitRunnable::DirectoryLockFailed()
{
NS_ASSERT_OWNINGTHREAD(QuotaInitRunnable);
MOZ_ASSERT(mState == STATE_WAIT_FOR_DIRECTORY_LOCK);
MOZ_ASSERT(!mDirectoryLock);
MOZ_DIAGNOSTIC_ASSERT(mState == STATE_WAIT_FOR_DIRECTORY_LOCK);
MOZ_DIAGNOSTIC_ASSERT(!mDirectoryLock);
NS_WARNING("Failed to acquire a directory lock!");
@@ -434,7 +432,7 @@ Context::QuotaInitRunnable::Run()
}
QuotaManager* qm = QuotaManager::Get();
MOZ_ASSERT(qm);
MOZ_DIAGNOSTIC_ASSERT(qm);
nsresult rv = qm->EnsureOriginIsInitialized(PERSISTENCE_TYPE_DEFAULT,
mQuotaInfo.mSuffix,
mQuotaInfo.mGroup,
@@ -462,7 +460,7 @@ Context::QuotaInitRunnable::Run()
// Execute the provided initialization Action. The Action must Resolve()
// before returning.
mInitAction->RunOnTarget(resolver, mQuotaInfo, mData);
MOZ_ASSERT(resolver->Resolved());
MOZ_DIAGNOSTIC_ASSERT(resolver->Resolved());
mData = nullptr;
@@ -523,18 +521,18 @@ public:
, mResult(NS_OK)
, mExecutingRunOnTarget(false)
{
MOZ_ASSERT(mContext);
MOZ_DIAGNOSTIC_ASSERT(mContext);
// mData may be nullptr
MOZ_ASSERT(mTarget);
MOZ_ASSERT(mAction);
MOZ_DIAGNOSTIC_ASSERT(mTarget);
MOZ_DIAGNOSTIC_ASSERT(mAction);
// mQuotaInfo.mDir may be nullptr if QuotaInitRunnable failed
MOZ_ASSERT(mInitiatingThread);
MOZ_DIAGNOSTIC_ASSERT(mInitiatingThread);
}
nsresult Dispatch()
{
NS_ASSERT_OWNINGTHREAD(ActionRunnable);
MOZ_ASSERT(mState == STATE_INIT);
MOZ_DIAGNOSTIC_ASSERT(mState == STATE_INIT);
mState = STATE_RUN_ON_TARGET;
nsresult rv = mTarget->Dispatch(this, nsIEventTarget::DISPATCH_NORMAL);
@@ -562,7 +560,7 @@ public:
virtual void Resolve(nsresult aRv) override
{
MOZ_ASSERT(mTarget == NS_GetCurrentThread());
MOZ_ASSERT(mState == STATE_RUNNING);
MOZ_DIAGNOSTIC_ASSERT(mState == STATE_RUNNING);
mResult = aRv;
@@ -588,16 +586,16 @@ public:
private:
~ActionRunnable()
{
MOZ_ASSERT(mState == STATE_COMPLETE);
MOZ_ASSERT(!mContext);
MOZ_ASSERT(!mAction);
MOZ_DIAGNOSTIC_ASSERT(mState == STATE_COMPLETE);
MOZ_DIAGNOSTIC_ASSERT(!mContext);
MOZ_DIAGNOSTIC_ASSERT(!mAction);
}
void Clear()
{
NS_ASSERT_OWNINGTHREAD(ActionRunnable);
MOZ_ASSERT(mContext);
MOZ_ASSERT(mAction);
MOZ_DIAGNOSTIC_ASSERT(mContext);
MOZ_DIAGNOSTIC_ASSERT(mAction);
mContext->RemoveActivity(this);
mContext = nullptr;
mAction = nullptr;
@@ -673,7 +671,7 @@ Context::ActionRunnable::Run()
case STATE_RUN_ON_TARGET:
{
MOZ_ASSERT(NS_GetCurrentThread() == mTarget);
MOZ_ASSERT(!mExecutingRunOnTarget);
MOZ_DIAGNOSTIC_ASSERT(!mExecutingRunOnTarget);
// Note that we are calling RunOnTarget(). This lets us detect
// if Resolve() is called synchronously.
@@ -820,16 +818,16 @@ Context::ThreadsafeHandle::InvalidateAndAllowToCloseOnOwningThread()
}
// We should synchronously have AllowToCloseOnOwningThread called when
// the Context is canceled.
MOZ_ASSERT(!mStrongRef);
MOZ_DIAGNOSTIC_ASSERT(!mStrongRef);
}
void
Context::ThreadsafeHandle::ContextDestroyed(Context* aContext)
{
MOZ_ASSERT(mOwningThread == NS_GetCurrentThread());
MOZ_ASSERT(!mStrongRef);
MOZ_ASSERT(mWeakRef);
MOZ_ASSERT(mWeakRef == aContext);
MOZ_DIAGNOSTIC_ASSERT(!mStrongRef);
MOZ_DIAGNOSTIC_ASSERT(mWeakRef);
MOZ_DIAGNOSTIC_ASSERT(mWeakRef == aContext);
mWeakRef = nullptr;
}
@@ -851,17 +849,17 @@ Context::Context(Manager* aManager, nsIThread* aTarget, Action* aInitAction)
, mOrphanedData(false)
, mInitAction(aInitAction)
{
MOZ_ASSERT(mManager);
MOZ_ASSERT(mTarget);
MOZ_DIAGNOSTIC_ASSERT(mManager);
MOZ_DIAGNOSTIC_ASSERT(mTarget);
}
void
Context::Dispatch(Action* aAction)
{
NS_ASSERT_OWNINGTHREAD(Context);
MOZ_ASSERT(aAction);
MOZ_DIAGNOSTIC_ASSERT(aAction);
MOZ_ASSERT(mState != STATE_CONTEXT_CANCELED);
MOZ_DIAGNOSTIC_ASSERT(mState != STATE_CONTEXT_CANCELED);
if (mState == STATE_CONTEXT_CANCELED) {
return;
} else if (mState == STATE_CONTEXT_INIT ||
@@ -871,7 +869,7 @@ Context::Dispatch(Action* aAction)
return;
}
MOZ_ASSERT(mState == STATE_CONTEXT_READY);
MOZ_DIAGNOSTIC_ASSERT(mState == STATE_CONTEXT_READY);
DispatchAction(aAction);
}
@@ -883,7 +881,7 @@ Context::CancelAll()
// In PREINIT state we have not dispatch the init action yet. Just
// forget it.
if (mState == STATE_CONTEXT_PREINIT) {
MOZ_ASSERT(!mInitRunnable);
MOZ_DIAGNOSTIC_ASSERT(!mInitRunnable);
mInitAction = nullptr;
// In INIT state we have dispatched the runnable, but not received the
@@ -953,8 +951,8 @@ Context::CancelForCacheId(CacheId aCacheId)
Context::~Context()
{
NS_ASSERT_OWNINGTHREAD(Context);
MOZ_ASSERT(mManager);
MOZ_ASSERT(!mData);
MOZ_DIAGNOSTIC_ASSERT(mManager);
MOZ_DIAGNOSTIC_ASSERT(!mData);
if (mThreadsafeHandle) {
mThreadsafeHandle->ContextDestroyed(this);
@@ -993,13 +991,13 @@ Context::Start()
// Previous context closing delayed our start, but then we were canceled.
// In this case, just do nothing here.
if (mState == STATE_CONTEXT_CANCELED) {
MOZ_ASSERT(!mInitRunnable);
MOZ_ASSERT(!mInitAction);
MOZ_DIAGNOSTIC_ASSERT(!mInitRunnable);
MOZ_DIAGNOSTIC_ASSERT(!mInitAction);
return;
}
MOZ_ASSERT(mState == STATE_CONTEXT_PREINIT);
MOZ_ASSERT(!mInitRunnable);
MOZ_DIAGNOSTIC_ASSERT(mState == STATE_CONTEXT_PREINIT);
MOZ_DIAGNOSTIC_ASSERT(!mInitRunnable);
mInitRunnable = new QuotaInitRunnable(this, mManager, mData, mTarget,
mInitAction);
@@ -1043,14 +1041,14 @@ Context::OnQuotaInit(nsresult aRv, const QuotaInfo& aQuotaInfo,
{
NS_ASSERT_OWNINGTHREAD(Context);
MOZ_ASSERT(mInitRunnable);
MOZ_DIAGNOSTIC_ASSERT(mInitRunnable);
mInitRunnable = nullptr;
mQuotaInfo = aQuotaInfo;
// Always save the directory lock to ensure QuotaManager does not shutdown
// before the Context has gone away.
MOZ_ASSERT(!mDirectoryLock);
MOZ_DIAGNOSTIC_ASSERT(!mDirectoryLock);
mDirectoryLock = aDirectoryLock;
// If we opening the context failed, but we were not explicitly canceled,
@@ -1071,7 +1069,7 @@ Context::OnQuotaInit(nsresult aRv, const QuotaInfo& aQuotaInfo,
return;
}
MOZ_ASSERT(mState == STATE_CONTEXT_INIT);
MOZ_DIAGNOSTIC_ASSERT(mState == STATE_CONTEXT_INIT);
mState = STATE_CONTEXT_READY;
for (uint32_t i = 0; i < mPendingActions.Length(); ++i) {
@@ -1084,7 +1082,7 @@ void
Context::AddActivity(Activity* aActivity)
{
NS_ASSERT_OWNINGTHREAD(Context);
MOZ_ASSERT(aActivity);
MOZ_DIAGNOSTIC_ASSERT(aActivity);
MOZ_ASSERT(!mActivityList.Contains(aActivity));
mActivityList.AppendElement(aActivity);
}
@@ -1093,7 +1091,7 @@ void
Context::RemoveActivity(Activity* aActivity)
{
NS_ASSERT_OWNINGTHREAD(Context);
MOZ_ASSERT(aActivity);
MOZ_DIAGNOSTIC_ASSERT(aActivity);
MOZ_ALWAYS_TRUE(mActivityList.RemoveElement(aActivity));
MOZ_ASSERT(!mActivityList.Contains(aActivity));
}
@@ -1121,8 +1119,8 @@ void
Context::SetNextContext(Context* aNextContext)
{
NS_ASSERT_OWNINGTHREAD(Context);
MOZ_ASSERT(aNextContext);
MOZ_ASSERT(!mNextContext);
MOZ_DIAGNOSTIC_ASSERT(aNextContext);
MOZ_DIAGNOSTIC_ASSERT(!mNextContext);
mNextContext = aNextContext;
}
@@ -1130,7 +1128,7 @@ void
Context::DoomTargetData()
{
NS_ASSERT_OWNINGTHREAD(Context);
MOZ_ASSERT(mData);
MOZ_DIAGNOSTIC_ASSERT(mData);
// We are about to drop our reference to the Data. We need to ensure that
// the ~Context() destructor does not run until contents of Data have been
@@ -1143,7 +1141,7 @@ Context::DoomTargetData()
RefPtr<Action> action = new NullAction();
DispatchAction(action, true /* doomed data */);
MOZ_ASSERT(!mData);
MOZ_DIAGNOSTIC_ASSERT(!mData);
}
} // namespace cache

View File

@@ -40,8 +40,8 @@ DBAction::RunOnTarget(Resolver* aResolver, const QuotaInfo& aQuotaInfo,
Data* aOptionalData)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aResolver);
MOZ_ASSERT(aQuotaInfo.mDir);
MOZ_DIAGNOSTIC_ASSERT(aResolver);
MOZ_DIAGNOSTIC_ASSERT(aQuotaInfo.mDir);
if (IsCanceled()) {
aResolver->Resolve(NS_ERROR_ABORT);
@@ -75,7 +75,7 @@ DBAction::RunOnTarget(Resolver* aResolver, const QuotaInfo& aQuotaInfo,
aResolver->Resolve(rv);
return;
}
MOZ_ASSERT(conn);
MOZ_DIAGNOSTIC_ASSERT(conn);
// Save this connection in the shared Data object so later Actions can
// use it. This avoids opening a new connection for every Action.
@@ -97,8 +97,8 @@ DBAction::OpenConnection(const QuotaInfo& aQuotaInfo, nsIFile* aDBDir,
mozIStorageConnection** aConnOut)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aDBDir);
MOZ_ASSERT(aConnOut);
MOZ_DIAGNOSTIC_ASSERT(aDBDir);
MOZ_DIAGNOSTIC_ASSERT(aConnOut);
nsCOMPtr<mozIStorageConnection> conn;
@@ -218,9 +218,9 @@ SyncDBAction::RunWithDBOnTarget(Resolver* aResolver,
mozIStorageConnection* aConn)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aResolver);
MOZ_ASSERT(aDBDir);
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aResolver);
MOZ_DIAGNOSTIC_ASSERT(aDBDir);
MOZ_DIAGNOSTIC_ASSERT(aConn);
nsresult rv = RunSyncWithDBOnTarget(aQuotaInfo, aDBDir, aConn);
aResolver->Resolve(rv);

142
dom/cache/DBSchema.cpp vendored
View File

@@ -406,7 +406,7 @@ nsresult
CreateOrMigrateSchema(mozIStorageConnection* aConn)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
int32_t schemaVersion;
nsresult rv = aConn->GetSchemaVersion(&schemaVersion);
@@ -496,7 +496,7 @@ nsresult
InitializeConnection(mozIStorageConnection* aConn)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
// This function needs to perform per-connection initialization tasks that
// need to happen regardless of the schema.
@@ -571,8 +571,8 @@ nsresult
CreateCacheId(mozIStorageConnection* aConn, CacheId* aCacheIdOut)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_ASSERT(aCacheIdOut);
MOZ_DIAGNOSTIC_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aCacheIdOut);
nsresult rv = aConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
"INSERT INTO caches DEFAULT VALUES;"
@@ -601,7 +601,7 @@ DeleteCacheId(mozIStorageConnection* aConn, CacheId aCacheId,
nsTArray<nsID>& aDeletedBodyIdListOut)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
// Delete the bodies explicitly as we need to read out the body IDs
// anyway. These body IDs must be deleted one-by-one as content may
@@ -639,8 +639,8 @@ IsCacheOrphaned(mozIStorageConnection* aConn, CacheId aCacheId,
bool* aOrphanedOut)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_ASSERT(aOrphanedOut);
MOZ_DIAGNOSTIC_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aOrphanedOut);
// err on the side of not deleting user data
*aOrphanedOut = false;
@@ -657,7 +657,7 @@ IsCacheOrphaned(mozIStorageConnection* aConn, CacheId aCacheId,
bool hasMoreData = false;
rv = state->ExecuteStep(&hasMoreData);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
MOZ_ASSERT(hasMoreData);
MOZ_DIAGNOSTIC_ASSERT(hasMoreData);
int32_t refCount;
rv = state->GetInt32(0, &refCount);
@@ -694,7 +694,7 @@ nsresult
GetKnownBodyIds(mozIStorageConnection* aConn, nsTArray<nsID>& aBodyIdListOut)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
nsCOMPtr<mozIStorageStatement> state;
nsresult rv = aConn->CreateStatement(NS_LITERAL_CSTRING(
@@ -732,9 +732,9 @@ CacheMatch(mozIStorageConnection* aConn, CacheId aCacheId,
SavedResponse* aSavedResponseOut)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_ASSERT(aFoundResponseOut);
MOZ_ASSERT(aSavedResponseOut);
MOZ_DIAGNOSTIC_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aFoundResponseOut);
MOZ_DIAGNOSTIC_ASSERT(aSavedResponseOut);
*aFoundResponseOut = false;
@@ -762,7 +762,7 @@ CacheMatchAll(mozIStorageConnection* aConn, CacheId aCacheId,
nsTArray<SavedResponse>& aSavedResponsesOut)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
nsresult rv;
AutoTArray<EntryId, 256> matches;
@@ -795,7 +795,7 @@ CachePut(mozIStorageConnection* aConn, CacheId aCacheId,
nsTArray<nsID>& aDeletedBodyIdListOut)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
CacheQueryParams params(false, false, false, false,
NS_LITERAL_STRING(""));
@@ -827,8 +827,8 @@ CacheDelete(mozIStorageConnection* aConn, CacheId aCacheId,
nsTArray<nsID>& aDeletedBodyIdListOut, bool* aSuccessOut)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_ASSERT(aSuccessOut);
MOZ_DIAGNOSTIC_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aSuccessOut);
*aSuccessOut = false;
@@ -860,7 +860,7 @@ CacheKeys(mozIStorageConnection* aConn, CacheId aCacheId,
nsTArray<SavedRequest>& aSavedRequestsOut)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
nsresult rv;
AutoTArray<EntryId, 256> matches;
@@ -893,9 +893,9 @@ StorageMatch(mozIStorageConnection* aConn,
SavedResponse* aSavedResponseOut)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_ASSERT(aFoundResponseOut);
MOZ_ASSERT(aSavedResponseOut);
MOZ_DIAGNOSTIC_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aFoundResponseOut);
MOZ_DIAGNOSTIC_ASSERT(aSavedResponseOut);
*aFoundResponseOut = false;
@@ -961,9 +961,9 @@ StorageGetCacheId(mozIStorageConnection* aConn, Namespace aNamespace,
CacheId* aCacheIdOut)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_ASSERT(aFoundCacheOut);
MOZ_ASSERT(aCacheIdOut);
MOZ_DIAGNOSTIC_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aFoundCacheOut);
MOZ_DIAGNOSTIC_ASSERT(aCacheIdOut);
*aFoundCacheOut = false;
@@ -1002,7 +1002,7 @@ StoragePutCache(mozIStorageConnection* aConn, Namespace aNamespace,
const nsAString& aKey, CacheId aCacheId)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
nsCOMPtr<mozIStorageStatement> state;
nsresult rv = aConn->CreateStatement(NS_LITERAL_CSTRING(
@@ -1031,7 +1031,7 @@ StorageForgetCache(mozIStorageConnection* aConn, Namespace aNamespace,
const nsAString& aKey)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
// How we constrain the key column depends on the value of our key. Use
// a format string for the query and let CreateAndBindKeyStatement() fill
@@ -1057,7 +1057,7 @@ StorageGetKeys(mozIStorageConnection* aConn, Namespace aNamespace,
nsTArray<nsString>& aKeysOut)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
nsCOMPtr<mozIStorageStatement> state;
nsresult rv = aConn->CreateStatement(NS_LITERAL_CSTRING(
@@ -1087,7 +1087,7 @@ QueryAll(mozIStorageConnection* aConn, CacheId aCacheId,
nsTArray<EntryId>& aEntryIdListOut)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
nsCOMPtr<mozIStorageStatement> state;
nsresult rv = aConn->CreateStatement(NS_LITERAL_CSTRING(
@@ -1117,8 +1117,8 @@ QueryCache(mozIStorageConnection* aConn, CacheId aCacheId,
uint32_t aMaxResults)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_ASSERT(aMaxResults > 0);
MOZ_DIAGNOSTIC_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aMaxResults > 0);
if (!aParams.ignoreMethod() &&
!aRequest.method().LowerCaseEqualsLiteral("get"))
@@ -1222,7 +1222,7 @@ MatchByVaryHeader(mozIStorageConnection* aConn,
EntryId entryId, bool* aSuccessOut)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
*aSuccessOut = false;
@@ -1248,7 +1248,7 @@ MatchByVaryHeader(mozIStorageConnection* aConn,
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
// Should not have called this function if this was not the case
MOZ_ASSERT(!varyValues.IsEmpty());
MOZ_DIAGNOSTIC_ASSERT(!varyValues.IsEmpty());
state->Reset();
rv = aConn->CreateStatement(NS_LITERAL_CSTRING(
@@ -1293,7 +1293,7 @@ MatchByVaryHeader(mozIStorageConnection* aConn,
for (; token;
token = nsCRT::strtok(rawBuffer, NS_HTTP_HEADER_SEPS, &rawBuffer)) {
nsDependentCString header(token);
MOZ_ASSERT(!header.EqualsLiteral("*"),
MOZ_DIAGNOSTIC_ASSERT(!header.EqualsLiteral("*"),
"We should have already caught this in "
"TypeUtils::ToPCacheResponseWithoutBody()");
@@ -1302,14 +1302,14 @@ MatchByVaryHeader(mozIStorageConnection* aConn,
queryHeaders->Get(header, queryValue, errorResult);
if (errorResult.Failed()) {
errorResult.SuppressException();
MOZ_ASSERT(queryValue.IsEmpty());
MOZ_DIAGNOSTIC_ASSERT(queryValue.IsEmpty());
}
nsAutoCString cachedValue;
cachedHeaders->Get(header, cachedValue, errorResult);
if (errorResult.Failed()) {
errorResult.SuppressException();
MOZ_ASSERT(cachedValue.IsEmpty());
MOZ_DIAGNOSTIC_ASSERT(cachedValue.IsEmpty());
}
if (queryValue != cachedValue) {
@@ -1336,13 +1336,13 @@ DeleteEntries(mozIStorageConnection* aConn,
uint32_t aPos, int32_t aLen)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
if (aEntryIdList.IsEmpty()) {
return NS_OK;
}
MOZ_ASSERT(aPos < aEntryIdList.Length());
MOZ_DIAGNOSTIC_ASSERT(aPos < aEntryIdList.Length());
if (aLen < 0) {
aLen = aEntryIdList.Length() - aPos;
@@ -1449,10 +1449,10 @@ nsresult
InsertSecurityInfo(mozIStorageConnection* aConn, nsICryptoHash* aCrypto,
const nsACString& aData, int32_t *aIdOut)
{
MOZ_ASSERT(aConn);
MOZ_ASSERT(aCrypto);
MOZ_ASSERT(aIdOut);
MOZ_ASSERT(!aData.IsEmpty());
MOZ_DIAGNOSTIC_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aCrypto);
MOZ_DIAGNOSTIC_ASSERT(aIdOut);
MOZ_DIAGNOSTIC_ASSERT(!aData.IsEmpty());
// We want to use an index to find existing security blobs, but indexing
// the full blob would be quite expensive. Instead, we index a small
@@ -1566,7 +1566,7 @@ DeleteSecurityInfo(mozIStorageConnection* aConn, int32_t aId, int32_t aCount)
rv = state->GetInt32(0, &refcount);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
MOZ_ASSERT(refcount >= aCount);
MOZ_DIAGNOSTIC_ASSERT(refcount >= aCount);
// Next, calculate the new refcount
int32_t newCount = refcount - aCount;
@@ -1628,7 +1628,7 @@ InsertEntry(mozIStorageConnection* aConn, CacheId aCacheId,
const nsID* aResponseBodyId)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
nsresult rv = NS_OK;
@@ -1797,7 +1797,7 @@ InsertEntry(mozIStorageConnection* aConn, CacheId aCacheId,
if (aResponse.principalInfo().type() == mozilla::ipc::OptionalPrincipalInfo::TPrincipalInfo) {
const mozilla::ipc::PrincipalInfo& principalInfo =
aResponse.principalInfo().get_PrincipalInfo();
MOZ_ASSERT(principalInfo.type() == mozilla::ipc::PrincipalInfo::TContentPrincipalInfo);
MOZ_DIAGNOSTIC_ASSERT(principalInfo.type() == mozilla::ipc::PrincipalInfo::TContentPrincipalInfo);
const mozilla::ipc::ContentPrincipalInfo& cInfo =
principalInfo.get_ContentPrincipalInfo();
@@ -1912,8 +1912,8 @@ ReadResponse(mozIStorageConnection* aConn, EntryId aEntryId,
SavedResponse* aSavedResponseOut)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_ASSERT(aSavedResponseOut);
MOZ_DIAGNOSTIC_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aSavedResponseOut);
nsCOMPtr<mozIStorageStatement> state;
nsresult rv = aConn->CreateStatement(NS_LITERAL_CSTRING(
@@ -2040,8 +2040,8 @@ ReadRequest(mozIStorageConnection* aConn, EntryId aEntryId,
SavedRequest* aSavedRequestOut)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_ASSERT(aSavedRequestOut);
MOZ_DIAGNOSTIC_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aSavedRequestOut);
nsCOMPtr<mozIStorageStatement> state;
nsresult rv = aConn->CreateStatement(NS_LITERAL_CSTRING(
"SELECT "
@@ -2159,7 +2159,7 @@ AppendListParamsToQuery(nsACString& aQuery,
uint32_t aPos, int32_t aLen)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT((aPos + aLen) <= aEntryIdList.Length());
MOZ_DIAGNOSTIC_ASSERT((aPos + aLen) <= aEntryIdList.Length());
for (int32_t i = aPos; i < aLen; ++i) {
if (i == 0) {
aQuery.AppendLiteral("?");
@@ -2175,7 +2175,7 @@ BindListParamsToQuery(mozIStorageStatement* aState,
uint32_t aPos, int32_t aLen)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT((aPos + aLen) <= aEntryIdList.Length());
MOZ_DIAGNOSTIC_ASSERT((aPos + aLen) <= aEntryIdList.Length());
for (int32_t i = aPos; i < aLen; ++i) {
nsresult rv = aState->BindInt32ByIndex(i, aEntryIdList[i]);
NS_ENSURE_SUCCESS(rv, rv);
@@ -2187,7 +2187,7 @@ nsresult
BindId(mozIStorageStatement* aState, const nsACString& aName, const nsID* aId)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aState);
MOZ_DIAGNOSTIC_ASSERT(aState);
nsresult rv;
if (!aId) {
@@ -2208,8 +2208,8 @@ nsresult
ExtractId(mozIStorageStatement* aState, uint32_t aPos, nsID* aIdOut)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aState);
MOZ_ASSERT(aIdOut);
MOZ_DIAGNOSTIC_ASSERT(aState);
MOZ_DIAGNOSTIC_ASSERT(aIdOut);
nsAutoCString idString;
nsresult rv = aState->GetUTF8String(aPos, idString);
@@ -2227,9 +2227,9 @@ CreateAndBindKeyStatement(mozIStorageConnection* aConn,
const nsAString& aKey,
mozIStorageStatement** aStateOut)
{
MOZ_ASSERT(aConn);
MOZ_ASSERT(aQueryFormat);
MOZ_ASSERT(aStateOut);
MOZ_DIAGNOSTIC_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aQueryFormat);
MOZ_DIAGNOSTIC_ASSERT(aStateOut);
// The key is stored as a blob to avoid encoding issues. An empty string
// is mapped to NULL for blobs. Normally we would just write the query
@@ -2263,7 +2263,7 @@ CreateAndBindKeyStatement(mozIStorageConnection* aConn,
nsresult
HashCString(nsICryptoHash* aCrypto, const nsACString& aIn, nsACString& aOut)
{
MOZ_ASSERT(aCrypto);
MOZ_DIAGNOSTIC_ASSERT(aCrypto);
nsresult rv = aCrypto->Init(nsICryptoHash::SHA1);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
@@ -2527,7 +2527,7 @@ nsresult
Migrate(mozIStorageConnection* aConn)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
int32_t currentVersion = 0;
nsresult rv = aConn->GetSchemaVersion(&currentVersion);
@@ -2539,7 +2539,7 @@ Migrate(mozIStorageConnection* aConn)
// Wiping old databases is handled in DBAction because it requires
// making a whole new mozIStorageConnection. Make sure we don't
// accidentally get here for one of those old databases.
MOZ_ASSERT(currentVersion >= kFirstShippedSchemaVersion);
MOZ_DIAGNOSTIC_ASSERT(currentVersion >= kFirstShippedSchemaVersion);
for (uint32_t i = 0; i < sMigrationListLength; ++i) {
if (sMigrationList[i].mFromVersion == currentVersion) {
@@ -2553,13 +2553,15 @@ Migrate(mozIStorageConnection* aConn)
}
}
DebugOnly<int32_t> lastVersion = currentVersion;
#if !defined(RELEASE_OR_BETA)
int32_t lastVersion = currentVersion;
#endif
rv = aConn->GetSchemaVersion(&currentVersion);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
MOZ_ASSERT(currentVersion > lastVersion);
MOZ_DIAGNOSTIC_ASSERT(currentVersion > lastVersion);
}
MOZ_ASSERT(currentVersion == kLatestSchemaVersion);
MOZ_DIAGNOSTIC_ASSERT(currentVersion == kLatestSchemaVersion);
if (rewriteSchema) {
// Now overwrite the master SQL for the entries table to remove the column
@@ -2574,7 +2576,7 @@ Migrate(mozIStorageConnection* aConn)
nsresult MigrateFrom15To16(mozIStorageConnection* aConn, bool& aRewriteSchema)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
// Add the request_redirect column with a default value of "follow". Note,
// we only use a default value here because its required by ALTER TABLE and
@@ -2599,7 +2601,7 @@ nsresult
MigrateFrom16To17(mozIStorageConnection* aConn, bool& aRewriteSchema)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
// This migration path removes the response_redirected and
// response_redirected_url columns from the entries table. sqlite doesn't
@@ -2731,7 +2733,7 @@ nsresult
MigrateFrom17To18(mozIStorageConnection* aConn, bool& aRewriteSchema)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
// 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
@@ -2758,7 +2760,7 @@ nsresult
MigrateFrom18To19(mozIStorageConnection* aConn, bool& aRewriteSchema)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
// This migration is needed in order to update the RequestMode values for
// Request objects corresponding to a navigation content policy type to
@@ -2786,7 +2788,7 @@ MigrateFrom18To19(mozIStorageConnection* aConn, bool& aRewriteSchema)
nsresult MigrateFrom19To20(mozIStorageConnection* aConn, bool& aRewriteSchema)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
// Add the request_referrer_policy column with a default value of
// "no-referrer-when-downgrade". Note, we only use a default value here
@@ -2810,7 +2812,7 @@ nsresult MigrateFrom19To20(mozIStorageConnection* aConn, bool& aRewriteSchema)
nsresult MigrateFrom20To21(mozIStorageConnection* aConn, bool& aRewriteSchema)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
// This migration creates response_url_list table to store response_url and
// removes the response_url column from the entries table.
@@ -2964,7 +2966,7 @@ nsresult MigrateFrom20To21(mozIStorageConnection* aConn, bool& aRewriteSchema)
nsresult MigrateFrom21To22(mozIStorageConnection* aConn, bool& aRewriteSchema)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
// Add the request_integrity column.
nsresult rv = aConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
@@ -2984,7 +2986,7 @@ nsresult MigrateFrom21To22(mozIStorageConnection* aConn, bool& aRewriteSchema)
nsresult MigrateFrom22To23(mozIStorageConnection* aConn, bool& aRewriteSchema)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
// The only change between 22 and 23 was a different snappy compression
// format, but it's backwards-compatible.
@@ -2995,7 +2997,7 @@ nsresult MigrateFrom22To23(mozIStorageConnection* aConn, bool& aRewriteSchema)
nsresult MigrateFrom23To24(mozIStorageConnection* aConn, bool& aRewriteSchema)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(aConn);
// Add the request_url_fragment column.
nsresult rv = aConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(

View File

@@ -43,7 +43,7 @@ BodyIdToFile(nsIFile* aBaseDir, const nsID& aId, BodyFileType aType,
nsresult
BodyCreateDir(nsIFile* aBaseDir)
{
MOZ_ASSERT(aBaseDir);
MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
nsCOMPtr<nsIFile> aBodyDir;
nsresult rv = aBaseDir->Clone(getter_AddRefs(aBodyDir));
@@ -65,7 +65,7 @@ BodyCreateDir(nsIFile* aBaseDir)
nsresult
BodyDeleteDir(nsIFile* aBaseDir)
{
MOZ_ASSERT(aBaseDir);
MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
nsCOMPtr<nsIFile> aBodyDir;
nsresult rv = aBaseDir->Clone(getter_AddRefs(aBodyDir));
@@ -88,14 +88,14 @@ BodyDeleteDir(nsIFile* aBaseDir)
nsresult
BodyGetCacheDir(nsIFile* aBaseDir, const nsID& aId, nsIFile** aCacheDirOut)
{
MOZ_ASSERT(aBaseDir);
MOZ_ASSERT(aCacheDirOut);
MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
MOZ_DIAGNOSTIC_ASSERT(aCacheDirOut);
*aCacheDirOut = nullptr;
nsresult rv = aBaseDir->Clone(aCacheDirOut);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
MOZ_ASSERT(*aCacheDirOut);
MOZ_DIAGNOSTIC_ASSERT(*aCacheDirOut);
rv = (*aCacheDirOut)->Append(NS_LITERAL_STRING("morgue"));
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
@@ -126,12 +126,12 @@ BodyStartWriteStream(const QuotaInfo& aQuotaInfo,
nsAsyncCopyCallbackFun aCallback, nsID* aIdOut,
nsISupports** aCopyContextOut)
{
MOZ_ASSERT(aBaseDir);
MOZ_ASSERT(aSource);
MOZ_ASSERT(aClosure);
MOZ_ASSERT(aCallback);
MOZ_ASSERT(aIdOut);
MOZ_ASSERT(aCopyContextOut);
MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
MOZ_DIAGNOSTIC_ASSERT(aSource);
MOZ_DIAGNOSTIC_ASSERT(aClosure);
MOZ_DIAGNOSTIC_ASSERT(aCallback);
MOZ_DIAGNOSTIC_ASSERT(aIdOut);
MOZ_DIAGNOSTIC_ASSERT(aCopyContextOut);
nsresult rv;
nsCOMPtr<nsIUUIDGenerator> idGen =
@@ -183,8 +183,8 @@ BodyStartWriteStream(const QuotaInfo& aQuotaInfo,
void
BodyCancelWrite(nsIFile* aBaseDir, nsISupports* aCopyContext)
{
MOZ_ASSERT(aBaseDir);
MOZ_ASSERT(aCopyContext);
MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
MOZ_DIAGNOSTIC_ASSERT(aCopyContext);
nsresult rv = NS_CancelAsyncCopy(aCopyContext, NS_ERROR_ABORT);
Unused << NS_WARN_IF(NS_FAILED(rv));
@@ -197,7 +197,7 @@ BodyCancelWrite(nsIFile* aBaseDir, nsISupports* aCopyContext)
nsresult
BodyFinalizeWrite(nsIFile* aBaseDir, const nsID& aId)
{
MOZ_ASSERT(aBaseDir);
MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
nsCOMPtr<nsIFile> tmpFile;
nsresult rv = BodyIdToFile(aBaseDir, aId, BODY_FILE_TMP, getter_AddRefs(tmpFile));
@@ -222,8 +222,8 @@ nsresult
BodyOpen(const QuotaInfo& aQuotaInfo, nsIFile* aBaseDir, const nsID& aId,
nsIInputStream** aStreamOut)
{
MOZ_ASSERT(aBaseDir);
MOZ_ASSERT(aStreamOut);
MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
MOZ_DIAGNOSTIC_ASSERT(aStreamOut);
nsCOMPtr<nsIFile> finalFile;
nsresult rv = BodyIdToFile(aBaseDir, aId, BODY_FILE_FINAL,
@@ -292,14 +292,14 @@ nsresult
BodyIdToFile(nsIFile* aBaseDir, const nsID& aId, BodyFileType aType,
nsIFile** aBodyFileOut)
{
MOZ_ASSERT(aBaseDir);
MOZ_ASSERT(aBodyFileOut);
MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
MOZ_DIAGNOSTIC_ASSERT(aBodyFileOut);
*aBodyFileOut = nullptr;
nsresult rv = BodyGetCacheDir(aBaseDir, aId, aBodyFileOut);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
MOZ_ASSERT(*aBodyFileOut);
MOZ_DIAGNOSTIC_ASSERT(*aBodyFileOut);
char idString[NSID_LENGTH];
aId.ToProvidedString(idString);
@@ -323,7 +323,7 @@ BodyIdToFile(nsIFile* aBaseDir, const nsID& aId, BodyFileType aType,
nsresult
BodyDeleteOrphanedFiles(nsIFile* aBaseDir, nsTArray<nsID>& aKnownBodyIdList)
{
MOZ_ASSERT(aBaseDir);
MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
// body files are stored in a directory structure like:
//
@@ -421,7 +421,7 @@ namespace {
nsresult
GetMarkerFileHandle(const QuotaInfo& aQuotaInfo, nsIFile** aFileOut)
{
MOZ_ASSERT(aFileOut);
MOZ_DIAGNOSTIC_ASSERT(aFileOut);
nsCOMPtr<nsIFile> marker;
nsresult rv = aQuotaInfo.mDir->Clone(getter_AddRefs(marker));

108
dom/cache/Manager.cpp vendored
View File

@@ -117,8 +117,8 @@ public:
virtual void
RunOnTarget(Resolver* aResolver, const QuotaInfo& aQuotaInfo, Data*) override
{
MOZ_ASSERT(aResolver);
MOZ_ASSERT(aQuotaInfo.mDir);
MOZ_DIAGNOSTIC_ASSERT(aResolver);
MOZ_DIAGNOSTIC_ASSERT(aQuotaInfo.mDir);
// Note that since DeleteOrphanedBodyAction isn't used while the context is
// being initialized, we don't need to check for cancellation here.
@@ -231,8 +231,8 @@ public:
Remove(Manager* aManager)
{
mozilla::ipc::AssertIsOnBackgroundThread();
MOZ_ASSERT(aManager);
MOZ_ASSERT(sFactory);
MOZ_DIAGNOSTIC_ASSERT(aManager);
MOZ_DIAGNOSTIC_ASSERT(sFactory);
MOZ_ALWAYS_TRUE(sFactory->mManagerList.RemoveElement(aManager));
@@ -249,7 +249,7 @@ public:
return;
}
MOZ_ASSERT(!sFactory->mManagerList.IsEmpty());
MOZ_DIAGNOSTIC_ASSERT(!sFactory->mManagerList.IsEmpty());
{
ManagerList::ForwardIterator iter(sFactory->mManagerList);
@@ -272,7 +272,7 @@ public:
return;
}
MOZ_ASSERT(!sFactory->mManagerList.IsEmpty());
MOZ_DIAGNOSTIC_ASSERT(!sFactory->mManagerList.IsEmpty());
{
// Note that we are synchronously calling shutdown code here. If any
@@ -308,8 +308,8 @@ private:
~Factory()
{
MOZ_COUNT_DTOR(cache::Manager::Factory);
MOZ_ASSERT(mManagerList.IsEmpty());
MOZ_ASSERT(!mInSyncShutdown);
MOZ_DIAGNOSTIC_ASSERT(mManagerList.IsEmpty());
MOZ_DIAGNOSTIC_ASSERT(!mInSyncShutdown);
}
static nsresult
@@ -348,7 +348,7 @@ private:
MaybeDestroyInstance()
{
mozilla::ipc::AssertIsOnBackgroundThread();
MOZ_ASSERT(sFactory);
MOZ_DIAGNOSTIC_ASSERT(sFactory);
// If the factory is is still in use then we cannot delete yet. This
// could be due to managers still existing or because we are in the
@@ -622,9 +622,9 @@ public:
, mAsyncResult(NS_OK)
, mMutex("cache::Manager::CachePutAllAction")
{
MOZ_ASSERT(!aPutList.IsEmpty());
MOZ_ASSERT(aPutList.Length() == aRequestStreamList.Length());
MOZ_ASSERT(aPutList.Length() == aResponseStreamList.Length());
MOZ_DIAGNOSTIC_ASSERT(!aPutList.IsEmpty());
MOZ_DIAGNOSTIC_ASSERT(aPutList.Length() == aRequestStreamList.Length());
MOZ_DIAGNOSTIC_ASSERT(aPutList.Length() == aResponseStreamList.Length());
for (uint32_t i = 0; i < aPutList.Length(); ++i) {
Entry* entry = mList.AppendElement();
@@ -642,21 +642,21 @@ private:
RunWithDBOnTarget(Resolver* aResolver, const QuotaInfo& aQuotaInfo,
nsIFile* aDBDir, mozIStorageConnection* aConn) override
{
MOZ_ASSERT(aResolver);
MOZ_ASSERT(aDBDir);
MOZ_ASSERT(aConn);
MOZ_ASSERT(!mResolver);
MOZ_ASSERT(!mDBDir);
MOZ_ASSERT(!mConn);
MOZ_DIAGNOSTIC_ASSERT(aResolver);
MOZ_DIAGNOSTIC_ASSERT(aDBDir);
MOZ_DIAGNOSTIC_ASSERT(aConn);
MOZ_DIAGNOSTIC_ASSERT(!mResolver);
MOZ_DIAGNOSTIC_ASSERT(!mDBDir);
MOZ_DIAGNOSTIC_ASSERT(!mConn);
MOZ_ASSERT(!mTargetThread);
MOZ_DIAGNOSTIC_ASSERT(!mTargetThread);
mTargetThread = NS_GetCurrentThread();
MOZ_ASSERT(mTargetThread);
MOZ_DIAGNOSTIC_ASSERT(mTargetThread);
// We should be pre-initialized to expect one async completion. This is
// the "manual" completion we call at the end of this method in all
// cases.
MOZ_ASSERT(mExpectedAsyncCopyCompletions == 1);
MOZ_DIAGNOSTIC_ASSERT(mExpectedAsyncCopyCompletions == 1);
mResolver = aResolver;
mDBDir = aDBDir;
@@ -695,9 +695,9 @@ private:
OnAsyncCopyComplete(nsresult aRv)
{
MOZ_ASSERT(mTargetThread == NS_GetCurrentThread());
MOZ_ASSERT(mConn);
MOZ_ASSERT(mResolver);
MOZ_ASSERT(mExpectedAsyncCopyCompletions > 0);
MOZ_DIAGNOSTIC_ASSERT(mConn);
MOZ_DIAGNOSTIC_ASSERT(mResolver);
MOZ_DIAGNOSTIC_ASSERT(mExpectedAsyncCopyCompletions > 0);
// Explicitly check for cancellation here to catch a race condition.
// Consider:
@@ -842,7 +842,7 @@ private:
StreamId aStreamId, uint32_t* aCopyCountOut)
{
MOZ_ASSERT(mTargetThread == NS_GetCurrentThread());
MOZ_ASSERT(aCopyCountOut);
MOZ_DIAGNOSTIC_ASSERT(aCopyCountOut);
if (IsCanceled()) {
return NS_ERROR_ABORT;
@@ -855,7 +855,7 @@ private:
source = aEntry.mRequestStream;
bodyId = &aEntry.mRequestBodyId;
} else {
MOZ_ASSERT(aStreamId == ResponseStream);
MOZ_DIAGNOSTIC_ASSERT(aStreamId == ResponseStream);
source = aEntry.mResponseStream;
bodyId = &aEntry.mResponseBodyId;
}
@@ -898,7 +898,7 @@ private:
AsyncCopyCompleteFunc(void* aClosure, nsresult aRv)
{
// May be on any thread, including STS event target.
MOZ_ASSERT(aClosure);
MOZ_DIAGNOSTIC_ASSERT(aClosure);
// Weak ref as we are guaranteed to the action is alive until
// CompleteOnInitiatingThread is called.
CachePutAllAction* action = static_cast<CachePutAllAction*>(aClosure);
@@ -1453,13 +1453,13 @@ void
Manager::RemoveContext(Context* aContext)
{
NS_ASSERT_OWNINGTHREAD(Manager);
MOZ_ASSERT(mContext);
MOZ_ASSERT(mContext == aContext);
MOZ_DIAGNOSTIC_ASSERT(mContext);
MOZ_DIAGNOSTIC_ASSERT(mContext == aContext);
// Whether the Context destruction was triggered from the Manager going
// idle or the underlying storage being invalidated, we should know we
// are closing before the Context is destroyed.
MOZ_ASSERT(mState == Closing);
MOZ_DIAGNOSTIC_ASSERT(mState == Closing);
// Before forgetting the Context, check to see if we have any outstanding
// cache or body objects waiting for deletion. If so, note that we've
@@ -1523,9 +1523,11 @@ Manager::ReleaseCacheId(CacheId aCacheId)
NS_ASSERT_OWNINGTHREAD(Manager);
for (uint32_t i = 0; i < mCacheIdRefs.Length(); ++i) {
if (mCacheIdRefs[i].mCacheId == aCacheId) {
DebugOnly<uint32_t> oldRef = mCacheIdRefs[i].mCount;
#if !defined(RELEASE_OR_BETA)
uint32_t oldRef = mCacheIdRefs[i].mCount;
#endif
mCacheIdRefs[i].mCount -= 1;
MOZ_ASSERT(mCacheIdRefs[i].mCount < oldRef);
MOZ_DIAGNOSTIC_ASSERT(mCacheIdRefs[i].mCount < oldRef);
if (mCacheIdRefs[i].mCount == 0) {
bool orphaned = mCacheIdRefs[i].mOrphaned;
mCacheIdRefs.RemoveElementAt(i);
@@ -1572,9 +1574,11 @@ Manager::ReleaseBodyId(const nsID& aBodyId)
NS_ASSERT_OWNINGTHREAD(Manager);
for (uint32_t i = 0; i < mBodyIdRefs.Length(); ++i) {
if (mBodyIdRefs[i].mBodyId == aBodyId) {
DebugOnly<uint32_t> oldRef = mBodyIdRefs[i].mCount;
#if !defined(RELEASE_OR_BETA)
uint32_t oldRef = mBodyIdRefs[i].mCount;
#endif
mBodyIdRefs[i].mCount -= 1;
MOZ_ASSERT(mBodyIdRefs[i].mCount < oldRef);
MOZ_DIAGNOSTIC_ASSERT(mBodyIdRefs[i].mCount < oldRef);
if (mBodyIdRefs[i].mCount < 1) {
bool orphaned = mBodyIdRefs[i].mOrphaned;
mBodyIdRefs.RemoveElementAt(i);
@@ -1608,7 +1612,7 @@ void
Manager::AddStreamList(StreamList* aStreamList)
{
NS_ASSERT_OWNINGTHREAD(Manager);
MOZ_ASSERT(aStreamList);
MOZ_DIAGNOSTIC_ASSERT(aStreamList);
mStreamLists.AppendElement(aStreamList);
}
@@ -1616,7 +1620,7 @@ void
Manager::RemoveStreamList(StreamList* aStreamList)
{
NS_ASSERT_OWNINGTHREAD(Manager);
MOZ_ASSERT(aStreamList);
MOZ_DIAGNOSTIC_ASSERT(aStreamList);
mStreamLists.RemoveElement(aStreamList);
}
@@ -1625,8 +1629,8 @@ Manager::ExecuteCacheOp(Listener* aListener, CacheId aCacheId,
const CacheOpArgs& aOpArgs)
{
NS_ASSERT_OWNINGTHREAD(Manager);
MOZ_ASSERT(aListener);
MOZ_ASSERT(aOpArgs.type() != CacheOpArgs::TCachePutAllArgs);
MOZ_DIAGNOSTIC_ASSERT(aListener);
MOZ_DIAGNOSTIC_ASSERT(aOpArgs.type() != CacheOpArgs::TCachePutAllArgs);
if (NS_WARN_IF(mState == Closing)) {
aListener->OnOpComplete(ErrorResult(NS_ERROR_FAILURE), void_t());
@@ -1634,7 +1638,7 @@ Manager::ExecuteCacheOp(Listener* aListener, CacheId aCacheId,
}
RefPtr<Context> context = mContext;
MOZ_ASSERT(!context->IsCanceled());
MOZ_DIAGNOSTIC_ASSERT(!context->IsCanceled());
RefPtr<StreamList> streamList = new StreamList(this, context);
ListenerId listenerId = SaveListener(aListener);
@@ -1670,7 +1674,7 @@ Manager::ExecuteStorageOp(Listener* aListener, Namespace aNamespace,
const CacheOpArgs& aOpArgs)
{
NS_ASSERT_OWNINGTHREAD(Manager);
MOZ_ASSERT(aListener);
MOZ_DIAGNOSTIC_ASSERT(aListener);
if (NS_WARN_IF(mState == Closing)) {
aListener->OnOpComplete(ErrorResult(NS_ERROR_FAILURE), void_t());
@@ -1678,7 +1682,7 @@ Manager::ExecuteStorageOp(Listener* aListener, Namespace aNamespace,
}
RefPtr<Context> context = mContext;
MOZ_ASSERT(!context->IsCanceled());
MOZ_DIAGNOSTIC_ASSERT(!context->IsCanceled());
RefPtr<StreamList> streamList = new StreamList(this, context);
ListenerId listenerId = SaveListener(aListener);
@@ -1719,7 +1723,7 @@ Manager::ExecutePutAll(Listener* aListener, CacheId aCacheId,
const nsTArray<nsCOMPtr<nsIInputStream>>& aResponseStreamList)
{
NS_ASSERT_OWNINGTHREAD(Manager);
MOZ_ASSERT(aListener);
MOZ_DIAGNOSTIC_ASSERT(aListener);
if (NS_WARN_IF(mState == Closing)) {
aListener->OnOpComplete(ErrorResult(NS_ERROR_FAILURE), CachePutAllResult());
@@ -1727,7 +1731,7 @@ Manager::ExecutePutAll(Listener* aListener, CacheId aCacheId,
}
RefPtr<Context> context = mContext;
MOZ_ASSERT(!context->IsCanceled());
MOZ_DIAGNOSTIC_ASSERT(!context->IsCanceled());
ListenerId listenerId = SaveListener(aListener);
@@ -1745,15 +1749,15 @@ Manager::Manager(ManagerId* aManagerId, nsIThread* aIOThread)
, mShuttingDown(false)
, mState(Open)
{
MOZ_ASSERT(mManagerId);
MOZ_ASSERT(mIOThread);
MOZ_DIAGNOSTIC_ASSERT(mManagerId);
MOZ_DIAGNOSTIC_ASSERT(mIOThread);
}
Manager::~Manager()
{
NS_ASSERT_OWNINGTHREAD(Manager);
MOZ_ASSERT(mState == Closing);
MOZ_ASSERT(!mContext);
MOZ_DIAGNOSTIC_ASSERT(mState == Closing);
MOZ_DIAGNOSTIC_ASSERT(!mContext);
nsCOMPtr<nsIThread> ioThread;
mIOThread.swap(ioThread);
@@ -1814,7 +1818,7 @@ void
Manager::Abort()
{
NS_ASSERT_OWNINGTHREAD(Manager);
MOZ_ASSERT(mContext);
MOZ_DIAGNOSTIC_ASSERT(mContext);
// Note that we are closing to prevent any new requests from coming in and
// creating a new Context. We must ensure all Contexts and IO operations are
@@ -1868,8 +1872,8 @@ Manager::SetCacheIdOrphanedIfRefed(CacheId aCacheId)
NS_ASSERT_OWNINGTHREAD(Manager);
for (uint32_t i = 0; i < mCacheIdRefs.Length(); ++i) {
if (mCacheIdRefs[i].mCacheId == aCacheId) {
MOZ_ASSERT(mCacheIdRefs[i].mCount > 0);
MOZ_ASSERT(!mCacheIdRefs[i].mOrphaned);
MOZ_DIAGNOSTIC_ASSERT(mCacheIdRefs[i].mCount > 0);
MOZ_DIAGNOSTIC_ASSERT(!mCacheIdRefs[i].mOrphaned);
mCacheIdRefs[i].mOrphaned = true;
return true;
}
@@ -1885,8 +1889,8 @@ Manager::SetBodyIdOrphanedIfRefed(const nsID& aBodyId)
NS_ASSERT_OWNINGTHREAD(Manager);
for (uint32_t i = 0; i < mBodyIdRefs.Length(); ++i) {
if (mBodyIdRefs[i].mBodyId == aBodyId) {
MOZ_ASSERT(mBodyIdRefs[i].mCount > 0);
MOZ_ASSERT(!mBodyIdRefs[i].mOrphaned);
MOZ_DIAGNOSTIC_ASSERT(mBodyIdRefs[i].mCount > 0);
MOZ_DIAGNOSTIC_ASSERT(!mBodyIdRefs[i].mOrphaned);
mBodyIdRefs[i].mOrphaned = true;
return true;
}

View File

@@ -52,7 +52,7 @@ ManagerId::ManagerId(nsIPrincipal* aPrincipal, const nsACString& aQuotaOrigin)
: mPrincipal(aPrincipal)
, mQuotaOrigin(aQuotaOrigin)
{
MOZ_ASSERT(mPrincipal);
MOZ_DIAGNOSTIC_ASSERT(mPrincipal);
}
ManagerId::~ManagerId()

View File

@@ -49,7 +49,7 @@ void
PrincipalVerifier::AddListener(Listener* aListener)
{
AssertIsOnBackgroundThread();
MOZ_ASSERT(aListener);
MOZ_DIAGNOSTIC_ASSERT(aListener);
MOZ_ASSERT(!mListenerList.Contains(aListener));
mListenerList.AppendElement(aListener);
}
@@ -58,7 +58,7 @@ void
PrincipalVerifier::RemoveListener(Listener* aListener)
{
AssertIsOnBackgroundThread();
MOZ_ASSERT(aListener);
MOZ_DIAGNOSTIC_ASSERT(aListener);
MOZ_ALWAYS_TRUE(mListenerList.RemoveElement(aListener));
}
@@ -71,8 +71,8 @@ PrincipalVerifier::PrincipalVerifier(Listener* aListener,
, mResult(NS_OK)
{
AssertIsOnBackgroundThread();
MOZ_ASSERT(mInitiatingThread);
MOZ_ASSERT(aListener);
MOZ_DIAGNOSTIC_ASSERT(mInitiatingThread);
MOZ_DIAGNOSTIC_ASSERT(aListener);
mListenerList.AppendElement(aListener);
}
@@ -83,11 +83,11 @@ PrincipalVerifier::~PrincipalVerifier()
// threads, its a race to see which thread de-refs us last. Therefore
// we cannot guarantee which thread we destruct on.
MOZ_ASSERT(mListenerList.IsEmpty());
MOZ_DIAGNOSTIC_ASSERT(mListenerList.IsEmpty());
// We should always be able to explicitly release the actor on the main
// thread.
MOZ_ASSERT(!mActor);
MOZ_DIAGNOSTIC_ASSERT(!mActor);
}
NS_IMETHODIMP
@@ -190,7 +190,7 @@ PrincipalVerifier::CompleteOnInitiatingThread()
}
// The listener must clear its reference in OnPrincipalVerified()
MOZ_ASSERT(mListenerList.IsEmpty());
MOZ_DIAGNOSTIC_ASSERT(mListenerList.IsEmpty());
}
void

View File

@@ -6,7 +6,6 @@
#include "mozilla/dom/cache/QuotaClient.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/dom/cache/Manager.h"
#include "mozilla/dom/quota/QuotaManager.h"
#include "mozilla/dom/quota/UsageInfo.h"
@@ -17,7 +16,6 @@
namespace {
using mozilla::DebugOnly;
using mozilla::dom::ContentParentId;
using mozilla::dom::cache::Manager;
using mozilla::dom::quota::Client;
@@ -55,7 +53,7 @@ GetBodyUsage(nsIFile* aDir, UsageInfo* aUsageInfo)
int64_t fileSize;
rv = file->GetFileSize(&fileSize);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
MOZ_ASSERT(fileSize >= 0);
MOZ_DIAGNOSTIC_ASSERT(fileSize >= 0);
aUsageInfo->AppendToFileUsage(fileSize);
}
@@ -90,10 +88,10 @@ public:
const nsACString& aOrigin,
UsageInfo* aUsageInfo) override
{
MOZ_ASSERT(aUsageInfo);
MOZ_DIAGNOSTIC_ASSERT(aUsageInfo);
QuotaManager* qm = QuotaManager::Get();
MOZ_ASSERT(qm);
MOZ_DIAGNOSTIC_ASSERT(qm);
nsCOMPtr<nsIFile> dir;
nsresult rv = qm->GetDirectoryForOrigin(aPersistenceType, aOrigin,
@@ -148,7 +146,7 @@ public:
int64_t fileSize;
rv = file->GetFileSize(&fileSize);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
MOZ_ASSERT(fileSize >= 0);
MOZ_DIAGNOSTIC_ASSERT(fileSize >= 0);
aUsageInfo->AppendToDatabaseUsage(fileSize);
continue;

View File

@@ -195,8 +195,8 @@ ReadStream::Inner::Inner(StreamControl* aControl, const nsID& aId,
, mOwningThread(NS_GetCurrentThread())
, mState(Open)
{
MOZ_ASSERT(mStream);
MOZ_ASSERT(mControl);
MOZ_DIAGNOSTIC_ASSERT(mStream);
MOZ_DIAGNOSTIC_ASSERT(mControl);
mControl->AddReadStream(this);
}
@@ -206,7 +206,7 @@ ReadStream::Inner::Serialize(CacheReadStreamOrVoid* aReadStreamOut,
ErrorResult& aRv)
{
MOZ_ASSERT(NS_GetCurrentThread() == mOwningThread);
MOZ_ASSERT(aReadStreamOut);
MOZ_DIAGNOSTIC_ASSERT(aReadStreamOut);
*aReadStreamOut = CacheReadStream();
Serialize(&aReadStreamOut->get_CacheReadStream(), aStreamCleanupList, aRv);
}
@@ -217,20 +217,20 @@ ReadStream::Inner::Serialize(CacheReadStream* aReadStreamOut,
ErrorResult& aRv)
{
MOZ_ASSERT(NS_GetCurrentThread() == mOwningThread);
MOZ_ASSERT(aReadStreamOut);
MOZ_DIAGNOSTIC_ASSERT(aReadStreamOut);
if (mState != Open) {
aRv.ThrowTypeError<MSG_CACHE_STREAM_CLOSED>();
return;
}
MOZ_ASSERT(mControl);
MOZ_DIAGNOSTIC_ASSERT(mControl);
aReadStreamOut->id() = mId;
mControl->SerializeControl(aReadStreamOut);
mControl->SerializeStream(aReadStreamOut, mStream, aStreamCleanupList);
MOZ_ASSERT(aReadStreamOut->stream().type() ==
MOZ_DIAGNOSTIC_ASSERT(aReadStreamOut->stream().type() ==
IPCStream::TInputStreamParamsWithFds);
// We're passing ownership across the IPC barrier with the control, so
@@ -292,7 +292,7 @@ nsresult
ReadStream::Inner::Read(char* aBuf, uint32_t aCount, uint32_t* aNumReadOut)
{
// stream ops can happen on any thread
MOZ_ASSERT(aNumReadOut);
MOZ_DIAGNOSTIC_ASSERT(aNumReadOut);
nsresult rv = mSnappyStream->Read(aBuf, aCount, aNumReadOut);
@@ -311,7 +311,7 @@ ReadStream::Inner::ReadSegments(nsWriteSegmentFun aWriter, void* aClosure,
uint32_t aCount, uint32_t* aNumReadOut)
{
// stream ops can happen on any thread
MOZ_ASSERT(aNumReadOut);
MOZ_DIAGNOSTIC_ASSERT(aNumReadOut);
if (aCount) {
mHasEverBeenRead = true;
@@ -346,8 +346,8 @@ ReadStream::Inner::IsNonBlocking(bool* aNonBlockingOut)
ReadStream::Inner::~Inner()
{
// Any thread
MOZ_ASSERT(mState == Closed);
MOZ_ASSERT(!mControl);
MOZ_DIAGNOSTIC_ASSERT(mState == Closed);
MOZ_DIAGNOSTIC_ASSERT(!mControl);
}
void
@@ -396,7 +396,7 @@ ReadStream::Inner::NoteClosedOnOwningThread()
return;
}
MOZ_ASSERT(mControl);
MOZ_DIAGNOSTIC_ASSERT(mControl);
mControl->NoteClosed(this, mId);
mControl = nullptr;
}
@@ -411,7 +411,7 @@ ReadStream::Inner::ForgetOnOwningThread()
return;
}
MOZ_ASSERT(mControl);
MOZ_DIAGNOSTIC_ASSERT(mControl);
mControl->ForgetReadStream(this);
mControl = nullptr;
}
@@ -442,7 +442,7 @@ ReadStream::Create(const CacheReadStream& aReadStream)
return nullptr;
}
MOZ_ASSERT(aReadStream.stream().type() ==
MOZ_DIAGNOSTIC_ASSERT(aReadStream.stream().type() ==
IPCStream::TInputStreamParamsWithFds);
// Control is guaranteed to survive this method as ActorDestroy() cannot
@@ -455,15 +455,15 @@ ReadStream::Create(const CacheReadStream& aReadStream)
auto actor = static_cast<CacheStreamControlParent*>(aReadStream.controlParent());
control = actor;
}
MOZ_ASSERT(control);
MOZ_DIAGNOSTIC_ASSERT(control);
nsCOMPtr<nsIInputStream> stream = DeserializeIPCStream(aReadStream.stream());
MOZ_ASSERT(stream);
MOZ_DIAGNOSTIC_ASSERT(stream);
// Currently we expect all cache read streams to be blocking file streams.
#ifdef DEBUG
#if !defined(RELEASE_OR_BETA)
nsCOMPtr<nsIAsyncInputStream> asyncStream = do_QueryInterface(stream);
MOZ_ASSERT(!asyncStream);
MOZ_DIAGNOSTIC_ASSERT(!asyncStream);
#endif
RefPtr<Inner> inner = new Inner(control, aReadStream.id(), stream);
@@ -476,7 +476,7 @@ already_AddRefed<ReadStream>
ReadStream::Create(PCacheStreamControlParent* aControl, const nsID& aId,
nsIInputStream* aStream)
{
MOZ_ASSERT(aControl);
MOZ_DIAGNOSTIC_ASSERT(aControl);
auto actor = static_cast<CacheStreamControlParent*>(aControl);
RefPtr<Inner> inner = new Inner(actor, aId, aStream);
RefPtr<ReadStream> ref = new ReadStream(inner);
@@ -502,7 +502,7 @@ ReadStream::Serialize(CacheReadStream* aReadStreamOut,
ReadStream::ReadStream(ReadStream::Inner* aInner)
: mInner(aInner)
{
MOZ_ASSERT(mInner);
MOZ_DIAGNOSTIC_ASSERT(mInner);
}
ReadStream::~ReadStream()

View File

@@ -14,7 +14,7 @@ void
StreamControl::AddReadStream(ReadStream::Controllable* aReadStream)
{
AssertOwningThread();
MOZ_ASSERT(aReadStream);
MOZ_DIAGNOSTIC_ASSERT(aReadStream);
MOZ_ASSERT(!mReadStreamList.Contains(aReadStream));
mReadStreamList.AppendElement(aReadStream);
}
@@ -38,14 +38,16 @@ StreamControl::NoteClosed(ReadStream::Controllable* aReadStream,
StreamControl::~StreamControl()
{
// owning thread only, but can't call virtual AssertOwningThread in destructor
MOZ_ASSERT(mReadStreamList.IsEmpty());
MOZ_DIAGNOSTIC_ASSERT(mReadStreamList.IsEmpty());
}
void
StreamControl::CloseReadStreams(const nsID& aId)
{
AssertOwningThread();
DebugOnly<uint32_t> closedCount = 0;
#if !defined(RELEASE_OR_BETA)
uint32_t closedCount = 0;
#endif
ReadStreamList::ForwardIterator iter(mReadStreamList);
while (iter.HasMore()) {
@@ -56,7 +58,7 @@ StreamControl::CloseReadStreams(const nsID& aId)
}
}
MOZ_ASSERT(closedCount > 0);
MOZ_DIAGNOSTIC_ASSERT(closedCount > 0);
}
void

View File

@@ -22,7 +22,7 @@ StreamList::StreamList(Manager* aManager, Context* aContext)
, mStreamControl(nullptr)
, mActivated(false)
{
MOZ_ASSERT(mManager);
MOZ_DIAGNOSTIC_ASSERT(mManager);
mContext->AddActivity(this);
}
@@ -30,13 +30,13 @@ void
StreamList::SetStreamControl(CacheStreamControlParent* aStreamControl)
{
NS_ASSERT_OWNINGTHREAD(StreamList);
MOZ_ASSERT(aStreamControl);
MOZ_DIAGNOSTIC_ASSERT(aStreamControl);
// For cases where multiple streams are serialized for a single list
// then the control will get passed multiple times. This is ok, but
// it should be the same control each time.
if (mStreamControl) {
MOZ_ASSERT(aStreamControl == mStreamControl);
MOZ_DIAGNOSTIC_ASSERT(aStreamControl == mStreamControl);
return;
}
@@ -48,8 +48,8 @@ void
StreamList::RemoveStreamControl(CacheStreamControlParent* aStreamControl)
{
NS_ASSERT_OWNINGTHREAD(StreamList);
MOZ_ASSERT(mStreamControl);
MOZ_ASSERT(mStreamControl == aStreamControl);
MOZ_DIAGNOSTIC_ASSERT(mStreamControl);
MOZ_DIAGNOSTIC_ASSERT(mStreamControl == aStreamControl);
mStreamControl = nullptr;
}
@@ -57,8 +57,8 @@ void
StreamList::Activate(CacheId aCacheId)
{
NS_ASSERT_OWNINGTHREAD(StreamList);
MOZ_ASSERT(!mActivated);
MOZ_ASSERT(mCacheId == INVALID_CACHE_ID);
MOZ_DIAGNOSTIC_ASSERT(!mActivated);
MOZ_DIAGNOSTIC_ASSERT(mCacheId == INVALID_CACHE_ID);
mActivated = true;
mCacheId = aCacheId;
mManager->AddRefCacheId(mCacheId);
@@ -74,8 +74,8 @@ StreamList::Add(const nsID& aId, nsIInputStream* aStream)
{
// All streams should be added on IO thread before we set the stream
// control on the owning IPC thread.
MOZ_ASSERT(!mStreamControl);
MOZ_ASSERT(aStream);
MOZ_DIAGNOSTIC_ASSERT(!mStreamControl);
MOZ_DIAGNOSTIC_ASSERT(aStream);
Entry* entry = mList.AppendElement();
entry->mId = aId;
entry->mStream = aStream;
@@ -159,7 +159,7 @@ StreamList::MatchesCacheId(CacheId aCacheId) const
StreamList::~StreamList()
{
NS_ASSERT_OWNINGTHREAD(StreamList);
MOZ_ASSERT(!mStreamControl);
MOZ_DIAGNOSTIC_ASSERT(!mStreamControl);
if (mActivated) {
mManager->RemoveStreamList(this);
for (uint32_t i = 0; i < mList.Length(); ++i) {

View File

@@ -65,7 +65,7 @@ HasVaryStar(mozilla::dom::InternalHeaders* aHeaders)
void
ToHeadersEntryList(nsTArray<HeadersEntry>& aOut, InternalHeaders* aHeaders)
{
MOZ_ASSERT(aHeaders);
MOZ_DIAGNOSTIC_ASSERT(aHeaders);
AutoTArray<InternalHeaders::Entry, 16> entryList;
aHeaders->GetEntries(entryList);
@@ -121,7 +121,7 @@ TypeUtils::ToCacheRequest(CacheRequest& aOut, InternalRequest* aIn,
nsTArray<UniquePtr<AutoIPCStream>>& aStreamCleanupList,
ErrorResult& aRv)
{
MOZ_ASSERT(aIn);
MOZ_DIAGNOSTIC_ASSERT(aIn);
aIn->GetMethod(aOut.method());
nsCString url(aIn->GetURLWithoutFragment());
bool schemeValid;
@@ -142,7 +142,7 @@ TypeUtils::ToCacheRequest(CacheRequest& aOut, InternalRequest* aIn,
aIn->GetReferrer(aOut.referrer());
aOut.referrerPolicy() = aIn->ReferrerPolicy_();
RefPtr<InternalHeaders> headers = aIn->Headers();
MOZ_ASSERT(headers);
MOZ_DIAGNOSTIC_ASSERT(headers);
ToHeadersEntryList(aOut.headers(), headers);
aOut.headersGuard() = headers->Guard();
aOut.mode() = aIn->Mode();
@@ -179,7 +179,7 @@ TypeUtils::ToCacheResponseWithoutBody(CacheResponse& aOut,
aIn.GetURLList(urlList);
for (uint32_t i = 0; i < aOut.urlList().Length(); i++) {
MOZ_ASSERT(!aOut.urlList()[i].IsEmpty());
MOZ_DIAGNOSTIC_ASSERT(!aOut.urlList()[i].IsEmpty());
// Pass all Response URL schemes through... The spec only requires we take
// action on invalid schemes for Request objects.
ProcessURL(aOut.urlList()[i], nullptr, nullptr, nullptr, aRv);
@@ -188,7 +188,7 @@ TypeUtils::ToCacheResponseWithoutBody(CacheResponse& aOut,
aOut.status() = aIn.GetUnfilteredStatus();
aOut.statusText() = aIn.GetUnfilteredStatusText();
RefPtr<InternalHeaders> headers = aIn.UnfilteredHeaders();
MOZ_ASSERT(headers);
MOZ_DIAGNOSTIC_ASSERT(headers);
if (HasVaryStar(headers)) {
aRv.ThrowTypeError<MSG_RESPONSE_HAS_VARY_STAR>();
return;
@@ -267,9 +267,9 @@ TypeUtils::ToResponse(const CacheResponse& aIn)
// Be careful to fill the headers before setting the guard in order to
// correctly re-create the original headers.
ir->Headers()->Fill(*internalHeaders, result);
MOZ_ASSERT(!result.Failed());
MOZ_DIAGNOSTIC_ASSERT(!result.Failed());
ir->Headers()->SetGuard(aIn.headersGuard(), result);
MOZ_ASSERT(!result.Failed());
MOZ_DIAGNOSTIC_ASSERT(!result.Failed());
ir->InitChannelInfo(aIn.channelInfo());
if (aIn.principalInfo().type() == mozilla::ipc::OptionalPrincipalInfo::TPrincipalInfo) {
@@ -299,7 +299,7 @@ TypeUtils::ToResponse(const CacheResponse& aIn)
default:
MOZ_CRASH("Unexpected ResponseType!");
}
MOZ_ASSERT(ir);
MOZ_DIAGNOSTIC_ASSERT(ir);
RefPtr<Response> ref = new Response(GetGlobalObject(), ir);
return ref.forget();
@@ -328,10 +328,10 @@ TypeUtils::ToInternalRequest(const CacheRequest& aIn)
// Be careful to fill the headers before setting the guard in order to
// correctly re-create the original headers.
internalRequest->Headers()->Fill(*internalHeaders, result);
MOZ_ASSERT(!result.Failed());
MOZ_DIAGNOSTIC_ASSERT(!result.Failed());
internalRequest->Headers()->SetGuard(aIn.headersGuard(), result);
MOZ_ASSERT(!result.Failed());
MOZ_DIAGNOSTIC_ASSERT(!result.Failed());
nsCOMPtr<nsIInputStream> stream = ReadStream::Create(aIn.body());
@@ -410,7 +410,7 @@ TypeUtils::ProcessURL(nsACString& aUrl, bool* aSchemeValidOut,
return;
}
MOZ_ASSERT(aUrlQueryOut);
MOZ_DIAGNOSTIC_ASSERT(aUrlQueryOut);
if (queryLen < 0) {
*aUrlWithoutQueryOut = aUrl;
@@ -429,7 +429,7 @@ void
TypeUtils::CheckAndSetBodyUsed(Request* aRequest, BodyAction aBodyAction,
ErrorResult& aRv)
{
MOZ_ASSERT(aRequest);
MOZ_DIAGNOSTIC_ASSERT(aRequest);
if (aBodyAction == IgnoreBody) {
return;
@@ -461,7 +461,7 @@ TypeUtils::ToInternalRequest(const nsAString& aIn, ErrorResult& aRv)
}
JSContext* cx = jsapi.cx();
GlobalObject global(cx, GetGlobalObject()->GetGlobalJSObject());
MOZ_ASSERT(!global.Failed());
MOZ_DIAGNOSTIC_ASSERT(!global.Failed());
RefPtr<Request> request = Request::Constructor(global, requestOrString,
RequestInit(), aRv);

View File

@@ -558,7 +558,7 @@ protected:
/** The list of controls (form.elements as well as stuff not in elements) */
RefPtr<HTMLFormControlsCollection> mControls;
/** The currently selected radio button of each group */
nsRefPtrHashtable<nsStringCaseInsensitiveHashKey, HTMLInputElement> mSelectedRadioButtons;
nsRefPtrHashtable<nsStringHashKey, HTMLInputElement> mSelectedRadioButtons;
/** The number of required radio button of each group */
nsDataHashtable<nsStringCaseInsensitiveHashKey,uint32_t> mRequiredRadioButtonCounts;
/** The value missing state of each group */

View File

@@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "domstubs.idl"
#include "nsIRequest.idl"
interface mozIDOMWindow;
interface nsPIDOMWindowInner;
@@ -98,7 +99,10 @@ interface nsIServiceWorkerManager : nsISupports
*
* Returns a Promise.
*/
nsISupports register(in mozIDOMWindow aWindow, in nsIURI aScope, in nsIURI aScriptURI);
nsISupports register(in mozIDOMWindow aWindow,
in nsIURI aScope,
in nsIURI aScriptURI,
in nsLoadFlags aLoadFlags);
/**
* Unregister an existing ServiceWorker registration for `aScope`.

View File

@@ -315,6 +315,6 @@ LargeAllocationSuccess=This page was loaded in a new process due to a Large-Allo
# LOCALIZATION NOTE: Do not translate "Large-Allocation", as it is a literal header name. Do not translate GET.
LargeAllocationNonGetRequest=A Large-Allocation header was ignored due to the load being triggered by a non-GET request.
# LOCALIZATION NOTE: Do not translate "Large-Allocation", as it is a literal header name. Do not translate `window.opener`.
LargeAllocationRelatedBrowsingContexts=A Large-Allocation header was ignored due to the presence of windows which have a reference to this browsing context through the frame hierarchy or window.opener.
LargeAllocationNotOnlyToplevelInTabGroup=A Large-Allocation header was ignored due to the presence of windows which have a reference to this browsing context through the frame hierarchy or window.opener.
# LOCALIZATION NOTE: Do not translate "Large-Allocation", as it is a literal header name
LargeAllocationNonE10S=A Large-Allocation header was ignored due to the document not being loaded out of process.

View File

@@ -4382,7 +4382,7 @@ QuotaManager::OpenDirectoryInternal(Nullable<PersistenceType> aPersistenceType,
}
}
for (uint32_t index : MakeRange(uint32_t(Client::TYPE_MAX))) {
for (uint32_t index : IntegerRange(uint32_t(Client::TYPE_MAX))) {
if (origins[index]) {
for (auto iter = origins[index]->Iter(); !iter.Done(); iter.Next()) {
MOZ_ASSERT(mClients[index]);

View File

@@ -42,4 +42,5 @@ partial interface ServiceWorkerContainer {
dictionary RegistrationOptions {
USVString scope;
boolean useCache;
};

View File

@@ -228,6 +228,7 @@ struct ScriptLoadInfo
, mExecutionScheduled(false)
, mExecutionResult(false)
, mCacheStatus(Uncached)
, mLoadFlags(nsIRequest::LOAD_NORMAL)
{ }
~ScriptLoadInfo()
@@ -290,6 +291,8 @@ struct ScriptLoadInfo
CacheStatus mCacheStatus;
nsLoadFlags mLoadFlags;
Maybe<bool> mMutedErrorFlag;
bool Finished() const
@@ -902,7 +905,7 @@ private:
ScriptLoadInfo& loadInfo = mLoadInfos[aIndex];
nsresult& rv = loadInfo.mLoadResult;
nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL;
nsLoadFlags loadFlags = loadInfo.mLoadFlags;
// Get the top-level worker.
WorkerPrivate* topWorkerPrivate = mWorkerPrivate;
@@ -926,13 +929,6 @@ private:
}
}
// If we are loading a script for a ServiceWorker then we must not
// try to intercept it. If the interception matches the current
// ServiceWorker's scope then we could deadlock the load.
if (mWorkerPrivate->IsServiceWorker()) {
loadFlags |= nsIChannel::LOAD_BYPASS_SERVICE_WORKER;
}
if (!channel) {
// Only top level workers' main script use the document charset for the
// script uri encoding. Otherwise, default encoding (UTF-8) is applied.
@@ -2252,6 +2248,7 @@ LoadMainScript(WorkerPrivate* aWorkerPrivate,
ScriptLoadInfo* info = loadInfos.AppendElement();
info->mURL = aScriptURL;
info->mLoadFlags = aWorkerPrivate->GetLoadFlags();
LoadAllScripts(aWorkerPrivate, loadInfos, true, aWorkerScriptType, aRv);
}
@@ -2277,6 +2274,7 @@ Load(WorkerPrivate* aWorkerPrivate,
for (uint32_t index = 0; index < urlCount; index++) {
loadInfos[index].mURL = aScriptURLs[index];
loadInfos[index].mLoadFlags = aWorkerPrivate->GetLoadFlags();
}
LoadAllScripts(aWorkerPrivate, loadInfos, false, aWorkerScriptType, aRv);

View File

@@ -207,9 +207,14 @@ ServiceWorkerContainer::Register(const nsAString& aScriptURL,
}
}
bool useCache = aOptions.mUseCache.WasPassed() && aOptions.mUseCache.Value();
nsLoadFlags loadFlags = useCache ? nsIRequest::LOAD_NORMAL
: nsIRequest::VALIDATE_ALWAYS;
// The spec says that the "client" passed to Register() must be the global
// where the ServiceWorkerContainer was retrieved from.
aRv = swm->Register(GetOwner(), scopeURI, scriptURI, getter_AddRefs(promise));
aRv = swm->Register(GetOwner(), scopeURI, scriptURI, loadFlags,
getter_AddRefs(promise));
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}

View File

@@ -171,11 +171,13 @@ ServiceWorkerInfo::UpdateState(ServiceWorkerState aState)
ServiceWorkerInfo::ServiceWorkerInfo(nsIPrincipal* aPrincipal,
const nsACString& aScope,
const nsACString& aScriptSpec,
const nsAString& aCacheName)
const nsAString& aCacheName,
nsLoadFlags aLoadFlags)
: mPrincipal(aPrincipal)
, mScope(aScope)
, mScriptSpec(aScriptSpec)
, mCacheName(aCacheName)
, mLoadFlags(aLoadFlags)
, mState(ServiceWorkerState::EndGuard_)
, mServiceWorkerID(GetNextID())
, mServiceWorkerPrivate(new ServiceWorkerPrivate(this))

View File

@@ -30,6 +30,7 @@ private:
const nsCString mScope;
const nsCString mScriptSpec;
const nsString mCacheName;
const nsLoadFlags mLoadFlags;
ServiceWorkerState mState;
PrincipalOriginAttributes mOriginAttributes;
@@ -103,7 +104,8 @@ public:
ServiceWorkerInfo(nsIPrincipal* aPrincipal,
const nsACString& aScope,
const nsACString& aScriptSpec,
const nsAString& aCacheName);
const nsAString& aCacheName,
nsLoadFlags aLoadFlags);
ServiceWorkerState
State() const
@@ -123,6 +125,12 @@ public:
return mCacheName;
}
nsLoadFlags
GetLoadFlags() const
{
return mLoadFlags;
}
uint64_t
ID() const
{

View File

@@ -187,6 +187,8 @@ PopulateRegistrationData(nsIPrincipal* aPrincipal,
aData.currentWorkerHandlesFetch() = aRegistration->GetActive()->HandlesFetch();
}
aData.loadFlags() = aRegistration->GetLoadFlags();
return NS_OK;
}
@@ -492,6 +494,7 @@ NS_IMETHODIMP
ServiceWorkerManager::Register(mozIDOMWindow* aWindow,
nsIURI* aScopeURI,
nsIURI* aScriptURI,
nsLoadFlags aLoadFlags,
nsISupports** aPromise)
{
AssertIsOnMainThread();
@@ -618,7 +621,7 @@ ServiceWorkerManager::Register(mozIDOMWindow* aWindow,
RefPtr<ServiceWorkerRegisterJob> job =
new ServiceWorkerRegisterJob(documentPrincipal, cleanedScope, spec,
loadGroup);
loadGroup, aLoadFlags);
job->AppendResultCallback(cb);
queue->ScheduleJob(job);
@@ -1682,12 +1685,16 @@ ServiceWorkerManager::LoadRegistration(
RefPtr<ServiceWorkerRegistrationInfo> registration =
GetRegistration(principal, aRegistration.scope());
if (!registration) {
registration = CreateNewRegistration(aRegistration.scope(), principal);
registration = CreateNewRegistration(aRegistration.scope(), principal,
aRegistration.loadFlags());
} else {
// If active worker script matches our expectations for a "current worker",
// then we are done.
// then we are done. Since scripts with the same URL might have different
// contents such as updated scripts or scripts with different LoadFlags, we
// use the CacheName to judje whether the two scripts are identical, where
// the CacheName is an UUID generated when a new script is found.
if (registration->GetActive() &&
registration->GetActive()->ScriptSpec() == aRegistration.currentWorkerURL()) {
registration->GetActive()->CacheName() == aRegistration.cacheName()) {
// No needs for updates.
return;
}
@@ -1696,9 +1703,11 @@ ServiceWorkerManager::LoadRegistration(
const nsCString& currentWorkerURL = aRegistration.currentWorkerURL();
if (!currentWorkerURL.IsEmpty()) {
registration->SetActive(
new ServiceWorkerInfo(registration->mPrincipal, registration->mScope,
currentWorkerURL, aRegistration.cacheName()));
new ServiceWorkerInfo(registration->mPrincipal,
registration->mScope,
currentWorkerURL,
aRegistration.cacheName(),
registration->GetLoadFlags()));
registration->GetActive()->SetHandlesFetch(aRegistration.currentWorkerHandlesFetch());
registration->GetActive()->SetActivateStateUncheckedWithoutEvent(ServiceWorkerState::Activated);
}
@@ -2649,7 +2658,8 @@ ServiceWorkerManager::SoftUpdate(const PrincipalOriginAttributes& aOriginAttribu
RefPtr<ServiceWorkerUpdateJob> job =
new ServiceWorkerUpdateJob(principal, registration->mScope,
newest->ScriptSpec(), nullptr);
newest->ScriptSpec(), nullptr,
registration->GetLoadFlags());
queue->ScheduleJob(job);
}
@@ -2733,7 +2743,8 @@ ServiceWorkerManager::Update(nsIPrincipal* aPrincipal,
// its argument."
RefPtr<ServiceWorkerUpdateJob> job =
new ServiceWorkerUpdateJob(aPrincipal, registration->mScope,
newest->ScriptSpec(), nullptr);
newest->ScriptSpec(), nullptr,
registration->GetLoadFlags());
RefPtr<UpdateJobCallback> cb = new UpdateJobCallback(aCallback);
job->AppendResultCallback(cb);
@@ -3073,7 +3084,8 @@ ServiceWorkerManager::GetRegistration(const nsACString& aScopeKey,
ServiceWorkerRegistrationInfo*
ServiceWorkerManager::CreateNewRegistration(const nsCString& aScope,
nsIPrincipal* aPrincipal)
nsIPrincipal* aPrincipal,
nsLoadFlags aLoadFlags)
{
#ifdef DEBUG
AssertIsOnMainThread();
@@ -3086,7 +3098,8 @@ ServiceWorkerManager::CreateNewRegistration(const nsCString& aScope,
MOZ_ASSERT(!tmp);
#endif
ServiceWorkerRegistrationInfo* registration = new ServiceWorkerRegistrationInfo(aScope, aPrincipal);
ServiceWorkerRegistrationInfo* registration =
new ServiceWorkerRegistrationInfo(aScope, aPrincipal, aLoadFlags);
// From now on ownership of registration is with
// mServiceWorkerRegistrationInfos.
AddScopeAndRegistration(aScope, registration);

View File

@@ -187,7 +187,9 @@ public:
GetRegistration(nsIPrincipal* aPrincipal, const nsACString& aScope) const;
ServiceWorkerRegistrationInfo*
CreateNewRegistration(const nsCString& aScope, nsIPrincipal* aPrincipal);
CreateNewRegistration(const nsCString& aScope,
nsIPrincipal* aPrincipal,
nsLoadFlags aLoadFlags);
void
RemoveRegistration(ServiceWorkerRegistrationInfo* aRegistration);

View File

@@ -1812,6 +1812,12 @@ ServiceWorkerPrivate::SpawnWorkerIfNeeded(WakeUpReason aWhy,
info.mLoadGroup = aLoadGroup;
info.mLoadFailedAsyncRunnable = aLoadFailedRunnable;
// If we are loading a script for a ServiceWorker then we must not
// try to intercept it. If the interception matches the current
// ServiceWorker's scope then we could deadlock the load.
info.mLoadFlags = mInfo->GetLoadFlags() |
nsIChannel::LOAD_BYPASS_SERVICE_WORKER;
rv = info.mBaseURI->GetHost(info.mDomain);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;

View File

@@ -15,9 +15,10 @@ namespace workers {
ServiceWorkerRegisterJob::ServiceWorkerRegisterJob(nsIPrincipal* aPrincipal,
const nsACString& aScope,
const nsACString& aScriptSpec,
nsILoadGroup* aLoadGroup)
nsILoadGroup* aLoadGroup,
nsLoadFlags aLoadFlags)
: ServiceWorkerUpdateJob(Type::Register, aPrincipal, aScope, aScriptSpec,
aLoadGroup)
aLoadGroup, aLoadFlags)
{
}
@@ -36,6 +37,9 @@ ServiceWorkerRegisterJob::AsyncExecute()
swm->GetRegistration(mPrincipal, mScope);
if (registration) {
bool isSameLoadFlags = registration->GetLoadFlags() == GetLoadFlags();
registration->SetLoadFlags(GetLoadFlags());
// If we are resurrecting an uninstalling registration, then persist
// it to disk again. We preemptively removed it earlier during
// unregister so that closing the window by shutting down the browser
@@ -45,13 +49,14 @@ ServiceWorkerRegisterJob::AsyncExecute()
}
registration->mPendingUninstall = false;
RefPtr<ServiceWorkerInfo> newest = registration->Newest();
if (newest && mScriptSpec.Equals(newest->ScriptSpec())) {
if (newest && mScriptSpec.Equals(newest->ScriptSpec()) && isSameLoadFlags) {
SetRegistration(registration);
Finish(NS_OK);
return;
}
} else {
registration = swm->CreateNewRegistration(mScope, mPrincipal);
registration = swm->CreateNewRegistration(mScope, mPrincipal,
GetLoadFlags());
}
SetRegistration(registration);

View File

@@ -22,7 +22,8 @@ public:
ServiceWorkerRegisterJob(nsIPrincipal* aPrincipal,
const nsACString& aScope,
const nsACString& aScriptSpec,
nsILoadGroup* aLoadGroup);
nsILoadGroup* aLoadGroup,
nsLoadFlags aLoadFlags);
private:
// Implement the Register algorithm steps and then call the parent class

View File

@@ -41,6 +41,7 @@ namespace {
static const char* gSupportedRegistrarVersions[] = {
SERVICEWORKERREGISTRAR_VERSION,
"5",
"4",
"3",
"2"
@@ -364,6 +365,49 @@ ServiceWorkerRegistrar::ReadData()
nsAutoCString cacheName;
GET_LINE(cacheName);
CopyUTF8toUTF16(cacheName, entry->cacheName());
nsAutoCString loadFlags;
GET_LINE(loadFlags);
entry->loadFlags() = loadFlags.ToInteger(&rv, 16);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
} else if (entry->loadFlags() != nsIRequest::LOAD_NORMAL &&
entry->loadFlags() != nsIRequest::VALIDATE_ALWAYS) {
return NS_ERROR_INVALID_ARG;
}
} else if (version.EqualsLiteral("5")) {
overwrite = true;
dedupe = true;
nsAutoCString suffix;
GET_LINE(suffix);
PrincipalOriginAttributes attrs;
if (!attrs.PopulateFromSuffix(suffix)) {
return NS_ERROR_INVALID_ARG;
}
GET_LINE(entry->scope());
entry->principal() =
mozilla::ipc::ContentPrincipalInfo(attrs, entry->scope());
GET_LINE(entry->currentWorkerURL());
nsAutoCString fetchFlag;
GET_LINE(fetchFlag);
if (!fetchFlag.EqualsLiteral(SERVICEWORKERREGISTRAR_TRUE) &&
!fetchFlag.EqualsLiteral(SERVICEWORKERREGISTRAR_FALSE)) {
return NS_ERROR_INVALID_ARG;
}
entry->currentWorkerHandlesFetch() =
fetchFlag.EqualsLiteral(SERVICEWORKERREGISTRAR_TRUE);
nsAutoCString cacheName;
GET_LINE(cacheName);
CopyUTF8toUTF16(cacheName, entry->cacheName());
entry->loadFlags() = nsIRequest::VALIDATE_ALWAYS;
} else if (version.EqualsLiteral("4")) {
overwrite = true;
dedupe = true;
@@ -389,6 +433,8 @@ ServiceWorkerRegistrar::ReadData()
nsAutoCString cacheName;
GET_LINE(cacheName);
CopyUTF8toUTF16(cacheName, entry->cacheName());
entry->loadFlags() = nsIRequest::VALIDATE_ALWAYS;
} else if (version.EqualsLiteral("3")) {
overwrite = true;
dedupe = true;
@@ -417,6 +463,8 @@ ServiceWorkerRegistrar::ReadData()
nsAutoCString cacheName;
GET_LINE(cacheName);
CopyUTF8toUTF16(cacheName, entry->cacheName());
entry->loadFlags() = nsIRequest::VALIDATE_ALWAYS;
} else if (version.EqualsLiteral("2")) {
overwrite = true;
dedupe = true;
@@ -451,6 +499,8 @@ ServiceWorkerRegistrar::ReadData()
// waitingCacheName is no more used in latest version.
GET_LINE(unused);
entry->loadFlags() = nsIRequest::VALIDATE_ALWAYS;
} else {
MOZ_ASSERT_UNREACHABLE("Should never get here!");
}
@@ -747,6 +797,16 @@ ServiceWorkerRegistrar::WriteData()
buffer.Append(NS_ConvertUTF16toUTF8(data[i].cacheName()));
buffer.Append('\n');
buffer.AppendInt(data[i].loadFlags(), 16);
buffer.Append('\n');
MOZ_DIAGNOSTIC_ASSERT(data[i].loadFlags() == nsIRequest::LOAD_NORMAL ||
data[i].loadFlags() == nsIRequest::VALIDATE_ALWAYS);
static_assert(nsIRequest::LOAD_NORMAL == 0,
"LOAD_NORMAL matches serialized value.");
static_assert(nsIRequest::VALIDATE_ALWAYS == (1 << 11),
"VALIDATE_ALWAYS matches serialized value");
buffer.AppendLiteral(SERVICEWORKERREGISTRAR_TERMINATOR);
buffer.Append('\n');

View File

@@ -16,7 +16,7 @@
#include "nsTArray.h"
#define SERVICEWORKERREGISTRAR_FILE "serviceworker.txt"
#define SERVICEWORKERREGISTRAR_VERSION "5"
#define SERVICEWORKERREGISTRAR_VERSION "6"
#define SERVICEWORKERREGISTRAR_TERMINATOR "#"
#define SERVICEWORKERREGISTRAR_TRUE "true"
#define SERVICEWORKERREGISTRAR_FALSE "false"

View File

@@ -18,6 +18,8 @@ struct ServiceWorkerRegistrationData
nsString cacheName;
PrincipalInfo principal;
uint32_t loadFlags;
};
} // namespace dom

View File

@@ -73,10 +73,12 @@ ServiceWorkerRegistrationInfo::Clear()
}
ServiceWorkerRegistrationInfo::ServiceWorkerRegistrationInfo(const nsACString& aScope,
nsIPrincipal* aPrincipal)
nsIPrincipal* aPrincipal,
nsLoadFlags aLoadFlags)
: mControlledDocumentsCounter(0)
, mUpdateState(NoUpdate)
, mLastUpdateCheckTime(0)
, mLoadFlags(aLoadFlags)
, mScope(aScope)
, mPrincipal(aPrincipal)
, mPendingUninstall(false)
@@ -548,4 +550,16 @@ ServiceWorkerRegistrationInfo::IsIdle() const
return !mActiveWorker || mActiveWorker->WorkerPrivate()->IsIdle();
}
nsLoadFlags
ServiceWorkerRegistrationInfo::GetLoadFlags() const
{
return mLoadFlags;
}
void
ServiceWorkerRegistrationInfo::SetLoadFlags(nsLoadFlags aLoadFlags)
{
mLoadFlags = aLoadFlags;
}
END_WORKERS_NAMESPACE

View File

@@ -27,6 +27,8 @@ class ServiceWorkerRegistrationInfo final
uint64_t mLastUpdateCheckTime;
nsLoadFlags mLoadFlags;
RefPtr<ServiceWorkerInfo> mEvaluatingWorker;
RefPtr<ServiceWorkerInfo> mActiveWorker;
RefPtr<ServiceWorkerInfo> mWaitingWorker;
@@ -50,7 +52,8 @@ public:
bool mPendingUninstall;
ServiceWorkerRegistrationInfo(const nsACString& aScope,
nsIPrincipal* aPrincipal);
nsIPrincipal* aPrincipal,
nsLoadFlags aLoadFlags);
already_AddRefed<ServiceWorkerInfo>
Newest() const
@@ -173,6 +176,12 @@ public:
bool
IsIdle() const;
nsLoadFlags
GetLoadFlags() const;
void
SetLoadFlags(nsLoadFlags aLoadFlags);
private:
enum TransitionType {
TransitionToNextState = 0,

View File

@@ -312,6 +312,12 @@ public:
return copy.forget();
}
void
SaveLoadFlags(nsLoadFlags aLoadFlags)
{
mCallback->SaveLoadFlags(aLoadFlags);
}
void
NetworkFinished(nsresult aStatus)
{
@@ -626,10 +632,14 @@ CompareNetwork::Initialize(nsIPrincipal* aPrincipal, const nsAString& aURL, nsIL
nsLoadFlags flags = nsIChannel::LOAD_BYPASS_SERVICE_WORKER;
RefPtr<ServiceWorkerRegistrationInfo> registration =
mManager->GetRegistration();
flags |= registration->GetLoadFlags();
if (registration->IsLastUpdateCheckTimeOverOneDay()) {
flags |= nsIRequest::LOAD_BYPASS_CACHE;
}
// Save the load flags for propagating to ServiceWorkerInfo.
mManager->SaveLoadFlags(flags);
// Note that because there is no "serviceworker" RequestContext type, we can
// use the TYPE_INTERNAL_SCRIPT content policy types when loading a service
// worker.

View File

@@ -41,6 +41,15 @@ public:
const nsAString& aNewCacheName,
const nsACString& aMaxScope) = 0;
/*
* Right before fetching the main script from the network, we check whether
* the script expiration timer has expired. Via this method, we can save the
* result of the check, and propogate it to the new ServiceWorkerInfo if there
* is one, so the imported scripts can be affected by the result as well.
*/
virtual void
SaveLoadFlags(nsLoadFlags aLoadFlags) = 0;
NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
};

View File

@@ -103,6 +103,12 @@ public:
mJob->ComparisonResult(aStatus, aInCacheAndEqual, aNewCacheName, aMaxScope);
}
virtual void
SaveLoadFlags(nsLoadFlags aLoadFlags) override
{
mJob->SetLoadFlags(aLoadFlags);
}
NS_INLINE_DECL_REFCOUNTING(ServiceWorkerUpdateJob::CompareCallback, override)
};
@@ -167,9 +173,11 @@ public:
ServiceWorkerUpdateJob::ServiceWorkerUpdateJob(nsIPrincipal* aPrincipal,
const nsACString& aScope,
const nsACString& aScriptSpec,
nsILoadGroup* aLoadGroup)
nsILoadGroup* aLoadGroup,
nsLoadFlags aLoadFlags)
: ServiceWorkerJob(Type::Update, aPrincipal, aScope, aScriptSpec)
, mLoadGroup(aLoadGroup)
, mLoadFlags(aLoadFlags)
{
}
@@ -185,9 +193,11 @@ ServiceWorkerUpdateJob::ServiceWorkerUpdateJob(Type aType,
nsIPrincipal* aPrincipal,
const nsACString& aScope,
const nsACString& aScriptSpec,
nsILoadGroup* aLoadGroup)
nsILoadGroup* aLoadGroup,
nsLoadFlags aLoadFlags)
: ServiceWorkerJob(aType, aPrincipal, aScope, aScriptSpec)
, mLoadGroup(aLoadGroup)
, mLoadFlags(aLoadFlags)
{
}
@@ -318,6 +328,18 @@ ServiceWorkerUpdateJob::Update()
}
}
nsLoadFlags
ServiceWorkerUpdateJob::GetLoadFlags() const
{
return mLoadFlags;
}
void
ServiceWorkerUpdateJob::SetLoadFlags(nsLoadFlags aLoadFlags)
{
mLoadFlags = aLoadFlags;
}
void
ServiceWorkerUpdateJob::ComparisonResult(nsresult aStatus,
bool aInCacheAndEqual,
@@ -415,7 +437,9 @@ ServiceWorkerUpdateJob::ComparisonResult(nsresult aStatus,
RefPtr<ServiceWorkerInfo> sw =
new ServiceWorkerInfo(mRegistration->mPrincipal,
mRegistration->mScope,
mScriptSpec, aNewCacheName);
mScriptSpec,
aNewCacheName,
mLoadFlags);
mRegistration->SetEvaluating(sw);

View File

@@ -25,7 +25,8 @@ public:
ServiceWorkerUpdateJob(nsIPrincipal* aPrincipal,
const nsACString& aScope,
const nsACString& aScriptSpec,
nsILoadGroup* aLoadGroup);
nsILoadGroup* aLoadGroup,
nsLoadFlags aLoadFlags);
already_AddRefed<ServiceWorkerRegistrationInfo>
GetRegistration() const;
@@ -36,7 +37,8 @@ protected:
nsIPrincipal* aPrincipal,
const nsACString& aScope,
const nsACString& aScriptSpec,
nsILoadGroup* aLoadGroup);
nsILoadGroup* aLoadGroup,
nsLoadFlags aLoadFlags);
virtual ~ServiceWorkerUpdateJob();
@@ -66,6 +68,12 @@ protected:
void
Update();
nsLoadFlags
GetLoadFlags() const;
void
SetLoadFlags(nsLoadFlags aLoadFlags);
private:
class CompareCallback;
class ContinueUpdateRunnable;
@@ -92,6 +100,8 @@ private:
ContinueAfterInstallEvent(bool aInstallEventSuccess);
nsCOMPtr<nsILoadGroup> mLoadGroup;
nsLoadFlags mLoadFlags;
RefPtr<ServiceWorkerRegistrationInfo> mRegistration;
};

View File

@@ -1609,7 +1609,8 @@ TimerThreadEventTarget::IsOnCurrentThread(bool* aIsOnCurrentThread)
NS_IMPL_ISUPPORTS(TimerThreadEventTarget, nsIEventTarget)
WorkerLoadInfo::WorkerLoadInfo()
: mWindowID(UINT64_MAX)
: mLoadFlags(nsIRequest::LOAD_NORMAL)
, mWindowID(UINT64_MAX)
, mServiceWorkerID(0)
, mReferrerPolicy(net::RP_Unset)
, mFromWindow(false)
@@ -1666,6 +1667,7 @@ WorkerLoadInfo::StealFrom(WorkerLoadInfo& aOther)
mDomain = aOther.mDomain;
mServiceWorkerCacheName = aOther.mServiceWorkerCacheName;
mLoadFlags = aOther.mLoadFlags;
mWindowID = aOther.mWindowID;
mServiceWorkerID = aOther.mServiceWorkerID;
mReferrerPolicy = aOther.mReferrerPolicy;

View File

@@ -475,6 +475,12 @@ public:
return mLoadInfo.mFromWindow;
}
nsLoadFlags
GetLoadFlags() const
{
return mLoadInfo.mLoadFlags;
}
uint64_t
WindowID() const
{

View File

@@ -258,6 +258,7 @@ struct WorkerLoadInfo
nsString mServiceWorkerCacheName;
ChannelInfo mChannelInfo;
nsLoadFlags mLoadFlags;
uint64_t mWindowID;
uint64_t mServiceWorkerID;

View File

@@ -151,12 +151,16 @@ TEST(ServiceWorkerRegistrar, TestReadData)
buffer.Append("scope 0\ncurrentWorkerURL 0\n");
buffer.Append(SERVICEWORKERREGISTRAR_TRUE "\n");
buffer.Append("cacheName 0\n");
buffer.AppendInt(nsIRequest::LOAD_NORMAL, 16);
buffer.Append("\n");
buffer.Append(SERVICEWORKERREGISTRAR_TERMINATOR "\n");
buffer.Append("\n");
buffer.Append("scope 1\ncurrentWorkerURL 1\n");
buffer.Append(SERVICEWORKERREGISTRAR_FALSE "\n");
buffer.Append("cacheName 1\n");
buffer.AppendInt(nsIRequest::VALIDATE_ALWAYS, 16);
buffer.Append("\n");
buffer.Append(SERVICEWORKERREGISTRAR_TERMINATOR "\n");
ASSERT_TRUE(CreateFile(buffer)) << "CreateFile should not fail";
@@ -182,6 +186,7 @@ TEST(ServiceWorkerRegistrar, TestReadData)
ASSERT_STREQ("currentWorkerURL 0", data[0].currentWorkerURL().get());
ASSERT_TRUE(data[0].currentWorkerHandlesFetch());
ASSERT_STREQ("cacheName 0", NS_ConvertUTF16toUTF8(data[0].cacheName()).get());
ASSERT_EQ(nsIRequest::LOAD_NORMAL, data[0].loadFlags());
const mozilla::ipc::PrincipalInfo& info1 = data[1].principal();
ASSERT_EQ(info1.type(), mozilla::ipc::PrincipalInfo::TContentPrincipalInfo) << "First principal must be content";
@@ -196,6 +201,7 @@ TEST(ServiceWorkerRegistrar, TestReadData)
ASSERT_STREQ("currentWorkerURL 1", data[1].currentWorkerURL().get());
ASSERT_FALSE(data[1].currentWorkerHandlesFetch());
ASSERT_STREQ("cacheName 1", NS_ConvertUTF16toUTF8(data[1].cacheName()).get());
ASSERT_EQ(nsIRequest::VALIDATE_ALWAYS, data[1].loadFlags());
}
TEST(ServiceWorkerRegistrar, TestDeleteData)
@@ -225,8 +231,10 @@ TEST(ServiceWorkerRegistrar, TestWriteData)
reg.scope() = nsPrintfCString("scope write %d", i);
reg.currentWorkerURL() = nsPrintfCString("currentWorkerURL write %d", i);
reg.currentWorkerHandlesFetch() = true;
reg.cacheName() =
NS_ConvertUTF8toUTF16(nsPrintfCString("cacheName write %d", i));
reg.loadFlags() = nsIRequest::VALIDATE_ALWAYS;
nsAutoCString spec;
spec.AppendPrintf("spec write %d", i);
@@ -272,9 +280,13 @@ TEST(ServiceWorkerRegistrar, TestWriteData)
test.AppendPrintf("currentWorkerURL write %d", i);
ASSERT_STREQ(test.get(), data[i].currentWorkerURL().get());
ASSERT_EQ(true, data[i].currentWorkerHandlesFetch());
test.Truncate();
test.AppendPrintf("cacheName write %d", i);
ASSERT_STREQ(test.get(), NS_ConvertUTF16toUTF8(data[i].cacheName()).get());
ASSERT_EQ(nsIRequest::VALIDATE_ALWAYS, data[i].loadFlags());
}
}
@@ -311,7 +323,9 @@ TEST(ServiceWorkerRegistrar, TestVersion2Migration)
ASSERT_STREQ("scope 0", cInfo0.spec().get());
ASSERT_STREQ("scope 0", data[0].scope().get());
ASSERT_STREQ("currentWorkerURL 0", data[0].currentWorkerURL().get());
ASSERT_EQ(true, data[0].currentWorkerHandlesFetch());
ASSERT_STREQ("activeCache 0", NS_ConvertUTF16toUTF8(data[0].cacheName()).get());
ASSERT_EQ(nsIRequest::VALIDATE_ALWAYS, data[0].loadFlags());
const mozilla::ipc::PrincipalInfo& info1 = data[1].principal();
ASSERT_EQ(info1.type(), mozilla::ipc::PrincipalInfo::TContentPrincipalInfo) << "First principal must be content";
@@ -324,7 +338,9 @@ TEST(ServiceWorkerRegistrar, TestVersion2Migration)
ASSERT_STREQ("scope 1", cInfo1.spec().get());
ASSERT_STREQ("scope 1", data[1].scope().get());
ASSERT_STREQ("currentWorkerURL 1", data[1].currentWorkerURL().get());
ASSERT_EQ(true, data[1].currentWorkerHandlesFetch());
ASSERT_STREQ("activeCache 1", NS_ConvertUTF16toUTF8(data[1].cacheName()).get());
ASSERT_EQ(nsIRequest::VALIDATE_ALWAYS, data[1].loadFlags());
}
TEST(ServiceWorkerRegistrar, TestVersion3Migration)
@@ -360,7 +376,9 @@ TEST(ServiceWorkerRegistrar, TestVersion3Migration)
ASSERT_STREQ("scope 0", cInfo0.spec().get());
ASSERT_STREQ("scope 0", data[0].scope().get());
ASSERT_STREQ("currentWorkerURL 0", data[0].currentWorkerURL().get());
ASSERT_EQ(true, data[0].currentWorkerHandlesFetch());
ASSERT_STREQ("cacheName 0", NS_ConvertUTF16toUTF8(data[0].cacheName()).get());
ASSERT_EQ(nsIRequest::VALIDATE_ALWAYS, data[0].loadFlags());
const mozilla::ipc::PrincipalInfo& info1 = data[1].principal();
ASSERT_EQ(info1.type(), mozilla::ipc::PrincipalInfo::TContentPrincipalInfo) << "First principal must be content";
@@ -373,7 +391,9 @@ TEST(ServiceWorkerRegistrar, TestVersion3Migration)
ASSERT_STREQ("scope 1", cInfo1.spec().get());
ASSERT_STREQ("scope 1", data[1].scope().get());
ASSERT_STREQ("currentWorkerURL 1", data[1].currentWorkerURL().get());
ASSERT_EQ(true, data[1].currentWorkerHandlesFetch());
ASSERT_STREQ("cacheName 1", NS_ConvertUTF16toUTF8(data[1].cacheName()).get());
ASSERT_EQ(nsIRequest::VALIDATE_ALWAYS, data[1].loadFlags());
}
TEST(ServiceWorkerRegistrar, TestVersion4Migration)
@@ -410,8 +430,9 @@ TEST(ServiceWorkerRegistrar, TestVersion4Migration)
ASSERT_STREQ("scope 0", data[0].scope().get());
ASSERT_STREQ("currentWorkerURL 0", data[0].currentWorkerURL().get());
// default is true
ASSERT_EQ(true, data[1].currentWorkerHandlesFetch());
ASSERT_EQ(true, data[0].currentWorkerHandlesFetch());
ASSERT_STREQ("cacheName 0", NS_ConvertUTF16toUTF8(data[0].cacheName()).get());
ASSERT_EQ(nsIRequest::VALIDATE_ALWAYS, data[0].loadFlags());
const mozilla::ipc::PrincipalInfo& info1 = data[1].principal();
ASSERT_EQ(info1.type(), mozilla::ipc::PrincipalInfo::TContentPrincipalInfo) << "First principal must be content";
@@ -427,6 +448,64 @@ TEST(ServiceWorkerRegistrar, TestVersion4Migration)
// default is true
ASSERT_EQ(true, data[1].currentWorkerHandlesFetch());
ASSERT_STREQ("cacheName 1", NS_ConvertUTF16toUTF8(data[1].cacheName()).get());
ASSERT_EQ(nsIRequest::VALIDATE_ALWAYS, data[1].loadFlags());
}
TEST(ServiceWorkerRegistrar, TestVersion5Migration)
{
nsAutoCString buffer("5" "\n");
buffer.Append("^appId=123&inBrowser=1\n");
buffer.Append("scope 0\ncurrentWorkerURL 0\n");
buffer.Append(SERVICEWORKERREGISTRAR_TRUE "\n");
buffer.Append("cacheName 0\n");
buffer.Append(SERVICEWORKERREGISTRAR_TERMINATOR "\n");
buffer.Append("\n");
buffer.Append("scope 1\ncurrentWorkerURL 1\n");
buffer.Append(SERVICEWORKERREGISTRAR_FALSE "\n");
buffer.Append("cacheName 1\n");
buffer.Append(SERVICEWORKERREGISTRAR_TERMINATOR "\n");
ASSERT_TRUE(CreateFile(buffer)) << "CreateFile should not fail";
RefPtr<ServiceWorkerRegistrarTest> swr = new ServiceWorkerRegistrarTest;
nsresult rv = swr->TestReadData();
ASSERT_EQ(NS_OK, rv) << "ReadData() should not fail";
const nsTArray<ServiceWorkerRegistrationData>& data = swr->TestGetData();
ASSERT_EQ((uint32_t)2, data.Length()) << "2 entries should be found";
const mozilla::ipc::PrincipalInfo& info0 = data[0].principal();
ASSERT_EQ(info0.type(), mozilla::ipc::PrincipalInfo::TContentPrincipalInfo) << "First principal must be content";
const mozilla::ipc::ContentPrincipalInfo& cInfo0 = data[0].principal();
nsAutoCString suffix0;
cInfo0.attrs().CreateSuffix(suffix0);
ASSERT_STREQ("^appId=123&inBrowser=1", suffix0.get());
ASSERT_STREQ("scope 0", cInfo0.spec().get());
ASSERT_STREQ("scope 0", data[0].scope().get());
ASSERT_STREQ("currentWorkerURL 0", data[0].currentWorkerURL().get());
ASSERT_TRUE(data[0].currentWorkerHandlesFetch());
ASSERT_STREQ("cacheName 0", NS_ConvertUTF16toUTF8(data[0].cacheName()).get());
ASSERT_EQ(nsIRequest::VALIDATE_ALWAYS, data[0].loadFlags());
const mozilla::ipc::PrincipalInfo& info1 = data[1].principal();
ASSERT_EQ(info1.type(), mozilla::ipc::PrincipalInfo::TContentPrincipalInfo) << "First principal must be content";
const mozilla::ipc::ContentPrincipalInfo& cInfo1 = data[1].principal();
nsAutoCString suffix1;
cInfo1.attrs().CreateSuffix(suffix1);
ASSERT_STREQ("", suffix1.get());
ASSERT_STREQ("scope 1", cInfo1.spec().get());
ASSERT_STREQ("scope 1", data[1].scope().get());
ASSERT_STREQ("currentWorkerURL 1", data[1].currentWorkerURL().get());
ASSERT_FALSE(data[1].currentWorkerHandlesFetch());
ASSERT_STREQ("cacheName 1", NS_ConvertUTF16toUTF8(data[1].cacheName()).get());
ASSERT_EQ(nsIRequest::VALIDATE_ALWAYS, data[1].loadFlags());
}
TEST(ServiceWorkerRegistrar, TestDedupeRead)
@@ -476,7 +555,9 @@ TEST(ServiceWorkerRegistrar, TestDedupeRead)
ASSERT_STREQ("scope 0", cInfo0.spec().get());
ASSERT_STREQ("scope 0", data[0].scope().get());
ASSERT_STREQ("currentWorkerURL 0", data[0].currentWorkerURL().get());
ASSERT_EQ(true, data[0].currentWorkerHandlesFetch());
ASSERT_STREQ("cacheName 0", NS_ConvertUTF16toUTF8(data[0].cacheName()).get());
ASSERT_EQ(nsIRequest::VALIDATE_ALWAYS, data[0].loadFlags());
const mozilla::ipc::PrincipalInfo& info1 = data[1].principal();
ASSERT_EQ(info1.type(), mozilla::ipc::PrincipalInfo::TContentPrincipalInfo) << "First principal must be content";
@@ -489,7 +570,9 @@ TEST(ServiceWorkerRegistrar, TestDedupeRead)
ASSERT_STREQ("scope 1", cInfo1.spec().get());
ASSERT_STREQ("scope 1", data[1].scope().get());
ASSERT_STREQ("currentWorkerURL 1", data[1].currentWorkerURL().get());
ASSERT_EQ(true, data[1].currentWorkerHandlesFetch());
ASSERT_STREQ("cacheName 1", NS_ConvertUTF16toUTF8(data[1].cacheName()).get());
ASSERT_EQ(nsIRequest::VALIDATE_ALWAYS, data[1].loadFlags());
}
TEST(ServiceWorkerRegistrar, TestDedupeWrite)
@@ -502,8 +585,10 @@ TEST(ServiceWorkerRegistrar, TestDedupeWrite)
reg.scope() = NS_LITERAL_CSTRING("scope write dedupe");
reg.currentWorkerURL() = nsPrintfCString("currentWorkerURL write %d", i);
reg.currentWorkerHandlesFetch() = true;
reg.cacheName() =
NS_ConvertUTF8toUTF16(nsPrintfCString("cacheName write %d", i));
reg.loadFlags() = nsIRequest::VALIDATE_ALWAYS;
nsAutoCString spec;
spec.AppendPrintf("spec write dedupe/%d", i);
@@ -540,8 +625,10 @@ TEST(ServiceWorkerRegistrar, TestDedupeWrite)
ASSERT_STREQ("scope write dedupe", cInfo.spec().get());
ASSERT_STREQ("scope write dedupe", data[0].scope().get());
ASSERT_STREQ("currentWorkerURL write 9", data[0].currentWorkerURL().get());
ASSERT_EQ(true, data[0].currentWorkerHandlesFetch());
ASSERT_STREQ("cacheName write 9",
NS_ConvertUTF16toUTF8(data[0].cacheName()).get());
ASSERT_EQ(nsIRequest::VALIDATE_ALWAYS, data[0].loadFlags());
}
int main(int argc, char** argv) {

View File

@@ -69,5 +69,5 @@ load 1158651.html
load 1244894.xhtml
load 1264921.html
load 1272490.html
load 1317704.html
asserts-if(stylo,1-24) load 1317704.html # bug 1324663
load 1317718.html

View File

@@ -29,7 +29,7 @@ parent:
nsresult rv);
async ShowPrintDialog(PPrintSettingsDialog dialog,
PBrowser browser,
nullable PBrowser browser,
PrintData settings);
async PPrintProgressDialog();

View File

@@ -84,10 +84,16 @@ PrintingParent::ShowPrintDialog(PBrowserParent* aParent,
const PrintData& aData,
PrintData* aResult)
{
nsCOMPtr<nsPIDOMWindowOuter> parentWin = DOMWindowFromBrowserParent(aParent);
// If aParent is null this call is just being used to get print settings from
// the printer for print preview.
bool isPrintPreview = !aParent;
nsCOMPtr<nsPIDOMWindowOuter> parentWin;
if (aParent) {
parentWin = DOMWindowFromBrowserParent(aParent);
if (!parentWin) {
return NS_ERROR_FAILURE;
}
}
nsCOMPtr<nsIPrintingPromptService> pps(do_GetService("@mozilla.org/embedcomp/printingprompt-service;1"));
if (!pps) {
@@ -123,9 +129,9 @@ PrintingParent::ShowPrintDialog(PBrowserParent* aParent,
rv = settings->SetPrintSilent(printSilently);
NS_ENSURE_SUCCESS(rv, rv);
// If we are printing silently then we just need to initialize the print
// settings with anything specific from the printer.
if (printSilently ||
// If this is for print preview or we are printing silently then we just need
// to initialize the print settings with anything specific from the printer.
if (isPrintPreview || printSilently ||
Preferences::GetBool("print.always_print_silent", printSilently)) {
nsXPIDLString printerName;
rv = settings->GetPrinterName(getter_Copies(printerName));
@@ -138,8 +144,13 @@ PrintingParent::ShowPrintDialog(PBrowserParent* aParent,
NS_ENSURE_SUCCESS(rv, rv);
}
if (isPrintPreview) {
// For print preview we don't want a RemotePrintJob just the settings.
rv = mPrintSettingsSvc->SerializeToPrintData(settings, nullptr, aResult);
} else {
rv = SerializeAndEnsureRemotePrintJob(settings, nullptr, remotePrintJob,
aResult);
}
return rv;
}

View File

@@ -72,10 +72,13 @@ nsPrintingProxy::ShowPrintDialog(mozIDOMWindowProxy *parent,
nsIWebBrowserPrint *webBrowserPrint,
nsIPrintSettings *printSettings)
{
NS_ENSURE_ARG(parent);
NS_ENSURE_ARG(webBrowserPrint);
NS_ENSURE_ARG(printSettings);
// If parent is null we are just being called to retrieve the print settings
// from the printer in the parent for print preview.
TabChild* pBrowser = nullptr;
if (parent) {
// Get the TabChild for this nsIDOMWindow, which we can then pass up to
// the parent.
nsCOMPtr<nsPIDOMWindowOuter> pwin = nsPIDOMWindowOuter::From(parent);
@@ -86,7 +89,8 @@ nsPrintingProxy::ShowPrintDialog(mozIDOMWindowProxy *parent,
nsCOMPtr<nsITabChild> tabchild = docShell->GetTabChild();
NS_ENSURE_STATE(tabchild);
TabChild* pBrowser = static_cast<TabChild*>(tabchild.get());
pBrowser = static_cast<TabChild*>(tabchild.get());
}
// Next, serialize the nsIWebBrowserPrint and nsIPrintSettings we were given.
nsresult rv = NS_OK;

View File

@@ -679,7 +679,14 @@ public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFont)
virtual ~ScaledFont() {}
typedef void (*FontFileDataOutput)(const uint8_t* aData, uint32_t aLength, uint32_t aIndex, Float aGlyphSize, void* aBaton);
typedef struct {
uint32_t mTag;
Float mValue;
} VariationSetting;
typedef void (*FontFileDataOutput)(const uint8_t *aData, uint32_t aLength, uint32_t aIndex, Float aGlyphSize,
uint32_t aVariationCount, const VariationSetting* aVariations,
void *aBaton);
typedef void (*FontInstanceDataOutput)(const uint8_t* aData, uint32_t aLength, void* aBaton);
typedef void (*FontDescriptorOutput)(const uint8_t* aData, uint32_t aLength, Float aFontSize, void* aBaton);
@@ -1398,11 +1405,16 @@ public:
*
* @param aData Pointer to the data
* @param aSize Size of the TrueType data
* @param aVariationCount Number of VariationSetting records provided.
* @param aVariations Pointer to VariationSetting records.
* @param aType Type of NativeFontResource that should be created.
* @return a NativeFontResource of nullptr if failed.
*/
static already_AddRefed<NativeFontResource>
CreateNativeFontResource(uint8_t *aData, uint32_t aSize, FontType aType);
CreateNativeFontResource(uint8_t *aData, uint32_t aSize,
uint32_t aVariationCount,
const ScaledFont::VariationSetting* aVariations,
FontType aType);
/**
* This creates a scaled font of the given type based on font descriptor

View File

@@ -473,6 +473,10 @@ SetPaintPattern(SkPaint& aPaint, const Pattern& aPattern, Float aAlpha = 1.0, Po
case PatternType::SURFACE: {
const SurfacePattern& pat = static_cast<const SurfacePattern&>(aPattern);
sk_sp<SkImage> image = GetSkImageForSurface(pat.mSurface);
if (!image) {
aPaint.setColor(SK_ColorTRANSPARENT);
break;
}
SkMatrix mat;
GfxMatrixToSkiaMatrix(pat.mMatrix, mat);
@@ -486,11 +490,7 @@ SetPaintPattern(SkPaint& aPaint, const Pattern& aPattern, Float aAlpha = 1.0, Po
SkShader::TileMode xTileMode = ExtendModeToTileMode(pat.mExtendMode, Axis::X_AXIS);
SkShader::TileMode yTileMode = ExtendModeToTileMode(pat.mExtendMode, Axis::Y_AXIS);
if (image) {
aPaint.setShader(image->makeShader(xTileMode, yTileMode, &mat));
} else {
aPaint.setColor(SK_ColorTRANSPARENT);
}
if (pat.mSamplingFilter == SamplingFilter::POINT) {
aPaint.setFilterQuality(kNone_SkFilterQuality);

View File

@@ -502,6 +502,8 @@ Factory::CreateScaledFontForNativeFont(const NativeFont &aNativeFont, Float aSiz
already_AddRefed<NativeFontResource>
Factory::CreateNativeFontResource(uint8_t *aData, uint32_t aSize,
uint32_t aVariationCount,
const ScaledFont::VariationSetting* aVariations,
FontType aType)
{
switch (aType) {
@@ -526,7 +528,8 @@ Factory::CreateNativeFontResource(uint8_t *aData, uint32_t aSize,
/* aNeedsCairo = */ true);
}
#elif defined(XP_DARWIN)
return NativeFontResourceMac::Create(aData, aSize);
return NativeFontResourceMac::Create(aData, aSize,
aVariationCount, aVariations);
#elif defined(MOZ_WIDGET_GTK)
return NativeFontResourceFontconfig::Create(aData, aSize);
#else

View File

@@ -13,12 +13,146 @@
#include <CoreFoundation/CoreFoundation.h>
#endif
// Simple helper class to automatically release a CFObject when it goes out
// of scope.
template<class T>
class AutoRelease
{
public:
explicit AutoRelease(T aObject)
: mObject(aObject)
{
}
~AutoRelease()
{
if (mObject) {
CFRelease(mObject);
}
}
operator T()
{
return mObject;
}
T forget()
{
T obj = mObject;
mObject = nullptr;
return obj;
}
private:
T mObject;
};
// This is essentially identical to the similarly-named helper function
// in gfx/thebes/gfxMacFont.cpp. Maybe we should put it somewhere that
// can be shared by both Moz2d and Thebes callers?
static CFDictionaryRef
CreateVariationDictionaryOrNull(CGFontRef aCGFont, uint32_t aVariationCount,
const mozilla::gfx::ScaledFont::VariationSetting* aVariations)
{
AutoRelease<CTFontRef>
ctFont(CTFontCreateWithGraphicsFont(aCGFont, 0, nullptr, nullptr));
AutoRelease<CFArrayRef> axes(CTFontCopyVariationAxes(ctFont));
if (!axes) {
return nullptr;
}
CFIndex axisCount = CFArrayGetCount(axes);
AutoRelease<CFMutableDictionaryRef>
dict(CFDictionaryCreateMutable(kCFAllocatorDefault, axisCount,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
// Number of variation settings passed in the aVariations parameter.
// This will typically be a very low value, so we just linear-search them.
bool allDefaultValues = true;
for (CFIndex i = 0; i < axisCount; ++i) {
// We sanity-check the axis info found in the CTFont, and bail out
// (returning null) if it doesn't have the expected types.
CFTypeRef axisInfo = CFArrayGetValueAtIndex(axes, i);
if (CFDictionaryGetTypeID() != CFGetTypeID(axisInfo)) {
return nullptr;
}
CFDictionaryRef axis = static_cast<CFDictionaryRef>(axisInfo);
CFTypeRef axisTag =
CFDictionaryGetValue(axis, kCTFontVariationAxisIdentifierKey);
if (!axisTag || CFGetTypeID(axisTag) != CFNumberGetTypeID()) {
return nullptr;
}
int64_t tagLong;
if (!CFNumberGetValue(static_cast<CFNumberRef>(axisTag),
kCFNumberSInt64Type, &tagLong)) {
return nullptr;
}
CFTypeRef axisName =
CFDictionaryGetValue(axis, kCTFontVariationAxisNameKey);
if (!axisName || CFGetTypeID(axisName) != CFStringGetTypeID()) {
return nullptr;
}
// Clamp axis values to the supported range.
CFTypeRef min = CFDictionaryGetValue(axis, kCTFontVariationAxisMinimumValueKey);
CFTypeRef max = CFDictionaryGetValue(axis, kCTFontVariationAxisMaximumValueKey);
CFTypeRef def = CFDictionaryGetValue(axis, kCTFontVariationAxisDefaultValueKey);
if (!min || CFGetTypeID(min) != CFNumberGetTypeID() ||
!max || CFGetTypeID(max) != CFNumberGetTypeID() ||
!def || CFGetTypeID(def) != CFNumberGetTypeID()) {
return nullptr;
}
double minDouble;
double maxDouble;
double defDouble;
if (!CFNumberGetValue(static_cast<CFNumberRef>(min), kCFNumberDoubleType,
&minDouble) ||
!CFNumberGetValue(static_cast<CFNumberRef>(max), kCFNumberDoubleType,
&maxDouble) ||
!CFNumberGetValue(static_cast<CFNumberRef>(def), kCFNumberDoubleType,
&defDouble)) {
return nullptr;
}
double value = defDouble;
for (uint32_t j = 0; j < aVariationCount; ++j) {
if (aVariations[j].mTag == tagLong) {
value = std::min(std::max<double>(aVariations[j].mValue,
minDouble),
maxDouble);
if (value != defDouble) {
allDefaultValues = false;
}
break;
}
}
AutoRelease<CFNumberRef> valueNumber(CFNumberCreate(kCFAllocatorDefault,
kCFNumberDoubleType,
&value));
CFDictionaryAddValue(dict, axisName, valueNumber);
}
if (allDefaultValues) {
// We didn't actually set any non-default values, so throw away the
// variations dictionary and just use the default rendering.
return nullptr;
}
return dict.forget();
}
namespace mozilla {
namespace gfx {
/* static */
already_AddRefed<NativeFontResourceMac>
NativeFontResourceMac::Create(uint8_t *aFontData, uint32_t aDataLength)
NativeFontResourceMac::Create(uint8_t *aFontData, uint32_t aDataLength,
uint32_t aVariationCount,
const ScaledFont::VariationSetting* aVariations)
{
// copy font data
CFDataRef data = CFDataCreate(kCFAllocatorDefault, aFontData, aDataLength);
@@ -42,6 +176,20 @@ NativeFontResourceMac::Create(uint8_t *aFontData, uint32_t aDataLength)
return nullptr;
}
if (aVariationCount > 0) {
MOZ_ASSERT(aVariations);
AutoRelease<CFDictionaryRef>
varDict(CreateVariationDictionaryOrNull(fontRef, aVariationCount,
aVariations));
if (varDict) {
CGFontRef varFont = CGFontCreateCopyWithVariations(fontRef, varDict);
if (varFont) {
CFRelease(fontRef);
fontRef = varFont;
}
}
}
// passes ownership of fontRef to the NativeFontResourceMac instance
RefPtr<NativeFontResourceMac> fontResource =
new NativeFontResourceMac(fontRef);

View File

@@ -20,7 +20,9 @@ public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(NativeFontResourceMac)
static already_AddRefed<NativeFontResourceMac>
Create(uint8_t *aFontData, uint32_t aDataLength);
Create(uint8_t *aFontData, uint32_t aDataLength,
uint32_t aVariationCount,
const ScaledFont::VariationSetting* aVariations);
already_AddRefed<ScaledFont>
CreateScaledFont(uint32_t aIndex, Float aGlyphSize,

View File

@@ -1513,6 +1513,7 @@ RecordedSnapshot::OutputSimpleEventInfo(stringstream &aStringStream) const
RecordedFontData::~RecordedFontData()
{
delete[] mData;
delete[] mVariations;
}
bool
@@ -1520,6 +1521,7 @@ RecordedFontData::PlayEvent(Translator *aTranslator) const
{
RefPtr<NativeFontResource> fontResource =
Factory::CreateNativeFontResource(mData, mFontDetails.size,
mFontDetails.variationCount, mVariations,
aTranslator->GetDesiredFontType());
if (!fontResource) {
return false;
@@ -1537,6 +1539,8 @@ RecordedFontData::RecordToStream(std::ostream &aStream) const
WriteElement(aStream, mFontDetails.fontDataKey);
WriteElement(aStream, mFontDetails.size);
aStream.write((const char*)mData, mFontDetails.size);
WriteElement(aStream, mFontDetails.variationCount);
aStream.write((const char*)mVariations, mFontDetails.variationCount * sizeof(ScaledFont::VariationSetting));
}
void
@@ -1546,14 +1550,23 @@ RecordedFontData::OutputSimpleEventInfo(stringstream &aStringStream) const
}
void
RecordedFontData::SetFontData(const uint8_t *aData, uint32_t aSize, uint32_t aIndex, Float aGlyphSize)
RecordedFontData::SetFontData(const uint8_t *aData, uint32_t aSize, uint32_t aIndex,
Float aGlyphSize, uint32_t aVariationCount,
const ScaledFont::VariationSetting* aVariations)
{
mData = new uint8_t[aSize];
memcpy(mData, aData, aSize);
mFontDetails.fontDataKey = SFNTData::GetUniqueKey(aData, aSize);
uint32_t varDataSize = aVariationCount * sizeof(ScaledFont::VariationSetting);
mFontDetails.fontDataKey =
SFNTData::GetUniqueKey(aData, aSize, varDataSize, aVariations);
mFontDetails.size = aSize;
mFontDetails.index = aIndex;
mFontDetails.glyphSize = aGlyphSize;
mFontDetails.variationCount = aVariationCount;
if (aVariationCount > 0) {
mVariations = new ScaledFont::VariationSetting[aVariationCount];
memcpy(mVariations, aVariations, varDataSize);
}
}
bool
@@ -1567,16 +1580,26 @@ RecordedFontData::GetFontDetails(RecordedFontDetails& fontDetails)
fontDetails.size = mFontDetails.size;
fontDetails.glyphSize = mFontDetails.glyphSize;
fontDetails.index = mFontDetails.index;
fontDetails.variationCount = mFontDetails.variationCount;
return true;
}
RecordedFontData::RecordedFontData(istream &aStream)
: RecordedEvent(FONTDATA)
, mData(nullptr)
, mVariations(nullptr)
{
ReadElement(aStream, mFontDetails.fontDataKey);
ReadElement(aStream, mFontDetails.size);
mData = new uint8_t[mFontDetails.size];
aStream.read((char*)mData, mFontDetails.size);
ReadElement(aStream, mFontDetails.variationCount);
if (mFontDetails.variationCount > 0) {
mVariations = new ScaledFont::VariationSetting[mFontDetails.variationCount];
aStream.read((char*)mVariations, mFontDetails.variationCount * sizeof(ScaledFont::VariationSetting));
} else {
mVariations = nullptr;
}
}
RecordedFontDescriptor::~RecordedFontDescriptor()

View File

@@ -24,7 +24,7 @@ const uint32_t kMagicInt = 0xc001feed;
// loss of backwards compatibility. Old streams will not work in a player
// using a newer major revision. And new streams will not work in a player
// using an older major revision.
const uint16_t kMajorRevision = 6;
const uint16_t kMajorRevision = 7;
// A change in minor revision means additions of new events. New streams will
// not play in older players.
const uint16_t kMinorRevision = 0;
@@ -67,6 +67,7 @@ struct RecordedFontDetails
uint64_t fontDataKey;
uint32_t size;
uint32_t index;
uint32_t variationCount;
Float glyphSize;
};
@@ -1014,14 +1015,18 @@ class RecordedFontData : public RecordedEvent {
public:
static void FontDataProc(const uint8_t *aData, uint32_t aSize,
uint32_t aIndex, Float aGlyphSize, void* aBaton)
uint32_t aIndex, Float aGlyphSize,
uint32_t aVariationCount,
const ScaledFont::VariationSetting* aVariations,
void* aBaton)
{
auto recordedFontData = static_cast<RecordedFontData*>(aBaton);
recordedFontData->SetFontData(aData, aSize, aIndex, aGlyphSize);
recordedFontData->SetFontData(aData, aSize, aIndex, aGlyphSize,
aVariationCount, aVariations);
}
explicit RecordedFontData(ScaledFont *aScaledFont)
: RecordedEvent(FONTDATA), mData(nullptr)
: RecordedEvent(FONTDATA), mData(nullptr), mVariations(nullptr)
{
mGetFontFileDataSucceeded = aScaledFont->GetFontFileData(&FontDataProc, this);
}
@@ -1037,7 +1042,8 @@ public:
virtual ReferencePtr GetObjectRef() const { return nullptr; };
void SetFontData(const uint8_t *aData, uint32_t aSize, uint32_t aIndex,
Float aGlyphSize);
Float aGlyphSize, uint32_t aVariationCount,
const ScaledFont::VariationSetting* aVariations);
bool GetFontDetails(RecordedFontDetails& fontDetails);
@@ -1045,6 +1051,7 @@ private:
friend class RecordedEvent;
uint8_t* mData;
ScaledFont::VariationSetting* mVariations;
RecordedFontDetails mFontDetails;
bool mGetFontFileDataSucceeded;

View File

@@ -152,7 +152,8 @@ SFNTData::Create(const uint8_t *aFontData, uint32_t aDataLength)
/* static */
uint64_t
SFNTData::GetUniqueKey(const uint8_t *aFontData, uint32_t aDataLength)
SFNTData::GetUniqueKey(const uint8_t *aFontData, uint32_t aDataLength,
uint32_t aVarDataSize, const void* aVarData)
{
uint64_t hash;
UniquePtr<SFNTData> sfntData = SFNTData::Create(aFontData, aDataLength);
@@ -164,6 +165,10 @@ SFNTData::GetUniqueKey(const uint8_t *aFontData, uint32_t aDataLength)
hash = HashString(aFontData, aDataLength);
}
if (aVarDataSize) {
hash = AddToHash(hash, HashBytes(aVarData, aVarDataSize));
}
return hash << 32 | aDataLength;;
}

View File

@@ -31,13 +31,14 @@ public:
uint32_t aDataLength);
/**
* Creates a unique key for the given font data.
* Creates a unique key for the given font data and variation settings.
*
* @param aFontData the SFNT data
* @param aDataLength length
* @return unique key to be used for caching
*/
static uint64_t GetUniqueKey(const uint8_t *aFontData, uint32_t aDataLength);
static uint64_t GetUniqueKey(const uint8_t *aFontData, uint32_t aDataLength,
uint32_t aVarDataSize, const void* aVarData);
~SFNTData();

View File

@@ -257,7 +257,8 @@ ScaledFontDWrite::GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton
void *context;
stream->ReadFileFragment(&fragmentStart, 0, fileSize, &context);
aDataCallback((uint8_t*)fragmentStart, fileSize, mFontFace->GetIndex(), mSize, aBaton);
aDataCallback((uint8_t*)fragmentStart, fileSize, mFontFace->GetIndex(), mSize,
0, nullptr, aBaton);
stream->ReleaseFileFragment(context);

View File

@@ -58,7 +58,7 @@ ScaledFontFontconfig::GetFontFileData(FontFileDataOutput aDataCallback, void* aB
if (FT_Load_Sfnt_Table(face, 0, 0, nullptr, &length) == FT_Err_Ok) {
uint8_t* fontData = new uint8_t[length];
if (FT_Load_Sfnt_Table(face, 0, 0, fontData, &length) == FT_Err_Ok) {
aDataCallback(fontData, length, 0, mSize, aBaton);
aDataCallback(fontData, length, 0, mSize, 0, nullptr, aBaton);
success = true;
}
delete[] fontData;

View File

@@ -33,6 +33,33 @@ namespace gfx {
ScaledFontMac::CTFontDrawGlyphsFuncT* ScaledFontMac::CTFontDrawGlyphsPtr = nullptr;
bool ScaledFontMac::sSymbolLookupDone = false;
// Helper to create a CTFont from a CGFont, copying any variations that were
// set on the original CGFont.
static CTFontRef
CreateCTFontFromCGFontWithVariations(CGFontRef aCGFont, CGFloat aSize)
{
CFDictionaryRef vars = CGFontCopyVariations(aCGFont);
CTFontRef ctFont;
if (vars) {
CFDictionaryRef varAttr =
CFDictionaryCreate(nullptr,
(const void**)&kCTFontVariationAttribute,
(const void**)&vars, 1,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFRelease(vars);
CTFontDescriptorRef varDesc = CTFontDescriptorCreateWithAttributes(varAttr);
CFRelease(varAttr);
ctFont = CTFontCreateWithGraphicsFont(aCGFont, aSize, nullptr, varDesc);
CFRelease(varDesc);
} else {
ctFont = CTFontCreateWithGraphicsFont(aCGFont, aSize, nullptr, nullptr);
}
return ctFont;
}
ScaledFontMac::ScaledFontMac(CGFontRef aFont, Float aSize)
: ScaledFontBase(aSize)
{
@@ -46,7 +73,7 @@ ScaledFontMac::ScaledFontMac(CGFontRef aFont, Float aSize)
mFont = CGFontRetain(aFont);
if (CTFontDrawGlyphsPtr != nullptr) {
// only create mCTFont if we're going to be using the CTFontDrawGlyphs API
mCTFont = CTFontCreateWithGraphicsFont(aFont, aSize, nullptr, nullptr);
mCTFont = CreateCTFontFromCGFontWithVariations(aFont, aSize);
} else {
mCTFont = nullptr;
}
@@ -67,7 +94,7 @@ SkTypeface* ScaledFontMac::GetSkTypeface()
if (mCTFont) {
mTypeface = SkCreateTypefaceFromCTFont(mCTFont);
} else {
CTFontRef fontFace = CTFontCreateWithGraphicsFont(mFont, mSize, nullptr, nullptr);
CTFontRef fontFace = CreateCTFontFromCGFontWithVariations(mFont, mSize);
mTypeface = SkCreateTypefaceFromCTFont(fontFace);
CFRelease(fontFace);
}
@@ -159,6 +186,24 @@ struct writeBuf
int offset;
};
static void CollectVariationSetting(const void *key, const void *value, void *context)
{
auto keyPtr = static_cast<const CFTypeRef>(key);
auto valuePtr = static_cast<const CFTypeRef>(value);
auto vpp = static_cast<ScaledFont::VariationSetting**>(context);
if (CFGetTypeID(keyPtr) == CFNumberGetTypeID() &&
CFGetTypeID(valuePtr) == CFNumberGetTypeID()) {
uint64_t t;
double v;
if (CFNumberGetValue(static_cast<CFNumberRef>(keyPtr), kCFNumberSInt64Type, &t) &&
CFNumberGetValue(static_cast<CFNumberRef>(valuePtr), kCFNumberDoubleType, &v)) {
(*vpp)->mTag = t;
(*vpp)->mValue = v;
(*vpp)++;
}
}
}
bool
ScaledFontMac::GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton)
{
@@ -227,8 +272,26 @@ ScaledFontMac::GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton)
// set checkSumAdjust to the computed checksum
memcpy(&buf.data[checkSumAdjustmentOffset], &fontChecksum, sizeof(fontChecksum));
// Collect any variation settings that were incorporated into the CTFont.
uint32_t variationCount = 0;
VariationSetting* variations = nullptr;
if (mCTFont) {
CFDictionaryRef dict = CTFontCopyVariation(mCTFont);
if (dict) {
CFIndex count = CFDictionaryGetCount(dict);
if (count > 0) {
variations = new VariationSetting[count];
VariationSetting* vPtr = variations;
CFDictionaryApplyFunction(dict, CollectVariationSetting, &vPtr);
variationCount = vPtr - variations;
}
CFRelease(dict);
}
}
// we always use an index of 0
aDataCallback(buf.data, buf.offset, 0, mSize, aBaton);
aDataCallback(buf.data, buf.offset, 0, mSize, variationCount, variations, aBaton);
delete[] variations;
return true;

View File

@@ -77,7 +77,7 @@ ScaledFontWin::GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton)
}
}
aDataCallback(fontData.get(), tableSize, index, mSize, aBaton);
aDataCallback(fontData.get(), tableSize, index, mSize, 0, nullptr, aBaton);
return true;
}

Some files were not shown because too many files have changed in this diff Show More