mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Fix remaining flake8 warnings
This commit is contained in:
parent
c953931621
commit
d01648d637
28 changed files with 328 additions and 310 deletions
|
@ -170,5 +170,6 @@ def update_test_file(cachedir):
|
|||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
update_test_file(tempfile.gettempdir())
|
||||
|
|
|
@ -359,17 +359,17 @@ class CGMethodCall(CGThing):
|
|||
|
||||
# First check for null or undefined
|
||||
pickFirstSignature("%s.get().is_null_or_undefined()" % distinguishingArg,
|
||||
lambda s: (s[1][distinguishingIndex].type.nullable() or
|
||||
s[1][distinguishingIndex].type.isDictionary()))
|
||||
lambda s: (s[1][distinguishingIndex].type.nullable()
|
||||
or s[1][distinguishingIndex].type.isDictionary()))
|
||||
|
||||
# Now check for distinguishingArg being an object that implements a
|
||||
# non-callback interface. That includes typed arrays and
|
||||
# arraybuffers.
|
||||
interfacesSigs = [
|
||||
s for s in possibleSignatures
|
||||
if (s[1][distinguishingIndex].type.isObject() or
|
||||
s[1][distinguishingIndex].type.isUnion() or
|
||||
s[1][distinguishingIndex].type.isNonCallbackInterface())]
|
||||
if (s[1][distinguishingIndex].type.isObject()
|
||||
or s[1][distinguishingIndex].type.isUnion()
|
||||
or s[1][distinguishingIndex].type.isNonCallbackInterface())]
|
||||
# There might be more than one of these; we need to check
|
||||
# which ones we unwrap to.
|
||||
|
||||
|
@ -424,24 +424,24 @@ class CGMethodCall(CGThing):
|
|||
pickFirstSignature("%s.get().is_object() && is_array_like(*cx, %s)" %
|
||||
(distinguishingArg, distinguishingArg),
|
||||
lambda s:
|
||||
(s[1][distinguishingIndex].type.isSequence() or
|
||||
s[1][distinguishingIndex].type.isObject()))
|
||||
(s[1][distinguishingIndex].type.isSequence()
|
||||
or s[1][distinguishingIndex].type.isObject()))
|
||||
|
||||
# Check for vanilla JS objects
|
||||
# XXXbz Do we need to worry about security wrappers?
|
||||
pickFirstSignature("%s.get().is_object()" %
|
||||
distinguishingArg,
|
||||
lambda s: (s[1][distinguishingIndex].type.isCallback() or
|
||||
s[1][distinguishingIndex].type.isCallbackInterface() or
|
||||
s[1][distinguishingIndex].type.isDictionary() or
|
||||
s[1][distinguishingIndex].type.isObject()))
|
||||
lambda s: (s[1][distinguishingIndex].type.isCallback()
|
||||
or s[1][distinguishingIndex].type.isCallbackInterface()
|
||||
or s[1][distinguishingIndex].type.isDictionary()
|
||||
or s[1][distinguishingIndex].type.isObject()))
|
||||
|
||||
# The remaining cases are mutually exclusive. The
|
||||
# pickFirstSignature calls are what change caseBody
|
||||
# Check for strings or enums
|
||||
if pickFirstSignature(None,
|
||||
lambda s: (s[1][distinguishingIndex].type.isString() or
|
||||
s[1][distinguishingIndex].type.isEnum())):
|
||||
lambda s: (s[1][distinguishingIndex].type.isString()
|
||||
or s[1][distinguishingIndex].type.isEnum())):
|
||||
pass
|
||||
# Check for primitives
|
||||
elif pickFirstSignature(None,
|
||||
|
@ -482,9 +482,9 @@ class CGMethodCall(CGThing):
|
|||
|
||||
def dictionaryHasSequenceMember(dictionary):
|
||||
return (any(typeIsSequenceOrHasSequenceMember(m.type) for m in
|
||||
dictionary.members) or
|
||||
(dictionary.parent and
|
||||
dictionaryHasSequenceMember(dictionary.parent)))
|
||||
dictionary.members)
|
||||
or (dictionary.parent
|
||||
and dictionaryHasSequenceMember(dictionary.parent)))
|
||||
|
||||
|
||||
def typeIsSequenceOrHasSequenceMember(type):
|
||||
|
@ -618,22 +618,22 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
|||
def onFailureNotAnObject(failureCode):
|
||||
return CGWrapper(
|
||||
CGGeneric(
|
||||
failureCode or
|
||||
('throw_type_error(*cx, "%s is not an object.");\n'
|
||||
'%s' % (firstCap(sourceDescription), exceptionCode))),
|
||||
failureCode
|
||||
or ('throw_type_error(*cx, "%s is not an object.");\n'
|
||||
'%s' % (firstCap(sourceDescription), exceptionCode))),
|
||||
post="\n")
|
||||
|
||||
def onFailureInvalidEnumValue(failureCode, passedVarName):
|
||||
return CGGeneric(
|
||||
failureCode or
|
||||
('throw_type_error(*cx, &format!("\'{}\' is not a valid enum value for enumeration \'%s\'.", %s)); %s'
|
||||
% (type.name, passedVarName, exceptionCode)))
|
||||
failureCode
|
||||
or ('throw_type_error(*cx, &format!("\'{}\' is not a valid enum value for enumeration \'%s\'.", %s)); %s'
|
||||
% (type.name, passedVarName, exceptionCode)))
|
||||
|
||||
def onFailureNotCallable(failureCode):
|
||||
return CGGeneric(
|
||||
failureCode or
|
||||
('throw_type_error(*cx, \"%s is not callable.\");\n'
|
||||
'%s' % (firstCap(sourceDescription), exceptionCode)))
|
||||
failureCode
|
||||
or ('throw_type_error(*cx, \"%s is not callable.\");\n'
|
||||
'%s' % (firstCap(sourceDescription), exceptionCode)))
|
||||
|
||||
# A helper function for handling default values.
|
||||
def handleDefault(nullValue):
|
||||
|
@ -660,16 +660,16 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
|||
# Handle the non-object cases by wrapping up the whole
|
||||
# thing in an if cascade.
|
||||
templateBody = (
|
||||
"if ${val}.get().is_object() {\n" +
|
||||
CGIndenter(CGGeneric(templateBody)).define() + "\n")
|
||||
"if ${val}.get().is_object() {\n"
|
||||
+ CGIndenter(CGGeneric(templateBody)).define() + "\n")
|
||||
if type.nullable():
|
||||
templateBody += (
|
||||
"} else if ${val}.get().is_null_or_undefined() {\n"
|
||||
" %s\n") % nullValue
|
||||
templateBody += (
|
||||
"} else {\n" +
|
||||
CGIndenter(onFailureNotAnObject(failureCode)).define() +
|
||||
"}")
|
||||
"} else {\n"
|
||||
+ CGIndenter(onFailureNotAnObject(failureCode)).define()
|
||||
+ "}")
|
||||
return templateBody
|
||||
|
||||
assert not (isEnforceRange and isClamp) # These are mutually exclusive
|
||||
|
@ -713,9 +713,9 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
|||
for memberType in type.unroll().flatMemberTypes
|
||||
if memberType.isDictionary()
|
||||
]
|
||||
if (defaultValue and
|
||||
not isinstance(defaultValue, IDLNullValue) and
|
||||
not isinstance(defaultValue, IDLDefaultDictionaryValue)):
|
||||
if (defaultValue
|
||||
and not isinstance(defaultValue, IDLNullValue)
|
||||
and not isinstance(defaultValue, IDLDefaultDictionaryValue)):
|
||||
tag = defaultValue.type.tag()
|
||||
if tag is IDLType.Tags.bool:
|
||||
default = "%s::Boolean(%s)" % (
|
||||
|
@ -1626,13 +1626,13 @@ class PropertyDefiner:
|
|||
prefableSpecs.append(
|
||||
prefableTemplate % (cond, name + "_specs", len(specs) - 1))
|
||||
|
||||
specsArray = ("const %s_specs: &'static [&'static[%s]] = &[\n" +
|
||||
",\n".join(specs) + "\n" +
|
||||
"];\n") % (name, specType)
|
||||
specsArray = ("const %s_specs: &'static [&'static[%s]] = &[\n"
|
||||
+ ",\n".join(specs) + "\n"
|
||||
+ "];\n") % (name, specType)
|
||||
|
||||
prefArray = ("const %s: &'static [Guard<&'static [%s]>] = &[\n" +
|
||||
",\n".join(prefableSpecs) + "\n" +
|
||||
"];\n") % (name, specType)
|
||||
prefArray = ("const %s: &'static [Guard<&'static [%s]>] = &[\n"
|
||||
+ ",\n".join(prefableSpecs) + "\n"
|
||||
+ "];\n") % (name, specType)
|
||||
return specsArray + prefArray
|
||||
|
||||
|
||||
|
@ -1660,9 +1660,9 @@ class MethodDefiner(PropertyDefiner):
|
|||
# Ignore non-static methods for callback interfaces
|
||||
if not descriptor.interface.isCallback() or static:
|
||||
methods = [m for m in descriptor.interface.members if
|
||||
m.isMethod() and m.isStatic() == static and
|
||||
not m.isIdentifierLess() and
|
||||
MemberIsUnforgeable(m, descriptor) == unforgeable]
|
||||
m.isMethod() and m.isStatic() == static
|
||||
and not m.isIdentifierLess()
|
||||
and MemberIsUnforgeable(m, descriptor) == unforgeable]
|
||||
else:
|
||||
methods = []
|
||||
self.regular = [{"name": m.identifier.name,
|
||||
|
@ -1683,10 +1683,10 @@ class MethodDefiner(PropertyDefiner):
|
|||
|
||||
# Generate the keys/values/entries aliases for value iterables.
|
||||
maplikeOrSetlikeOrIterable = descriptor.interface.maplikeOrSetlikeOrIterable
|
||||
if (not static and not unforgeable and
|
||||
(maplikeOrSetlikeOrIterable and
|
||||
maplikeOrSetlikeOrIterable.isIterable() and
|
||||
maplikeOrSetlikeOrIterable.isValueIterator())):
|
||||
if (not static and not unforgeable
|
||||
and maplikeOrSetlikeOrIterable
|
||||
and maplikeOrSetlikeOrIterable.isIterable()
|
||||
and maplikeOrSetlikeOrIterable.isValueIterator()):
|
||||
m = maplikeOrSetlikeOrIterable
|
||||
|
||||
# Add our keys/values/entries/forEach
|
||||
|
@ -1805,8 +1805,8 @@ class AttrDefiner(PropertyDefiner):
|
|||
self.regular = [
|
||||
m
|
||||
for m in descriptor.interface.members if
|
||||
m.isAttr() and m.isStatic() == static and
|
||||
MemberIsUnforgeable(m, descriptor) == unforgeable
|
||||
m.isAttr() and m.isStatic() == static
|
||||
and MemberIsUnforgeable(m, descriptor) == unforgeable
|
||||
]
|
||||
self.static = static
|
||||
self.unforgeable = unforgeable
|
||||
|
@ -1902,6 +1902,7 @@ class ConstDefiner(PropertyDefiner):
|
|||
'ConstantSpec',
|
||||
PropertyDefiner.getControllingCondition, specData)
|
||||
|
||||
|
||||
# We'll want to insert the indent at the beginnings of lines, but we
|
||||
# don't want to indent empty lines. So only indent lines that have a
|
||||
# non-newline character on them.
|
||||
|
@ -2003,8 +2004,8 @@ class CGImports(CGWrapper):
|
|||
|
||||
def isImportable(type):
|
||||
if not type.isType():
|
||||
assert (type.isInterface() or type.isDictionary() or
|
||||
type.isEnum() or type.isNamespace())
|
||||
assert (type.isInterface() or type.isDictionary()
|
||||
or type.isEnum() or type.isNamespace())
|
||||
return True
|
||||
return not (type.builtin or type.isSequence() or type.isUnion())
|
||||
|
||||
|
@ -2878,8 +2879,8 @@ class CGIDLInterface(CGThing):
|
|||
def define(self):
|
||||
interface = self.descriptor.interface
|
||||
name = self.descriptor.concreteType
|
||||
if (interface.getUserData("hasConcreteDescendant", False) or
|
||||
interface.getUserData("hasProxyDescendant", False)):
|
||||
if (interface.getUserData("hasConcreteDescendant", False)
|
||||
or interface.getUserData("hasProxyDescendant", False)):
|
||||
depth = self.descriptor.prototypeDepth
|
||||
check = "class.interface_chain[%s] == PrototypeList::ID::%s" % (depth, name)
|
||||
elif self.descriptor.proxy:
|
||||
|
@ -3466,9 +3467,9 @@ assert!(!proto.is_null());""" % (function,))
|
|||
|
||||
|
||||
def needCx(returnType, arguments, considerTypes):
|
||||
return (considerTypes and
|
||||
(typeNeedsCx(returnType, True) or
|
||||
any(typeNeedsCx(a.type) for a in arguments)))
|
||||
return (considerTypes
|
||||
and (typeNeedsCx(returnType, True)
|
||||
or any(typeNeedsCx(a.type) for a in arguments)))
|
||||
|
||||
|
||||
class CGCallGenerator(CGThing):
|
||||
|
@ -3775,10 +3776,10 @@ class CGSpecializedMethod(CGAbstractExternMethod):
|
|||
self.method)
|
||||
return CGWrapper(CGMethodCall([], nativeName, self.method.isStatic(),
|
||||
self.descriptor, self.method),
|
||||
pre="let cx = SafeJSContext::from_ptr(cx);\n" +
|
||||
("let this = &*(this as *const %s);\n" % self.descriptor.concreteType) +
|
||||
"let args = &*args;\n"
|
||||
"let argc = args.argc_;\n")
|
||||
pre="let cx = SafeJSContext::from_ptr(cx);\n"
|
||||
+ ("let this = &*(this as *const %s);\n" % self.descriptor.concreteType)
|
||||
+ "let args = &*args;\n"
|
||||
"let argc = args.argc_;\n")
|
||||
|
||||
@staticmethod
|
||||
def makeNativeName(descriptor, method):
|
||||
|
@ -3868,8 +3869,8 @@ class CGSpecializedGetter(CGAbstractExternMethod):
|
|||
|
||||
return CGWrapper(CGGetterCall([], self.attr.type, nativeName,
|
||||
self.descriptor, self.attr),
|
||||
pre="let cx = SafeJSContext::from_ptr(cx);\n" +
|
||||
("let this = &*(this as *const %s);\n" % self.descriptor.concreteType))
|
||||
pre="let cx = SafeJSContext::from_ptr(cx);\n"
|
||||
+ ("let this = &*(this as *const %s);\n" % self.descriptor.concreteType))
|
||||
|
||||
@staticmethod
|
||||
def makeNativeName(descriptor, attr):
|
||||
|
@ -3924,8 +3925,8 @@ class CGSpecializedSetter(CGAbstractExternMethod):
|
|||
self.attr)
|
||||
return CGWrapper(CGSetterCall([], self.attr.type, nativeName,
|
||||
self.descriptor, self.attr),
|
||||
pre="let cx = SafeJSContext::from_ptr(cx);\n" +
|
||||
("let this = &*(this as *const %s);\n" % self.descriptor.concreteType))
|
||||
pre="let cx = SafeJSContext::from_ptr(cx);\n"
|
||||
+ ("let this = &*(this as *const %s);\n" % self.descriptor.concreteType))
|
||||
|
||||
@staticmethod
|
||||
def makeNativeName(descriptor, attr):
|
||||
|
@ -4191,8 +4192,8 @@ class CGMemberJITInfo(CGThing):
|
|||
# don't want them coalesced with each other or loop-hoisted, since
|
||||
# their return value can change even if nothing is going on from our
|
||||
# point of view.
|
||||
return (affects == "Nothing" and
|
||||
(dependsOn != "Everything" and dependsOn != "DeviceState"))
|
||||
return (affects == "Nothing"
|
||||
and (dependsOn != "Everything" and dependsOn != "DeviceState"))
|
||||
|
||||
def aliasSet(self):
|
||||
"""Returns the alias set to store in the jitinfo. This may not be the
|
||||
|
@ -4282,10 +4283,10 @@ class CGMemberJITInfo(CGThing):
|
|||
|
||||
if type == existingType:
|
||||
return existingType
|
||||
if ((type == "JSVAL_TYPE_DOUBLE" and
|
||||
existingType == "JSVAL_TYPE_INT32") or
|
||||
(existingType == "JSVAL_TYPE_DOUBLE" and
|
||||
type == "JSVAL_TYPE_INT32")):
|
||||
if ((type == "JSVAL_TYPE_DOUBLE"
|
||||
and existingType == "JSVAL_TYPE_INT32")
|
||||
or (existingType == "JSVAL_TYPE_DOUBLE"
|
||||
and type == "JSVAL_TYPE_INT32")):
|
||||
# Promote INT32 to DOUBLE as needed
|
||||
return "JSVAL_TYPE_DOUBLE"
|
||||
# Different types
|
||||
|
@ -5206,8 +5207,8 @@ class CGProxyNamedOperation(CGProxySpecialOperation):
|
|||
argName = self.arguments[0].identifier.name
|
||||
return ("let %s = jsid_to_string(*cx, Handle::from_raw(id)).expect(\"Not a string-convertible JSID?\");\n"
|
||||
"let this = UnwrapProxy(proxy);\n"
|
||||
"let this = &*this;\n" % argName +
|
||||
CGProxySpecialOperation.define(self))
|
||||
"let this = &*this;\n" % argName
|
||||
+ CGProxySpecialOperation.define(self))
|
||||
|
||||
|
||||
class CGProxyNamedGetter(CGProxyNamedOperation):
|
||||
|
@ -5288,11 +5289,11 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
|||
'successCode': fillDescriptor,
|
||||
'pre': 'rooted!(in(*cx) let mut result_root = UndefinedValue());'
|
||||
}
|
||||
get += ("if let Some(index) = index {\n" +
|
||||
" let this = UnwrapProxy(proxy);\n" +
|
||||
" let this = &*this;\n" +
|
||||
CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define() + "\n" +
|
||||
"}\n")
|
||||
get += ("if let Some(index) = index {\n"
|
||||
+ " let this = UnwrapProxy(proxy);\n"
|
||||
+ " let this = &*this;\n"
|
||||
+ CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define() + "\n"
|
||||
+ "}\n")
|
||||
|
||||
namedGetter = self.descriptor.operations['NamedGetter']
|
||||
if namedGetter:
|
||||
|
@ -5373,16 +5374,16 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
|||
|
||||
indexedSetter = self.descriptor.operations['IndexedSetter']
|
||||
if indexedSetter:
|
||||
set += ("let index = get_array_index_from_id(*cx, Handle::from_raw(id));\n" +
|
||||
"if let Some(index) = index {\n" +
|
||||
" let this = UnwrapProxy(proxy);\n" +
|
||||
" let this = &*this;\n" +
|
||||
CGIndenter(CGProxyIndexedSetter(self.descriptor)).define() +
|
||||
" return (*opresult).succeed();\n" +
|
||||
"}\n")
|
||||
set += ("let index = get_array_index_from_id(*cx, Handle::from_raw(id));\n"
|
||||
+ "if let Some(index) = index {\n"
|
||||
+ " let this = UnwrapProxy(proxy);\n"
|
||||
+ " let this = &*this;\n"
|
||||
+ CGIndenter(CGProxyIndexedSetter(self.descriptor)).define()
|
||||
+ " return (*opresult).succeed();\n"
|
||||
+ "}\n")
|
||||
elif self.descriptor.operations['IndexedGetter']:
|
||||
set += ("if get_array_index_from_id(*cx, Handle::from_raw(id)).is_some() {\n" +
|
||||
" return (*opresult).failNoIndexedSetter();\n" +
|
||||
set += ("if get_array_index_from_id(*cx, Handle::from_raw(id)).is_some() {\n"
|
||||
" return (*opresult).failNoIndexedSetter();\n"
|
||||
"}\n")
|
||||
|
||||
namedSetter = self.descriptor.operations['NamedSetter']
|
||||
|
@ -5390,17 +5391,17 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
|||
if self.descriptor.hasUnforgeableMembers:
|
||||
raise TypeError("Can't handle a named setter on an interface that has "
|
||||
"unforgeables. Figure out how that should work!")
|
||||
set += ("if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {\n" +
|
||||
CGIndenter(CGProxyNamedSetter(self.descriptor)).define() +
|
||||
" return (*opresult).succeed();\n" +
|
||||
"}\n")
|
||||
set += ("if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {\n"
|
||||
+ CGIndenter(CGProxyNamedSetter(self.descriptor)).define()
|
||||
+ " return (*opresult).succeed();\n"
|
||||
+ "}\n")
|
||||
elif self.descriptor.operations['NamedGetter']:
|
||||
set += ("if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {\n" +
|
||||
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() +
|
||||
" if result.is_some() {\n"
|
||||
" return (*opresult).failNoNamedSetter();\n"
|
||||
" }\n"
|
||||
"}\n")
|
||||
set += ("if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {\n"
|
||||
+ CGIndenter(CGProxyNamedGetter(self.descriptor)).define()
|
||||
+ " if result.is_some() {\n"
|
||||
" return (*opresult).failNoNamedSetter();\n"
|
||||
" }\n"
|
||||
"}\n")
|
||||
set += "return proxyhandler::define_property(*cx, %s);" % ", ".join(a.name for a in self.args[1:])
|
||||
return set
|
||||
|
||||
|
@ -5488,8 +5489,8 @@ class CGDOMJSProxyHandler_ownPropertyKeys(CGAbstractExternMethod):
|
|||
|
||||
class CGDOMJSProxyHandler_getOwnEnumerablePropertyKeys(CGAbstractExternMethod):
|
||||
def __init__(self, descriptor):
|
||||
assert (descriptor.operations["IndexedGetter"] and
|
||||
descriptor.interface.getExtendedAttribute("LegacyUnenumerableNamedProperties"))
|
||||
assert (descriptor.operations["IndexedGetter"]
|
||||
and descriptor.interface.getExtendedAttribute("LegacyUnenumerableNamedProperties"))
|
||||
args = [Argument('*mut JSContext', 'cx'),
|
||||
Argument('RawHandleObject', 'proxy'),
|
||||
Argument('RawMutableHandleIdVector', 'props')]
|
||||
|
@ -5543,14 +5544,14 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
|||
indexedGetter = self.descriptor.operations['IndexedGetter']
|
||||
indexed = "let cx = SafeJSContext::from_ptr(cx);\n"
|
||||
if indexedGetter:
|
||||
indexed += ("let index = get_array_index_from_id(*cx, Handle::from_raw(id));\n" +
|
||||
"if let Some(index) = index {\n" +
|
||||
" let this = UnwrapProxy(proxy);\n" +
|
||||
" let this = &*this;\n" +
|
||||
CGIndenter(CGProxyIndexedGetter(self.descriptor)).define() + "\n" +
|
||||
" *bp = result.is_some();\n" +
|
||||
" return true;\n" +
|
||||
"}\n\n")
|
||||
indexed += ("let index = get_array_index_from_id(*cx, Handle::from_raw(id));\n"
|
||||
+ "if let Some(index) = index {\n"
|
||||
+ " let this = UnwrapProxy(proxy);\n"
|
||||
+ " let this = &*this;\n"
|
||||
+ CGIndenter(CGProxyIndexedGetter(self.descriptor)).define() + "\n"
|
||||
+ " *bp = result.is_some();\n"
|
||||
+ " return true;\n"
|
||||
+ "}\n\n")
|
||||
|
||||
namedGetter = self.descriptor.operations['NamedGetter']
|
||||
condition = "RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id)"
|
||||
|
@ -5624,11 +5625,11 @@ if !expando.is_null() {
|
|||
|
||||
indexedGetter = self.descriptor.operations['IndexedGetter']
|
||||
if indexedGetter:
|
||||
getIndexedOrExpando = ("let index = get_array_index_from_id(*cx, id_lt);\n" +
|
||||
"if let Some(index) = index {\n" +
|
||||
" let this = UnwrapProxy(proxy);\n" +
|
||||
" let this = &*this;\n" +
|
||||
CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define())
|
||||
getIndexedOrExpando = ("let index = get_array_index_from_id(*cx, id_lt);\n"
|
||||
+ "if let Some(index) = index {\n"
|
||||
+ " let this = UnwrapProxy(proxy);\n"
|
||||
+ " let this = &*this;\n"
|
||||
+ CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define())
|
||||
getIndexedOrExpando += """\
|
||||
// Even if we don't have this index, we don't forward the
|
||||
// get on to our expando object.
|
||||
|
@ -5648,9 +5649,9 @@ if !expando.is_null() {
|
|||
# 3. Set ignoreNamedProps to true.
|
||||
if indexedGetter:
|
||||
condition = "index.is_none() && (%s)" % condition
|
||||
getNamed = ("if %s {\n" +
|
||||
CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() +
|
||||
"}\n") % condition
|
||||
getNamed = ("if %s {\n"
|
||||
+ CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define()
|
||||
+ "}\n") % condition
|
||||
else:
|
||||
getNamed = ""
|
||||
|
||||
|
@ -5852,10 +5853,10 @@ class CGInterfaceTrait(CGThing):
|
|||
|
||||
def members():
|
||||
for m in descriptor.interface.members:
|
||||
if (m.isMethod() and not m.isStatic() and
|
||||
not m.isMaplikeOrSetlikeOrIterableMethod() and
|
||||
(not m.isIdentifierLess() or (m.isStringifier() and not m.underlyingAttr)) and
|
||||
not m.isDefaultToJSON()):
|
||||
if (m.isMethod() and not m.isStatic()
|
||||
and not m.isMaplikeOrSetlikeOrIterableMethod()
|
||||
and (not m.isIdentifierLess() or (m.isStringifier() and not m.underlyingAttr))
|
||||
and not m.isDefaultToJSON()):
|
||||
name = CGSpecializedMethod.makeNativeName(descriptor, m)
|
||||
infallible = 'infallible' in descriptor.getExtendedAttributes(m)
|
||||
for idx, (rettype, arguments) in enumerate(m.signatures()):
|
||||
|
@ -6254,8 +6255,8 @@ class CGDescriptor(CGThing):
|
|||
defaultToJSONMethod = None
|
||||
unscopableNames = []
|
||||
for m in descriptor.interface.members:
|
||||
if (m.isMethod() and
|
||||
(not m.isIdentifierLess() or m == descriptor.operations["Stringifier"])):
|
||||
if (m.isMethod()
|
||||
and (not m.isIdentifierLess() or m == descriptor.operations["Stringifier"])):
|
||||
if m.getExtendedAttribute("Unscopable"):
|
||||
assert not m.isStatic()
|
||||
unscopableNames.append(m.identifier.name)
|
||||
|
@ -6506,14 +6507,14 @@ class CGDictionary(CGThing):
|
|||
|
||||
return (string.Template(
|
||||
"#[derive(${derive})]\n"
|
||||
"${mustRoot}" +
|
||||
"pub struct ${selfName} {\n" +
|
||||
"${inheritance}" +
|
||||
"\n".join(memberDecls) + "\n" +
|
||||
"}").substitute({"selfName": self.makeClassName(d),
|
||||
"inheritance": inheritance,
|
||||
"mustRoot": mustRoot,
|
||||
"derive": ', '.join(derive)}))
|
||||
+ "${mustRoot}"
|
||||
+ "pub struct ${selfName} {\n"
|
||||
+ "${inheritance}"
|
||||
+ "\n".join(memberDecls) + "\n"
|
||||
+ "}").substitute({"selfName": self.makeClassName(d),
|
||||
"inheritance": inheritance,
|
||||
"mustRoot": mustRoot,
|
||||
"derive": ', '.join(derive)}))
|
||||
|
||||
def impl(self):
|
||||
d = self.dictionary
|
||||
|
@ -6769,15 +6770,15 @@ class CGRegisterProxyHandlers(CGThing):
|
|||
descriptors = config.getDescriptors(proxy=True)
|
||||
self.root = CGList([
|
||||
CGGeneric(
|
||||
"#[allow(non_upper_case_globals)]\n" +
|
||||
"pub mod proxy_handlers {\n" +
|
||||
"#[allow(non_upper_case_globals)]\n"
|
||||
"pub mod proxy_handlers {\n"
|
||||
"".join(
|
||||
" pub static %s: std::sync::atomic::AtomicPtr<libc::c_void> =\n"
|
||||
" std::sync::atomic::AtomicPtr::new(std::ptr::null_mut());\n"
|
||||
% desc.name
|
||||
for desc in descriptors
|
||||
) +
|
||||
"}\n"
|
||||
)
|
||||
+ "}\n"
|
||||
),
|
||||
CGRegisterProxyHandlersMethod(descriptors),
|
||||
], "\n")
|
||||
|
@ -7004,8 +7005,8 @@ class CGNativeMember(ClassMethod):
|
|||
static=member.isStatic(),
|
||||
# Mark our getters, which are attrs that
|
||||
# have a non-void return type, as const.
|
||||
const=(not member.isStatic() and member.isAttr() and
|
||||
not signature[0].isVoid()),
|
||||
const=(not member.isStatic() and member.isAttr()
|
||||
and not signature[0].isVoid()),
|
||||
breakAfterSelf=breakAfterSelf,
|
||||
unsafe=unsafe,
|
||||
visibility=visibility)
|
||||
|
@ -7087,23 +7088,23 @@ class CGCallback(CGClass):
|
|||
setupCall = "let s = CallSetup::new(self, aExceptionHandling);\n"
|
||||
|
||||
bodyWithThis = string.Template(
|
||||
setupCall +
|
||||
"rooted!(in(*s.get_context()) let mut thisObjJS = ptr::null_mut::<JSObject>());\n"
|
||||
"wrap_call_this_object(s.get_context(), thisObj, thisObjJS.handle_mut());\n"
|
||||
"if thisObjJS.is_null() {\n"
|
||||
" return Err(JSFailed);\n"
|
||||
"}\n"
|
||||
"unsafe { ${methodName}(${callArgs}) }").substitute({
|
||||
"callArgs": ", ".join(argnamesWithThis),
|
||||
"methodName": 'self.' + method.name,
|
||||
})
|
||||
setupCall
|
||||
+ "rooted!(in(*s.get_context()) let mut thisObjJS = ptr::null_mut::<JSObject>());\n"
|
||||
"wrap_call_this_object(s.get_context(), thisObj, thisObjJS.handle_mut());\n"
|
||||
"if thisObjJS.is_null() {\n"
|
||||
" return Err(JSFailed);\n"
|
||||
"}\n"
|
||||
"unsafe { ${methodName}(${callArgs}) }").substitute({
|
||||
"callArgs": ", ".join(argnamesWithThis),
|
||||
"methodName": 'self.' + method.name,
|
||||
})
|
||||
bodyWithoutThis = string.Template(
|
||||
setupCall +
|
||||
"rooted!(in(*s.get_context()) let thisObjJS = ptr::null_mut::<JSObject>());\n"
|
||||
"unsafe { ${methodName}(${callArgs}) }").substitute({
|
||||
"callArgs": ", ".join(argnamesWithoutThis),
|
||||
"methodName": 'self.' + method.name,
|
||||
})
|
||||
setupCall
|
||||
+ "rooted!(in(*s.get_context()) let thisObjJS = ptr::null_mut::<JSObject>());\n"
|
||||
"unsafe { ${methodName}(${callArgs}) }").substitute({
|
||||
"callArgs": ", ".join(argnamesWithoutThis),
|
||||
"methodName": 'self.' + method.name,
|
||||
})
|
||||
return [ClassMethod(method.name + '_', method.returnType, args,
|
||||
bodyInHeader=True,
|
||||
templateArgs=["T: DomObject"],
|
||||
|
@ -7314,28 +7315,28 @@ class CallbackMember(CGNativeMember):
|
|||
|
||||
conversion = wrapForType(
|
||||
"argv_root.handle_mut()", result=argval,
|
||||
successCode=("{\n" +
|
||||
"let arg = &mut argv[%s];\n" +
|
||||
"*arg = Heap::default();\n" +
|
||||
"arg.set(argv_root.get());\n" +
|
||||
successCode=("{\n"
|
||||
"let arg = &mut argv[%s];\n"
|
||||
"*arg = Heap::default();\n"
|
||||
"arg.set(argv_root.get());\n"
|
||||
"}") % jsvalIndex,
|
||||
pre="rooted!(in(*cx) let mut argv_root = UndefinedValue());")
|
||||
if arg.variadic:
|
||||
conversion = string.Template(
|
||||
"for idx in 0..${arg}.len() {\n" +
|
||||
CGIndenter(CGGeneric(conversion)).define() + "\n"
|
||||
"}"
|
||||
"for idx in 0..${arg}.len() {\n"
|
||||
+ CGIndenter(CGGeneric(conversion)).define() + "\n"
|
||||
+ "}"
|
||||
).substitute({"arg": arg.identifier.name})
|
||||
elif arg.optional and not arg.defaultValue:
|
||||
conversion = (
|
||||
CGIfWrapper("%s.is_some()" % arg.identifier.name,
|
||||
CGGeneric(conversion)).define() +
|
||||
" else if argc == %d {\n"
|
||||
" // This is our current trailing argument; reduce argc\n"
|
||||
" argc -= 1;\n"
|
||||
"} else {\n"
|
||||
" argv[%d] = Heap::default();\n"
|
||||
"}" % (i + 1, i))
|
||||
CGGeneric(conversion)).define()
|
||||
+ " else if argc == %d {\n"
|
||||
" // This is our current trailing argument; reduce argc\n"
|
||||
" argc -= 1;\n"
|
||||
"} else {\n"
|
||||
" argv[%d] = Heap::default();\n"
|
||||
"}" % (i + 1, i))
|
||||
return conversion
|
||||
|
||||
def getArgs(self, returnType, argList):
|
||||
|
@ -7464,8 +7465,8 @@ class CallbackOperationBase(CallbackMethod):
|
|||
return 'rooted!(in(*cx) let callable =\n' + getCallableFromProp + ');\n'
|
||||
return (
|
||||
'let isCallable = IsCallable(self.callback());\n'
|
||||
'rooted!(in(*cx) let callable =\n' +
|
||||
CGIndenter(
|
||||
'rooted!(in(*cx) let callable =\n'
|
||||
+ CGIndenter(
|
||||
CGIfElseWrapper('isCallable',
|
||||
CGGeneric('ObjectValue(self.callback())'),
|
||||
CGGeneric(getCallableFromProp))).define() + ');\n')
|
||||
|
@ -7676,9 +7677,9 @@ class GlobalGenRoots():
|
|||
return getModuleFromObject(d).split('::')[-1]
|
||||
|
||||
descriptors = config.getDescriptors(register=True, isIteratorInterface=False)
|
||||
descriptors = (set(toBindingNamespace(d.name) for d in descriptors) |
|
||||
set(leafModule(d) for d in config.callbacks) |
|
||||
set(leafModule(d) for d in config.getDictionaries()))
|
||||
descriptors = (set(toBindingNamespace(d.name) for d in descriptors)
|
||||
| set(leafModule(d) for d in config.callbacks)
|
||||
| set(leafModule(d) for d in config.getDictionaries()))
|
||||
curr = CGList([CGGeneric("pub mod %s;\n" % name) for name in sorted(descriptors)])
|
||||
curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT)
|
||||
return curr
|
||||
|
|
|
@ -63,7 +63,8 @@ class Configuration:
|
|||
c.isCallback() and not c.isInterface()]
|
||||
|
||||
# Keep the descriptor list sorted for determinism.
|
||||
cmp = lambda x, y: (x > y) - (x < y)
|
||||
def cmp(x, y):
|
||||
return (x > y) - (x < y)
|
||||
self.descriptors.sort(key=functools.cmp_to_key(lambda x, y: cmp(x.name, y.name)))
|
||||
|
||||
def getInterface(self, ifname):
|
||||
|
@ -74,25 +75,35 @@ class Configuration:
|
|||
curr = self.descriptors
|
||||
for key, val in filters.iteritems():
|
||||
if key == 'webIDLFile':
|
||||
getter = lambda x: x.interface.filename()
|
||||
def getter(x):
|
||||
return x.interface.filename()
|
||||
elif key == 'hasInterfaceObject':
|
||||
getter = lambda x: x.interface.hasInterfaceObject()
|
||||
def getter(x):
|
||||
return x.interface.hasInterfaceObject()
|
||||
elif key == 'isCallback':
|
||||
getter = lambda x: x.interface.isCallback()
|
||||
def getter(x):
|
||||
return x.interface.isCallback()
|
||||
elif key == 'isNamespace':
|
||||
getter = lambda x: x.interface.isNamespace()
|
||||
def getter(x):
|
||||
return x.interface.isNamespace()
|
||||
elif key == 'isJSImplemented':
|
||||
getter = lambda x: x.interface.isJSImplemented()
|
||||
def getter(x):
|
||||
return x.interface.isJSImplemented()
|
||||
elif key == 'isGlobal':
|
||||
getter = lambda x: x.isGlobal()
|
||||
def getter(x):
|
||||
return x.isGlobal()
|
||||
elif key == 'isInline':
|
||||
getter = lambda x: x.interface.getExtendedAttribute('Inline') is not None
|
||||
def getter(x):
|
||||
return x.interface.getExtendedAttribute('Inline') is not None
|
||||
elif key == 'isExposedConditionally':
|
||||
getter = lambda x: x.interface.isExposedConditionally()
|
||||
def getter(x):
|
||||
return x.interface.isExposedConditionally()
|
||||
elif key == 'isIteratorInterface':
|
||||
getter = lambda x: x.interface.isIteratorInterface()
|
||||
def getter(x):
|
||||
return x.interface.isIteratorInterface()
|
||||
else:
|
||||
getter = lambda x: getattr(x, key)
|
||||
def getter(x):
|
||||
return getattr(x, key)
|
||||
curr = filter(lambda x: getter(x) == val, curr)
|
||||
return curr
|
||||
|
||||
|
@ -125,8 +136,8 @@ class Configuration:
|
|||
|
||||
# We should have exactly one result.
|
||||
if len(descriptors) != 1:
|
||||
raise NoSuchDescriptorError("For " + interfaceName + " found " +
|
||||
str(len(descriptors)) + " matches")
|
||||
raise NoSuchDescriptorError("For " + interfaceName + " found "
|
||||
+ str(len(descriptors)) + " matches")
|
||||
return descriptors[0]
|
||||
|
||||
def getDescriptorProvider(self):
|
||||
|
@ -157,10 +168,10 @@ class DescriptorProvider:
|
|||
|
||||
|
||||
def MemberIsUnforgeable(member, descriptor):
|
||||
return ((member.isAttr() or member.isMethod()) and
|
||||
not member.isStatic() and
|
||||
(member.isUnforgeable() or
|
||||
bool(descriptor.interface.getExtendedAttribute("Unforgeable"))))
|
||||
return ((member.isAttr() or member.isMethod())
|
||||
and not member.isStatic()
|
||||
and (member.isUnforgeable()
|
||||
or bool(descriptor.interface.getExtendedAttribute("Unforgeable"))))
|
||||
|
||||
|
||||
class Descriptor(DescriptorProvider):
|
||||
|
@ -228,14 +239,14 @@ class Descriptor(DescriptorProvider):
|
|||
|
||||
# If we're concrete, we need to crawl our ancestor interfaces and mark
|
||||
# them as having a concrete descendant.
|
||||
self.concrete = (not self.interface.isCallback() and
|
||||
not self.interface.isNamespace() and
|
||||
not self.interface.getExtendedAttribute("Abstract") and
|
||||
not self.interface.getExtendedAttribute("Inline") and
|
||||
not spiderMonkeyInterface)
|
||||
self.hasUnforgeableMembers = (self.concrete and
|
||||
any(MemberIsUnforgeable(m, self) for m in
|
||||
self.interface.members))
|
||||
self.concrete = (not self.interface.isCallback()
|
||||
and not self.interface.isNamespace()
|
||||
and not self.interface.getExtendedAttribute("Abstract")
|
||||
and not self.interface.getExtendedAttribute("Inline")
|
||||
and not spiderMonkeyInterface)
|
||||
self.hasUnforgeableMembers = (self.concrete
|
||||
and any(MemberIsUnforgeable(m, self) for m in
|
||||
self.interface.members))
|
||||
|
||||
self.operations = {
|
||||
'IndexedGetter': None,
|
||||
|
@ -391,8 +402,8 @@ class Descriptor(DescriptorProvider):
|
|||
return None
|
||||
|
||||
def hasDescendants(self):
|
||||
return (self.interface.getUserData("hasConcreteDescendant", False) or
|
||||
self.interface.getUserData("hasProxyDescendant", False))
|
||||
return (self.interface.getUserData("hasConcreteDescendant", False)
|
||||
or self.interface.getUserData("hasProxyDescendant", False))
|
||||
|
||||
def hasHTMLConstructor(self):
|
||||
ctor = self.interface.ctor()
|
||||
|
@ -402,8 +413,8 @@ class Descriptor(DescriptorProvider):
|
|||
assert self.interface.hasInterfaceObject()
|
||||
if self.interface.getExtendedAttribute("Inline"):
|
||||
return False
|
||||
return (self.interface.isCallback() or self.interface.isNamespace() or
|
||||
self.hasDescendants() or self.hasHTMLConstructor())
|
||||
return (self.interface.isCallback() or self.interface.isNamespace()
|
||||
or self.hasDescendants() or self.hasHTMLConstructor())
|
||||
|
||||
def shouldCacheConstructor(self):
|
||||
return self.hasDescendants() or self.hasHTMLConstructor()
|
||||
|
@ -416,8 +427,8 @@ class Descriptor(DescriptorProvider):
|
|||
Returns true if this is the primary interface for a global object
|
||||
of some sort.
|
||||
"""
|
||||
return bool(self.interface.getExtendedAttribute("Global") or
|
||||
self.interface.getExtendedAttribute("PrimaryGlobal"))
|
||||
return bool(self.interface.getExtendedAttribute("Global")
|
||||
or self.interface.getExtendedAttribute("PrimaryGlobal"))
|
||||
|
||||
|
||||
# Some utility methods
|
||||
|
@ -428,8 +439,8 @@ def MakeNativeName(name):
|
|||
|
||||
|
||||
def getModuleFromObject(object):
|
||||
return ('crate::dom::bindings::codegen::Bindings::' +
|
||||
os.path.basename(object.location.filename()).split('.webidl')[0] + 'Binding')
|
||||
return ('crate::dom::bindings::codegen::Bindings::'
|
||||
+ os.path.basename(object.location.filename()).split('.webidl')[0] + 'Binding')
|
||||
|
||||
|
||||
def getTypesFromDescriptor(descriptor):
|
||||
|
|
|
@ -198,11 +198,11 @@ class Longhand(object):
|
|||
self.gecko_pref = gecko_pref
|
||||
self.has_effect_on_gecko_scrollbars = has_effect_on_gecko_scrollbars
|
||||
assert (
|
||||
has_effect_on_gecko_scrollbars in [None, False, True] and
|
||||
not style_struct.inherited or
|
||||
(gecko_pref is None) == (has_effect_on_gecko_scrollbars is None)), (
|
||||
"Property " + name + ": has_effect_on_gecko_scrollbars must be " +
|
||||
"specified, and must have a value of True or False, iff a " +
|
||||
has_effect_on_gecko_scrollbars in [None, False, True]
|
||||
and not style_struct.inherited
|
||||
or (gecko_pref is None) == (has_effect_on_gecko_scrollbars is None)), (
|
||||
"Property " + name + ": has_effect_on_gecko_scrollbars must be "
|
||||
"specified, and must have a value of True or False, iff a "
|
||||
"property is inherited and is behind a Gecko pref")
|
||||
# For enabled_in, the setup is as follows:
|
||||
# It needs to be one of the four values: ["", "ua", "chrome", "content"]
|
||||
|
|
|
@ -14,7 +14,7 @@ import re
|
|||
import subprocess
|
||||
import sys
|
||||
|
||||
symbol_regex = re.compile(b"D \*UND\*\t(.*) (.*)$")
|
||||
symbol_regex = re.compile(br"D \*UND\*\t(.*) (.*)$")
|
||||
allowed_symbols = frozenset([
|
||||
b'unshare',
|
||||
b'malloc_usable_size',
|
||||
|
|
|
@ -31,44 +31,44 @@ def create_gecko_session():
|
|||
|
||||
|
||||
def generate_placeholder(testcase):
|
||||
# We need to still include the failed tests, otherwise Treeherder will
|
||||
# consider the result to be a new test series, and thus a new graph. So we
|
||||
# use a placeholder with values = -1 to make Treeherder happy, and still be
|
||||
# able to identify failed tests (successful tests have time >=0).
|
||||
# We need to still include the failed tests, otherwise Treeherder will
|
||||
# consider the result to be a new test series, and thus a new graph. So we
|
||||
# use a placeholder with values = -1 to make Treeherder happy, and still be
|
||||
# able to identify failed tests (successful tests have time >=0).
|
||||
|
||||
timings = {
|
||||
"testcase": testcase,
|
||||
"title": ""
|
||||
}
|
||||
timings = {
|
||||
"testcase": testcase,
|
||||
"title": ""
|
||||
}
|
||||
|
||||
timing_names = [
|
||||
"navigationStart",
|
||||
"unloadEventStart",
|
||||
"domLoading",
|
||||
"fetchStart",
|
||||
"responseStart",
|
||||
"loadEventEnd",
|
||||
"connectStart",
|
||||
"domainLookupStart",
|
||||
"redirectStart",
|
||||
"domContentLoadedEventEnd",
|
||||
"requestStart",
|
||||
"secureConnectionStart",
|
||||
"connectEnd",
|
||||
"loadEventStart",
|
||||
"domInteractive",
|
||||
"domContentLoadedEventStart",
|
||||
"redirectEnd",
|
||||
"domainLookupEnd",
|
||||
"unloadEventEnd",
|
||||
"responseEnd",
|
||||
"domComplete",
|
||||
]
|
||||
timing_names = [
|
||||
"navigationStart",
|
||||
"unloadEventStart",
|
||||
"domLoading",
|
||||
"fetchStart",
|
||||
"responseStart",
|
||||
"loadEventEnd",
|
||||
"connectStart",
|
||||
"domainLookupStart",
|
||||
"redirectStart",
|
||||
"domContentLoadedEventEnd",
|
||||
"requestStart",
|
||||
"secureConnectionStart",
|
||||
"connectEnd",
|
||||
"loadEventStart",
|
||||
"domInteractive",
|
||||
"domContentLoadedEventStart",
|
||||
"redirectEnd",
|
||||
"domainLookupEnd",
|
||||
"unloadEventEnd",
|
||||
"responseEnd",
|
||||
"domComplete",
|
||||
]
|
||||
|
||||
for name in timing_names:
|
||||
timings[name] = 0 if name == "navigationStart" else -1
|
||||
for name in timing_names:
|
||||
timings[name] = 0 if name == "navigationStart" else -1
|
||||
|
||||
return [timings]
|
||||
return [timings]
|
||||
|
||||
|
||||
def run_gecko_test(testcase, url, date, timeout, is_async):
|
||||
|
@ -91,7 +91,7 @@ def run_gecko_test(testcase, url, date, timeout, is_async):
|
|||
"return JSON.stringify(performance.timing)"
|
||||
)
|
||||
))
|
||||
except:
|
||||
except Exception:
|
||||
# We need to return a timing object no matter what happened.
|
||||
# See the comment in generate_placeholder() for explanation
|
||||
print("Failed to get a valid timing measurement.")
|
||||
|
|
|
@ -116,7 +116,7 @@ def parse_log(log, testcase, url, date):
|
|||
for line in block:
|
||||
try:
|
||||
(_, key, value) = line.split(",")
|
||||
except:
|
||||
except ValueError:
|
||||
print("[DEBUG] failed to parse the following line:")
|
||||
print(line)
|
||||
print('[DEBUG] log:')
|
||||
|
@ -133,10 +133,10 @@ def parse_log(log, testcase, url, date):
|
|||
return timing
|
||||
|
||||
def valid_timing(timing, url=None):
|
||||
if (timing is None or
|
||||
testcase is None or
|
||||
timing.get('title') == 'Error loading page' or
|
||||
timing.get('testcase') != url):
|
||||
if (timing is None
|
||||
or testcase is None
|
||||
or timing.get('title') == 'Error loading page'
|
||||
or timing.get('testcase') != url):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
|
|
@ -19,8 +19,8 @@ from runner import format_result_summary
|
|||
|
||||
|
||||
def geometric_mean(iterable):
|
||||
filtered = list(filter(lambda x: x > 0, iterable))
|
||||
return (reduce(operator.mul, filtered)) ** (1.0 / len(filtered))
|
||||
filtered = list(filter(lambda x: x > 0, iterable))
|
||||
return (reduce(operator.mul, filtered)) ** (1.0 / len(filtered))
|
||||
|
||||
|
||||
def format_testcase_name(name):
|
||||
|
|
|
@ -29,6 +29,7 @@ def load_data(filename):
|
|||
results[key] = round(totals[key] / counts[key])
|
||||
return results
|
||||
|
||||
|
||||
data1 = load_data(args.file1)
|
||||
data2 = load_data(args.file2)
|
||||
keys = set(data1.keys()).union(data2.keys())
|
||||
|
|
|
@ -14,8 +14,8 @@ def test_format_testcase_name():
|
|||
'http://localhost:8000/page_load_test/163.com/p.mail.163.com/'
|
||||
'mailinfo/shownewmsg_www_1222.htm.html')))
|
||||
assert(('1234567890223456789032345678904234567890'
|
||||
'5234567890623456789072345678908234567890') ==
|
||||
submit_to_perfherder.format_testcase_name((
|
||||
'5234567890623456789072345678908234567890')
|
||||
== submit_to_perfherder.format_testcase_name((
|
||||
'1234567890223456789032345678904234567890'
|
||||
'52345678906234567890723456789082345678909234567890')))
|
||||
assert('news.ycombinator.com' == submit_to_perfherder.format_testcase_name(
|
||||
|
|
|
@ -10,15 +10,14 @@
|
|||
"""
|
||||
Created on Mon Mar 26 20:08:25 2018
|
||||
@author: Pranshu Sinha, Abhay Soni, Aayushi Agrawal
|
||||
"""
|
||||
|
||||
"""
|
||||
The below program is intended to test rendering mismatches in servo by taking screenshots of rendered html files.
|
||||
Here is the breakdown of how our code works:
|
||||
* A session is started on localhost:7002
|
||||
* The randomly generated webpage's (html files) data is sent as JSON to this session
|
||||
* Using curl request, we load the html files for this session ID based on the session we just created.
|
||||
"""
|
||||
|
||||
import os
|
||||
import json
|
||||
import requests
|
||||
|
@ -72,7 +71,7 @@ def render_html_files(num_of_files, url, file_url, json_string, headers, cwd):
|
|||
image_file.write(base64.decodebytes(image_data_encoded.encode('utf-8')))
|
||||
print("################################")
|
||||
print("The screenshot is stored in the location: {0}/screenshots/"
|
||||
+ " with filename: output_image_{1}.png".format(cwd, str(x)))
|
||||
" with filename: output_image_{1}.png".format(cwd, str(x)))
|
||||
print("################################")
|
||||
|
||||
|
||||
|
@ -124,6 +123,7 @@ def main(argv): # take inputs from command line by considering the options para
|
|||
# Render each HTML file and take a screenshot
|
||||
render_html_files(num_of_files, url, file_url, json_string, headers, cwd)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 8:
|
||||
print_help()
|
||||
|
|
|
@ -128,6 +128,7 @@ class TestPrinter:
|
|||
def to_string(self):
|
||||
return "[UNKNOWN - type = {0}]".format(str(self.val.type))
|
||||
|
||||
|
||||
type_map = [
|
||||
('struct Au', AuPrinter),
|
||||
('FlowFlags', BitFieldU8Printer),
|
||||
|
|
|
@ -13,15 +13,14 @@
|
|||
python3 -m coverage run $0
|
||||
python3 -m coverage report -m --fail-under 100
|
||||
exit
|
||||
'''
|
||||
|
||||
"""
|
||||
Run the decision task with fake Taskcluster APIs, to catch Python errors before pushing.
|
||||
"""
|
||||
'''
|
||||
|
||||
import os
|
||||
import sys
|
||||
from unittest.mock import MagicMock
|
||||
import decision_task
|
||||
|
||||
|
||||
class TaskclusterRestFailure(Exception):
|
||||
|
@ -47,7 +46,7 @@ os.environ["GIT_REF"] = "refs/heads/auto"
|
|||
os.environ["TASKCLUSTER_ROOT_URL"] = "https://community-tc.services.mozilla.com"
|
||||
os.environ["TASKCLUSTER_PROXY_URL"] = "http://taskcluster"
|
||||
os.environ["NEW_AMI_WORKER_TYPE"] = "-"
|
||||
import decision_task
|
||||
|
||||
decision_task.decisionlib.subprocess = MagicMock()
|
||||
|
||||
print("\n# Push:")
|
||||
|
|
|
@ -34,13 +34,13 @@ with open(sys.argv[1]) as f:
|
|||
if "action" in entry and entry["action"] == "test_end":
|
||||
thread = None
|
||||
else:
|
||||
if ("action" in entry and
|
||||
entry["action"] == "test_start" and
|
||||
entry["test"] == sys.argv[2]):
|
||||
if ("action" in entry
|
||||
and entry["action"] == "test_start"
|
||||
and entry["test"] == sys.argv[2]):
|
||||
thread = entry["thread"]
|
||||
print(json.dumps(entry))
|
||||
elif (full_search and
|
||||
"command" in entry and
|
||||
sys.argv[2] in entry["command"]):
|
||||
elif (full_search
|
||||
and "command" in entry
|
||||
and sys.argv[2] in entry["command"]):
|
||||
thread = entry["thread"]
|
||||
print(json.dumps(entry))
|
||||
|
|
|
@ -51,6 +51,7 @@ def process_log(data):
|
|||
|
||||
return test_results
|
||||
|
||||
|
||||
test_results = {
|
||||
"SKIP": [],
|
||||
"OK": [],
|
||||
|
|
|
@ -155,7 +155,6 @@ def wptserve_path(is_firefox, topdir, *paths):
|
|||
|
||||
def _activate_virtualenv(topdir, is_firefox):
|
||||
virtualenv_path = os.path.join(topdir, "python", "_virtualenv%d.%d" % (sys.version_info[0], sys.version_info[1]))
|
||||
check_exec_path = lambda path: path.startswith(virtualenv_path)
|
||||
python = sys.executable # If there was no python, mach wouldn't have run at all!
|
||||
if not python:
|
||||
sys.exit('Failed to find python executable for starting virtualenv.')
|
||||
|
@ -177,7 +176,8 @@ def _activate_virtualenv(topdir, is_firefox):
|
|||
|
||||
exec(compile(open(activate_path).read(), activate_path, 'exec'), dict(__file__=activate_path))
|
||||
|
||||
python = _get_exec_path(PYTHON_NAMES, is_valid_path=check_exec_path)
|
||||
python = _get_exec_path(PYTHON_NAMES,
|
||||
is_valid_path=lambda path: path.startswith(virtualenv_path))
|
||||
if not python:
|
||||
sys.exit("Python executable in virtualenv failed to activate.")
|
||||
|
||||
|
|
|
@ -244,7 +244,7 @@ class MachCommands(CommandBase):
|
|||
|
||||
with open(path.join(preload_path, preload_filename), 'w') as fd:
|
||||
json.dump(entries, fd, indent=4)
|
||||
except ValueError as e:
|
||||
except ValueError:
|
||||
print("Unable to parse chromium HSTS preload list, has the format changed?")
|
||||
sys.exit(1)
|
||||
|
||||
|
@ -262,8 +262,8 @@ class MachCommands(CommandBase):
|
|||
print("Unable to download the public suffix list; are you connected to the internet?")
|
||||
sys.exit(1)
|
||||
|
||||
lines = [l.strip() for l in content.decode("utf8").split("\n")]
|
||||
suffixes = [l for l in lines if not l.startswith("//") and not l == ""]
|
||||
lines = [line.strip() for line in content.decode("utf8").split("\n")]
|
||||
suffixes = [line for line in lines if not line.startswith("//") and not line == ""]
|
||||
|
||||
with open(dst_filename, "wb") as fo:
|
||||
for suffix in suffixes:
|
||||
|
@ -475,7 +475,7 @@ class MachCommands(CommandBase):
|
|||
if os.path.exists(crate_path):
|
||||
try:
|
||||
delete(crate_path)
|
||||
except:
|
||||
except (FileNotFoundError, PermissionError):
|
||||
print(traceback.format_exc())
|
||||
print("Delete %s failed!" % crate_path)
|
||||
else:
|
||||
|
|
|
@ -93,8 +93,8 @@ class MachCommands(CommandBase):
|
|||
help='Updates the selected package')
|
||||
@CommandArgument(
|
||||
'--all-packages', '-a', action='store_true',
|
||||
help='Updates all packages. NOTE! This is very likely to break your ' +
|
||||
'working copy, making it impossible to build servo. Only do ' +
|
||||
help='Updates all packages. NOTE! This is very likely to break your '
|
||||
'working copy, making it impossible to build servo. Only do '
|
||||
'this if you really know what you are doing.')
|
||||
@CommandArgument(
|
||||
'--dry-run', '-d', action='store_true',
|
||||
|
|
|
@ -138,8 +138,8 @@ class DuplicateLine(Strategy):
|
|||
plus_equals_statement = r".+?\s\+\=\s.*"
|
||||
minus_equals_statement = r".+?\s\-\=\s.*"
|
||||
self._replace_strategy = {
|
||||
'regex': (append_statement + '|' + remove_statement + '|' + push_statement +
|
||||
'|' + pop_statement + '|' + plus_equals_statement + '|' + minus_equals_statement),
|
||||
'regex': (append_statement + '|' + remove_statement + '|' + push_statement
|
||||
+ '|' + pop_statement + '|' + plus_equals_statement + '|' + minus_equals_statement),
|
||||
'replaceString': r"\g<0>\n\g<0>",
|
||||
}
|
||||
|
||||
|
|
|
@ -30,9 +30,6 @@ from mach.decorators import (
|
|||
Command,
|
||||
)
|
||||
from mach.registrar import Registrar
|
||||
# Note: mako cannot be imported at the top level because it breaks mach bootstrap
|
||||
sys.path.append(path.join(path.dirname(__file__), "..", "..",
|
||||
"components", "style", "properties", "Mako-1.1.2-py2.py3-none-any.whl"))
|
||||
|
||||
from servo.command_base import (
|
||||
archive_deterministically,
|
||||
|
@ -44,6 +41,9 @@ from servo.command_base import (
|
|||
)
|
||||
from servo.util import delete
|
||||
|
||||
# Note: mako cannot be imported at the top level because it breaks mach bootstrap
|
||||
sys.path.append(path.join(path.dirname(__file__), "..", "..",
|
||||
"components", "style", "properties", "Mako-1.1.2-py2.py3-none-any.whl"))
|
||||
|
||||
PACKAGES = {
|
||||
'android': [
|
||||
|
@ -96,18 +96,18 @@ else:
|
|||
|
||||
def get_taskcluster_secret(name):
|
||||
url = (
|
||||
os.environ.get("TASKCLUSTER_PROXY_URL", "http://taskcluster") +
|
||||
"/api/secrets/v1/secret/project/servo/" +
|
||||
name
|
||||
os.environ.get("TASKCLUSTER_PROXY_URL", "http://taskcluster")
|
||||
+ "/api/secrets/v1/secret/project/servo/"
|
||||
+ name
|
||||
)
|
||||
return json.load(urllib.request.urlopen(url))["secret"]
|
||||
|
||||
|
||||
def otool(s):
|
||||
o = subprocess.Popen(['/usr/bin/otool', '-L', s], stdout=subprocess.PIPE)
|
||||
for l in o.stdout:
|
||||
if l[0] == '\t':
|
||||
yield l.split(' ', 1)[0][1:]
|
||||
for line in o.stdout:
|
||||
if line[0] == '\t':
|
||||
yield line.split(' ', 1)[0][1:]
|
||||
|
||||
|
||||
def listfiles(directory):
|
||||
|
@ -781,7 +781,7 @@ def setup_uwp_signing(ms_app_store, publisher):
|
|||
print("Packaging on TC. Using secret certificate")
|
||||
pfx = get_taskcluster_secret("windows-codesign-cert/latest")["pfx"]
|
||||
open("servo.pfx", "wb").write(base64.b64decode(pfx["base64"]))
|
||||
run_powershell_cmd('Import-PfxCertificate -FilePath .\servo.pfx -CertStoreLocation Cert:\CurrentUser\My')
|
||||
run_powershell_cmd('Import-PfxCertificate -FilePath .\\servo.pfx -CertStoreLocation Cert:\\CurrentUser\\My')
|
||||
os.remove("servo.pfx")
|
||||
|
||||
# Powershell command that lists all certificates for publisher
|
||||
|
@ -796,7 +796,7 @@ def setup_uwp_signing(ms_app_store, publisher):
|
|||
# PowerShell command that creates and install signing certificate for publisher
|
||||
cmd = '(New-SelfSignedCertificate -Type Custom -Subject ' + publisher + \
|
||||
' -FriendlyName "Allizom Signing Certificate (temporary)"' + \
|
||||
' -KeyUsage DigitalSignature -CertStoreLocation "Cert:\CurrentUser\My"' + \
|
||||
' -KeyUsage DigitalSignature -CertStoreLocation "Cert:\\CurrentUser\\My"' + \
|
||||
' -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}")).Thumbprint'
|
||||
thumbprint = run_powershell_cmd(cmd)
|
||||
elif len(certs) > 1:
|
||||
|
|
|
@ -161,8 +161,8 @@ class PostBuildCommands(CommandBase):
|
|||
command = rustCommand
|
||||
|
||||
# Prepend the debugger args.
|
||||
args = ([command] + self.debuggerInfo.args +
|
||||
args + params)
|
||||
args = ([command] + self.debuggerInfo.args
|
||||
+ args + params)
|
||||
else:
|
||||
args = args + params
|
||||
|
||||
|
@ -208,8 +208,8 @@ class PostBuildCommands(CommandBase):
|
|||
env = self.build_env()
|
||||
env["RUST_BACKTRACE"] = "1"
|
||||
|
||||
servo_cmd = [bin or self.get_nightly_binary_path(nightly) or
|
||||
self.get_binary_path(release, dev)] + params
|
||||
servo_cmd = [bin or self.get_nightly_binary_path(nightly)
|
||||
or self.get_binary_path(release, dev)] + params
|
||||
rr_cmd = ['rr', '--fatal-errors', 'record']
|
||||
try:
|
||||
check_call(rr_cmd + servo_cmd)
|
||||
|
|
|
@ -117,8 +117,8 @@ class MachCommands(CommandBase):
|
|||
help="Optionally select test based on "
|
||||
"test file directory")
|
||||
@CommandArgument('--render-mode', '-rm', default=DEFAULT_RENDER_MODE,
|
||||
help="The render mode to be used on all tests. " +
|
||||
HELP_RENDER_MODE)
|
||||
help="The render mode to be used on all tests. "
|
||||
+ HELP_RENDER_MODE)
|
||||
@CommandArgument('--release', default=False, action="store_true",
|
||||
help="Run with a release build of servo")
|
||||
@CommandArgument('--tidy-all', default=False, action="store_true",
|
||||
|
|
|
@ -65,15 +65,15 @@ if __name__ == '__main__':
|
|||
while not server.got_post:
|
||||
server.handle_request()
|
||||
data = json.loads(server.post_data[0])
|
||||
n = 0
|
||||
l = 0
|
||||
number = 0
|
||||
length = 0
|
||||
for test in data:
|
||||
n = max(n, len(data[test]))
|
||||
l = max(l, len(test))
|
||||
print("\n Test{0} | Time".format(" " * (l - len("Test"))))
|
||||
print("-{0}-|-{1}-".format("-" * l, "-" * n))
|
||||
number = max(number, len(data[test]))
|
||||
length = max(length, len(test))
|
||||
print("\n Test{0} | Time".format(" " * (length - len("Test"))))
|
||||
print("-{0}-|-{1}-".format("-" * length, "-" * number))
|
||||
for test in data:
|
||||
print(" {0}{1} | {2}".format(test, " " * (l - len(test)), data[test]))
|
||||
print(" {0}{1} | {2}".format(test, " " * (length - len(test)), data[test]))
|
||||
proc.kill()
|
||||
else:
|
||||
print_usage()
|
||||
|
|
|
@ -183,7 +183,7 @@ def run_http_server():
|
|||
self.send_header("Last-Modified", self.date_time_string(fs.st_mtime))
|
||||
self.end_headers()
|
||||
return f
|
||||
except:
|
||||
except IOError:
|
||||
f.close()
|
||||
raise
|
||||
|
||||
|
@ -195,6 +195,7 @@ def run_http_server():
|
|||
sys.stdout.flush()
|
||||
server.handle_request()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) == 4:
|
||||
cmd = sys.argv[1]
|
||||
|
|
|
@ -134,10 +134,10 @@ def PowerParser(OutputDir, LayoutThreads):
|
|||
|
||||
TotalPower = PowerGen / float(ExperimentNum - 1)
|
||||
TotalTime = TimeGen / float(ExperimentNum - 1)
|
||||
ResultFile.write(str(layoutT) + " , " + str(TotalPower) + " , " +
|
||||
str(MaxPower) + " , " + str(MinPower) + " , " +
|
||||
str(TotalTime) + " , " + str(MaxTime) + " , " +
|
||||
str(MinTime) + "\n")
|
||||
ResultFile.write(str(layoutT) + " , " + str(TotalPower) + " , "
|
||||
+ str(MaxPower) + " , " + str(MinPower) + " , "
|
||||
+ str(TotalTime) + " , " + str(MaxTime) + " , "
|
||||
+ str(MinTime) + "\n")
|
||||
ResultFile.close()
|
||||
Opener = ResultFile = open(ResultTable, "r")
|
||||
for line in Opener:
|
||||
|
@ -180,5 +180,6 @@ def main():
|
|||
PowerCollector(OutputDir, Benchmarks, LayoutThreads, Renderer)
|
||||
PowerParser(OutputDir, LayoutThreads)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -75,8 +75,8 @@ class ServoFormatter(base.BaseFormatter):
|
|||
def text_to_erase_display(self):
|
||||
if not self.interactive or not self.current_display:
|
||||
return ""
|
||||
return ((self.move_up + self.clear_eol) *
|
||||
self.current_display.count('\n'))
|
||||
return ((self.move_up + self.clear_eol)
|
||||
* self.current_display.count('\n'))
|
||||
|
||||
def generate_output(self, text=None, new_display=None, unexpected_in_test=None):
|
||||
if not self.interactive:
|
||||
|
|
|
@ -19,6 +19,7 @@ def wpt_path(*args):
|
|||
def servo_path(*args):
|
||||
return os.path.join(servo_root, *args)
|
||||
|
||||
|
||||
paths = {"include_manifest": wpt_path("include.ini"),
|
||||
"config": wpt_path("config.ini"),
|
||||
"ca-cert-path": wpt_path("web-platform-tests/tools/certs/cacert.pem"),
|
||||
|
@ -26,8 +27,8 @@ paths = {"include_manifest": wpt_path("include.ini"),
|
|||
"host-cert-path": wpt_path("web-platform-tests/tools/certs/web-platform.test.pem")}
|
||||
# Imports
|
||||
sys.path.append(wpt_path("web-platform-tests", "tools"))
|
||||
import localpaths # noqa: flake8
|
||||
from wptrunner import wptrunner, wptcommandline
|
||||
import localpaths # noqa: F401,E402
|
||||
from wptrunner import wptrunner, wptcommandline # noqa: E402
|
||||
|
||||
|
||||
def run_tests(**kwargs):
|
||||
|
@ -106,5 +107,6 @@ def main():
|
|||
kwargs = vars(parser.parse_args())
|
||||
return run_tests(**kwargs)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(0 if main() else 1)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
import os
|
||||
import sys
|
||||
from wptrunner import wptcommandline
|
||||
from update import updatecommandline
|
||||
|
||||
here = os.path.split(__file__)[0]
|
||||
|
||||
|
@ -12,9 +13,6 @@ here = os.path.split(__file__)[0]
|
|||
def wpt_path(*args):
|
||||
return os.path.join(here, *args)
|
||||
|
||||
# Imports
|
||||
from update import updatecommandline
|
||||
|
||||
|
||||
def update_tests(**kwargs):
|
||||
import update
|
||||
|
@ -45,5 +43,6 @@ def main():
|
|||
kwargs = vars(parser.parse_args())
|
||||
return update_tests(**kwargs)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(0 if main() else 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue