Skip to content

Commit

Permalink
Merge inbound to mozilla-central. a=merge
Browse files Browse the repository at this point in the history
  • Loading branch information
nerli1 committed Mar 10, 2018
2 parents d807a6a + 3459045 commit 16adda4
Show file tree
Hide file tree
Showing 123 changed files with 2,390 additions and 756 deletions.
9 changes: 9 additions & 0 deletions browser/components/enterprisepolicies/Policies.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ var Policies = {
"Cookies": {
onBeforeUIStartup(manager, param) {
addAllowDenyPermissions("cookie", param.Allow, param.Block);

if (param.Block) {
const hosts = param.Block.map(uri => uri.host).sort().join("\n");
runOncePerModification("clearCookiesForBlockedHosts", hosts, () => {
for (let blocked of param.Block) {
Services.cookies.removeCookiesWithOriginAttributes("{}", blocked.host);
}
});
}
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,17 @@ this.EnterprisePolicyTesting = {
Services.obs.notifyObservers(null, "EnterprisePolicies:Restart");
return promise;
},

resetRunOnceState: function resetRunOnceState() {
const runOnceBaseKeys = [
"browser.policies.runonce.",
"browser.policies.runOncePerModification."
];
for (let base of runOnceBaseKeys) {
for (let key of Services.prefs.getChildList(base, {})) {
if (Services.prefs.prefHasUserValue(key))
Services.prefs.clearUserPref(key);
}
}
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ support-files =
[browser_policy_block_about_support.js]
[browser_policy_block_set_desktop_background.js]
[browser_policy_bookmarks.js]
[browser_policy_clear_blocked_cookies.js]
[browser_policy_default_browser_check.js]
[browser_policy_disable_formhistory.js]
[browser_policy_disable_fxaccounts.js]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";

add_task(async function setup() {
EnterprisePolicyTesting.resetRunOnceState();
const expiry = Date.now() + 24 * 60 * 60;
Services.cookies.add("example.com", "/", "secure", "true", true, false, false, expiry, {});
Services.cookies.add("example.com", "/", "insecure", "true", false, false, false, expiry, {});
Services.cookies.add("example.org", "/", "secure", "true", true, false, false, expiry, {});
Services.cookies.add("example.org", "/", "insecure", "true", false, false, false, expiry, {});
Services.cookies.add("example.net", "/", "secure", "true", true, false, false, expiry, {});
await setupPolicyEngineWithJson({
"policies": {
"Cookies": {
"Block": [
"http://example.com",
"https://example.org:8080"
]
}
}
});
});

function retrieve_all_cookies(host) {
const values = [];
const cookies = Services.cookies.getCookiesFromHost(host, {});
while (cookies.hasMoreElements()) {
const cookie = cookies.getNext().QueryInterface(Ci.nsICookie);
values.push({
host: cookie.host,
name: cookie.name,
path: cookie.path
});
}
return values;
}

add_task(async function test_cookies_for_blocked_sites_cleared() {
const cookies = {
hostname: retrieve_all_cookies("example.com"),
origin: retrieve_all_cookies("example.org"),
keep: retrieve_all_cookies("example.net")
};
const expected = {
hostname: [],
origin: [],
keep: [
{host: "example.net",
name: "secure",
path: "/"}
]
};
is(JSON.stringify(cookies), JSON.stringify(expected),
"All stored cookies for blocked origins should be cleared");
});

add_task(function teardown() {
for (let host of ["example.com", "example.org", "example.net"]) {
Services.cookies.removeCookiesWithOriginAttributes("{}", host);
}
EnterprisePolicyTesting.resetRunOnceState();
});
8 changes: 8 additions & 0 deletions build/mozconfig.lld-link
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
if test -d "$topsrcdir/clang/bin"; then
CLANG_DIR=`cd "$topsrcdir/clang/bin" ; pwd`
export PATH="${CLANG_DIR}:${PATH}"

mk_export_correct_style PATH
fi

export LINKER=lld-link
5 changes: 4 additions & 1 deletion docshell/base/timeline/JavascriptTimelineMarker.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#define mozilla_JavascriptTimelineMarker_h_

#include "TimelineMarker.h"

#include "mozilla/Maybe.h"

#include "mozilla/dom/ProfileTimelineMarkerBinding.h"
#include "mozilla/dom/RootedDictionary.h"
#include "mozilla/dom/ToJSValue.h"
Expand Down Expand Up @@ -63,7 +66,7 @@ class JavascriptTimelineMarker : public TimelineMarker
}

if (JS::IsSavedFrame(asyncStack) &&
!JS::CopyAsyncStack(aCx, asyncStack, asyncCause, &parentFrame, 0)) {
!JS::CopyAsyncStack(aCx, asyncStack, asyncCause, &parentFrame, mozilla::Nothing())) {
JS_ClearPendingException(aCx);
} else {
stackFrame.mAsyncParent = parentFrame;
Expand Down
28 changes: 0 additions & 28 deletions dom/base/nsDOMClassInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@

// DOM core includes
#include "nsError.h"
#include "nsIDOMXULButtonElement.h"
#include "nsIDOMXULCheckboxElement.h"

// Event related includes
#include "nsIDOMEventTarget.h"
Expand Down Expand Up @@ -182,16 +180,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ChromeMessageSender, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)


NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULControlElement, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULLabeledControlElement, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULButtonElement, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULCheckboxElement, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
};

nsIXPConnect *nsDOMClassInfo::sXPConnect = nullptr;
Expand Down Expand Up @@ -455,22 +443,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIMessageSender)
DOM_CLASSINFO_MAP_END

DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XULControlElement, nsIDOMXULControlElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULControlElement)
DOM_CLASSINFO_MAP_END

DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XULLabeledControlElement, nsIDOMXULLabeledControlElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULLabeledControlElement)
DOM_CLASSINFO_MAP_END

DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XULButtonElement, nsIDOMXULButtonElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULButtonElement)
DOM_CLASSINFO_MAP_END

DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XULCheckboxElement, nsIDOMXULCheckboxElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULCheckboxElement)
DOM_CLASSINFO_MAP_END

static_assert(MOZ_ARRAY_LENGTH(sClassInfoData) == eDOMClassInfoIDCount,
"The number of items in sClassInfoData doesn't match the "
"number of nsIDOMClassInfo ID's, this is bad! Fix it!");
Expand Down
5 changes: 0 additions & 5 deletions dom/base/nsDOMClassInfoID.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ enum nsDOMClassInfoID
eDOMClassInfo_ChromeMessageBroadcaster_id,
eDOMClassInfo_ChromeMessageSender_id,

eDOMClassInfo_XULControlElement_id,
eDOMClassInfo_XULLabeledControlElement_id,
eDOMClassInfo_XULButtonElement_id,
eDOMClassInfo_XULCheckboxElement_id,

// This one better be the last one in this list
eDOMClassInfoIDCount
};
Expand Down
11 changes: 11 additions & 0 deletions dom/bindings/BindingDeclarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,17 @@ class SystemCallerGuarantee {
operator CallerType() const { return CallerType::System; }
};

class ProtoAndIfaceCache;
typedef void (*CreateInterfaceObjectsMethod)(JSContext* aCx,
JS::Handle<JSObject*> aGlobal,
ProtoAndIfaceCache& aCache,
bool aDefineOnGlobal);
JS::Handle<JSObject*> GetPerInterfaceObjectHandle(
JSContext* aCx,
size_t aSlotId,
CreateInterfaceObjectsMethod aCreator,
bool aDefineOnGlobal);

} // namespace dom
} // namespace mozilla

Expand Down
36 changes: 36 additions & 0 deletions dom/bindings/BindingUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3805,5 +3805,41 @@ UnprivilegedJunkScopeOrWorkerGlobal()
}
} // namespace binding_detail

JS::Handle<JSObject*>
GetPerInterfaceObjectHandle(JSContext* aCx,
size_t aSlotId,
CreateInterfaceObjectsMethod aCreator,
bool aDefineOnGlobal)
{
/* Make sure our global is sane. Hopefully we can remove this sometime */
JSObject* global = JS::CurrentGlobalOrNull(aCx);
if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
return nullptr;
}

/* Check to see whether the interface objects are already installed */
ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
if (!protoAndIfaceCache.HasEntryInSlot(aSlotId)) {
JS::Rooted<JSObject*> rootedGlobal(aCx, global);
aCreator(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
}

/*
* The object might _still_ be null, but that's OK.
*
* Calling fromMarkedLocation() is safe because protoAndIfaceCache is
* traced by TraceProtoAndIfaceCache() and its contents are never
* changed after they have been set.
*
* Calling address() avoids the read barrier that does gray unmarking, but
* it's not possible for the object to be gray here.
*/

const JS::Heap<JSObject*>& entrySlot =
protoAndIfaceCache.EntrySlotMustExist(aSlotId);
MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
}

} // namespace dom
} // namespace mozilla
85 changes: 28 additions & 57 deletions dom/bindings/Codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -3400,66 +3400,28 @@ def defineAliasesFor(m):
"\n").define()


class CGGetPerInterfaceObject(CGAbstractMethod):
"""
A method for getting a per-interface object (a prototype object or interface
constructor object).
"""
def __init__(self, descriptor, name, idPrefix="", extraArgs=[]):
args = [Argument('JSContext*', 'aCx')] + extraArgs
CGAbstractMethod.__init__(self, descriptor, name,
'JS::Handle<JSObject*>', args)
self.id = idPrefix + "id::" + self.descriptor.name

def definition_body(self):
return fill(
"""
/* Make sure our global is sane. Hopefully we can remove this sometime */
JSObject* global = JS::CurrentGlobalOrNull(aCx);
if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
return nullptr;
}

/* Check to see whether the interface objects are already installed */
ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
if (!protoAndIfaceCache.HasEntryInSlot(${id})) {
JS::Rooted<JSObject*> rootedGlobal(aCx, global);
CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
}

/*
* The object might _still_ be null, but that's OK.
*
* Calling fromMarkedLocation() is safe because protoAndIfaceCache is
* traced by TraceProtoAndIfaceCache() and its contents are never
* changed after they have been set.
*
* Calling address() avoids the read read barrier that does gray
* unmarking, but it's not possible for the object to be gray here.
*/

const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(${id});
MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
""",
id=self.id)


class CGGetProtoObjectHandleMethod(CGGetPerInterfaceObject):
class CGGetProtoObjectHandleMethod(CGAbstractMethod):
"""
A method for getting the interface prototype object.
"""
def __init__(self, descriptor):
CGGetPerInterfaceObject.__init__(self, descriptor, "GetProtoObjectHandle",
"prototypes::")
CGAbstractMethod.__init__(
self, descriptor, "GetProtoObjectHandle",
'JS::Handle<JSObject*>',
[Argument('JSContext*', 'aCx')],
inline=True)

def definition_body(self):
return dedent("""
return fill(
"""
/* Get the interface prototype object for this class. This will create the
object as needed. */
bool aDefineOnGlobal = true;
return GetPerInterfaceObjectHandle(aCx, prototypes::id::${name},
&CreateInterfaceObjects,
/* aDefineOnGlobal = */ true);

""") + CGGetPerInterfaceObject.definition_body(self)
""",
name=self.descriptor.name)


class CGGetProtoObjectMethod(CGAbstractMethod):
Expand All @@ -3475,22 +3437,29 @@ def definition_body(self):
return "return GetProtoObjectHandle(aCx);\n"


class CGGetConstructorObjectHandleMethod(CGGetPerInterfaceObject):
class CGGetConstructorObjectHandleMethod(CGAbstractMethod):
"""
A method for getting the interface constructor object.
"""
def __init__(self, descriptor):
CGGetPerInterfaceObject.__init__(
CGAbstractMethod.__init__(
self, descriptor, "GetConstructorObjectHandle",
"constructors::",
extraArgs=[Argument("bool", "aDefineOnGlobal", "true")])
'JS::Handle<JSObject*>',
[Argument('JSContext*', 'aCx'),
Argument('bool', 'aDefineOnGlobal', 'true')],
inline=True)

def definition_body(self):
return dedent("""
return fill(
"""
/* Get the interface object for this class. This will create the object as
needed. */

""") + CGGetPerInterfaceObject.definition_body(self)
return GetPerInterfaceObjectHandle(aCx, constructors::id::${name},
&CreateInterfaceObjects,
aDefineOnGlobal);
""",
name=self.descriptor.name)


class CGGetConstructorObjectMethod(CGAbstractMethod):
Expand Down Expand Up @@ -14386,6 +14355,7 @@ def descriptorNeedsNonSystemPrincipal(d):
jsImplemented = config.getDescriptors(webIDLFile=webIDLFile,
isJSImplemented=True)
bindingDeclareHeaders["nsWeakReference.h"] = jsImplemented
bindingDeclareHeaders["mozilla/dom/PrototypeList.h"] = descriptors
bindingHeaders["nsIGlobalObject.h"] = jsImplemented
bindingHeaders["AtomList.h"] = hasNonEmptyDictionaries or jsImplemented or callbackDescriptors

Expand Down Expand Up @@ -17332,6 +17302,7 @@ def fieldSizeAssert(amount, jitInfoField, message):
idEnum = CGWrapper(idEnum, post='\n')

curr = CGList([CGGeneric(define="#include <stdint.h>\n\n"),
CGGeneric(declare='#include "jsfriendapi.h"\n\n'),
idEnum])

# Let things know the maximum length of the prototype chain.
Expand Down
5 changes: 5 additions & 0 deletions dom/canvas/WebGL2ContextUniforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ WebGL2Context::GetActiveUniforms(JSContext* cx, const WebGLProgram& program,
if (!ValidateObject("getActiveUniforms: program", program))
return;

if (!program.IsLinked()) {
ErrorInvalidOperation("%s: `program` must be linked.", funcName);
return;
}

const auto& numActiveUniforms = program.LinkInfo()->uniforms.size();
for (const auto& curIndex : uniformIndices) {
if (curIndex >= numActiveUniforms) {
Expand Down
Loading

0 comments on commit 16adda4

Please sign in to comment.