Add [Default] toJSON() to performance interfaces

This commit is contained in:
Kagami Sascha Rosylight 2019-08-29 21:33:03 +09:00
parent 1af15054e7
commit 5695ee94a5
13 changed files with 218 additions and 104 deletions

View file

@ -2049,9 +2049,10 @@ class CGImports(CGWrapper):
if name != 'GlobalScope':
extras += [descriptor.path]
parentName = descriptor.getParentName()
if parentName:
while parentName:
descriptor = descriptorProvider.getDescriptor(parentName)
extras += [descriptor.path, descriptor.bindingPath]
parentName = descriptor.getParentName()
elif t.isType() and t.isRecord():
extras += ['crate::dom::bindings::mozmap::MozMap']
elif isinstance(t, IDLPromiseType):
@ -3662,6 +3663,7 @@ class CGDefaultToJSONMethod(CGSpecializedMethod):
def definition_body(self):
ret = dedent("""
use crate::dom::bindings::inheritance::HasParent;
rooted!(in(*cx) let result = JS_NewPlainObject(*cx));
if result.is_null() {
return false;
@ -3676,16 +3678,19 @@ class CGDefaultToJSONMethod(CGSpecializedMethod):
jsonDescriptors.append(descriptor)
interface = interface.parent
parents = len(jsonDescriptors) - 1
form = """
if !${parentclass}CollectJSONAttributes(cx, _obj, this, &result) {
if !${parentclass}CollectJSONAttributes(cx, _obj, this${asparent}, &result) {
return false;
}
"""
# Iterate the array in reverse: oldest ancestor first
for descriptor in jsonDescriptors[:0:-1]:
ret += fill(form, parentclass=toBindingNamespace(descriptor.name) + "::")
ret += fill(form, parentclass="")
ret += fill(form, parentclass=toBindingNamespace(descriptor.name) + "::",
asparent=".as_ref().unwrap()" + ".as_parent()" * parents)
parents -= 1
ret += fill(form, parentclass="", asparent="")
ret += ('(*args).rval().set(ObjectValue(*result));\n'
'return true;\n')
return CGGeneric(ret)

View file

@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is
* https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html#sec-window.performance-attribute
* https://w3c.github.io/hr-time/#sec-performance
*/
typedef double DOMHighResTimeStamp;
@ -13,7 +13,7 @@ typedef sequence<PerformanceEntry> PerformanceEntryList;
interface Performance : EventTarget {
DOMHighResTimeStamp now();
readonly attribute DOMHighResTimeStamp timeOrigin;
// [Default] object toJSON();
[Default] object toJSON();
};
// https://w3c.github.io/performance-timeline/#extensions-to-the-performance-interface

View file

@ -12,6 +12,5 @@ interface PerformanceEntry {
readonly attribute DOMString entryType;
readonly attribute DOMHighResTimeStamp startTime;
readonly attribute DOMHighResTimeStamp duration;
// [Default] object toJSON();
[Default] object toJSON();
};

View file

@ -14,5 +14,5 @@ interface PerformanceNavigation {
const unsigned short TYPE_RESERVED = 255;
readonly attribute unsigned short type;
readonly attribute unsigned short redirectCount;
// [Default] object toJSON();
[Default] object toJSON();
};

View file

@ -25,7 +25,7 @@ interface PerformanceNavigationTiming : PerformanceResourceTiming {
readonly attribute DOMHighResTimeStamp loadEventEnd;
readonly attribute NavigationType type;
readonly attribute unsigned short redirectCount;
// [Default] object toJSON();
[Default] object toJSON();
/* Servo-only attribute for measuring when the top-level document (not iframes) is complete. */
[Pref="dom.testperf.enabled"]
readonly attribute DOMHighResTimeStamp topLevelDomComplete;

View file

@ -26,5 +26,5 @@ interface PerformanceResourceTiming : PerformanceEntry {
/// readonly attribute unsigned long long transferSize;
/// readonly attribute unsigned long long encodedBodySize;
/// readonly attribute unsigned long long decodedBodySize;
// [Default] object toJSON();
[Default] object toJSON();
};

View file

@ -1,20 +1,3 @@
[idlharness.any.html]
[idlharness]
expected: FAIL
[Performance interface: operation toJSON()]
expected: FAIL
[Performance interface: performance must inherit property "toJSON()" with the proper type]
expected: FAIL
[Test default toJSON operation of Performance]
expected: FAIL
[Performance interface: default toJSON operation on performance]
expected: FAIL
[idlharness.any.serviceworker.html]
[idlharness]
expected: FAIL
@ -30,20 +13,3 @@
[idlharness]
expected: FAIL
[idlharness.any.worker.html]
[idlharness]
expected: FAIL
[Performance interface: operation toJSON()]
expected: FAIL
[Performance interface: performance must inherit property "toJSON()" with the proper type]
expected: FAIL
[Test default toJSON operation of Performance]
expected: FAIL
[Performance interface: default toJSON operation on performance]
expected: FAIL

View file

@ -1,2 +1,204 @@
[idlharness.window.html]
disabled: https://github.com/servo/servo/issues/21274
[PerformanceNavigationTiming must be primary interface of performance.getEntriesByType("navigation")[0\]]
expected: FAIL
[Stringification of performance.getEntriesByType("navigation")[0\]]
expected: FAIL
[PerformanceNavigationTiming interface: performance.getEntriesByType("navigation")[0\] must inherit property "unloadEventStart" with the proper type]
expected: FAIL
[PerformanceNavigationTiming interface: performance.getEntriesByType("navigation")[0\] must inherit property "unloadEventEnd" with the proper type]
expected: FAIL
[PerformanceNavigationTiming interface: performance.getEntriesByType("navigation")[0\] must inherit property "domInteractive" with the proper type]
expected: FAIL
[PerformanceNavigationTiming interface: performance.getEntriesByType("navigation")[0\] must inherit property "domContentLoadedEventStart" with the proper type]
expected: FAIL
[PerformanceNavigationTiming interface: performance.getEntriesByType("navigation")[0\] must inherit property "domContentLoadedEventEnd" with the proper type]
expected: FAIL
[PerformanceNavigationTiming interface: performance.getEntriesByType("navigation")[0\] must inherit property "domComplete" with the proper type]
expected: FAIL
[PerformanceNavigationTiming interface: performance.getEntriesByType("navigation")[0\] must inherit property "loadEventStart" with the proper type]
expected: FAIL
[PerformanceNavigationTiming interface: performance.getEntriesByType("navigation")[0\] must inherit property "loadEventEnd" with the proper type]
expected: FAIL
[PerformanceNavigationTiming interface: performance.getEntriesByType("navigation")[0\] must inherit property "type" with the proper type]
expected: FAIL
[PerformanceNavigationTiming interface: performance.getEntriesByType("navigation")[0\] must inherit property "redirectCount" with the proper type]
expected: FAIL
[PerformanceNavigationTiming interface: performance.getEntriesByType("navigation")[0\] must inherit property "toJSON()" with the proper type]
expected: FAIL
[PerformanceNavigationTiming interface: default toJSON operation on performance.getEntriesByType("navigation")[0\]]
expected: FAIL
[PerformanceTiming interface: existence and properties of interface object]
expected: FAIL
[PerformanceTiming interface object length]
expected: FAIL
[PerformanceTiming interface object name]
expected: FAIL
[PerformanceTiming interface: existence and properties of interface prototype object]
expected: FAIL
[PerformanceTiming interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[PerformanceTiming interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL
[PerformanceTiming interface: attribute navigationStart]
expected: FAIL
[PerformanceTiming interface: attribute unloadEventStart]
expected: FAIL
[PerformanceTiming interface: attribute unloadEventEnd]
expected: FAIL
[PerformanceTiming interface: attribute redirectStart]
expected: FAIL
[PerformanceTiming interface: attribute redirectEnd]
expected: FAIL
[PerformanceTiming interface: attribute fetchStart]
expected: FAIL
[PerformanceTiming interface: attribute domainLookupStart]
expected: FAIL
[PerformanceTiming interface: attribute domainLookupEnd]
expected: FAIL
[PerformanceTiming interface: attribute connectStart]
expected: FAIL
[PerformanceTiming interface: attribute connectEnd]
expected: FAIL
[PerformanceTiming interface: attribute secureConnectionStart]
expected: FAIL
[PerformanceTiming interface: attribute requestStart]
expected: FAIL
[PerformanceTiming interface: attribute responseStart]
expected: FAIL
[PerformanceTiming interface: attribute responseEnd]
expected: FAIL
[PerformanceTiming interface: attribute domLoading]
expected: FAIL
[PerformanceTiming interface: attribute domInteractive]
expected: FAIL
[PerformanceTiming interface: attribute domContentLoadedEventStart]
expected: FAIL
[PerformanceTiming interface: attribute domContentLoadedEventEnd]
expected: FAIL
[PerformanceTiming interface: attribute domComplete]
expected: FAIL
[PerformanceTiming interface: attribute loadEventStart]
expected: FAIL
[PerformanceTiming interface: attribute loadEventEnd]
expected: FAIL
[PerformanceTiming interface: operation toJSON()]
expected: FAIL
[PerformanceTiming must be primary interface of performance.timing]
expected: FAIL
[Stringification of performance.timing]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "navigationStart" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "unloadEventStart" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "unloadEventEnd" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "redirectStart" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "redirectEnd" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "fetchStart" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "domainLookupStart" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "domainLookupEnd" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "connectStart" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "connectEnd" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "secureConnectionStart" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "requestStart" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "responseStart" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "responseEnd" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "domLoading" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "domInteractive" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "domContentLoadedEventStart" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "domContentLoadedEventEnd" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "domComplete" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "loadEventStart" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "loadEventEnd" with the proper type]
expected: FAIL
[PerformanceTiming interface: performance.timing must inherit property "toJSON()" with the proper type]
expected: FAIL
[PerformanceTiming interface: default toJSON operation on performance.timing]
expected: FAIL
[Performance interface: attribute timing]
expected: FAIL

View file

@ -7,18 +7,12 @@
[idlharness.any.worker.html]
[PerformanceEntry interface: operation toJSON()]
expected: FAIL
[PerformanceObserver interface: operation takeRecords()]
expected: FAIL
[PerformanceObserver interface: observer must inherit property "takeRecords()" with the proper type]
expected: FAIL
[PerformanceEntry interface: mark must inherit property "toJSON()" with the proper type]
expected: FAIL
[Test default toJSON operation of PerformanceMark]
expected: FAIL
@ -34,9 +28,6 @@
[PerformanceMark interface object length]
expected: FAIL
[PerformanceEntry interface: default toJSON operation on mark]
expected: FAIL
[PerformanceObserver interface: operation observe(PerformanceObserverInit)]
expected: FAIL
@ -45,18 +36,12 @@
[Untitled]
expected: FAIL
[PerformanceEntry interface: operation toJSON()]
expected: FAIL
[PerformanceObserver interface: operation takeRecords()]
expected: FAIL
[PerformanceObserver interface: observer must inherit property "takeRecords()" with the proper type]
expected: FAIL
[PerformanceEntry interface: mark must inherit property "toJSON()" with the proper type]
expected: FAIL
[Test default toJSON operation of PerformanceMark]
expected: FAIL
@ -72,9 +57,6 @@
[PerformanceMark interface object length]
expected: FAIL
[PerformanceEntry interface: default toJSON operation on mark]
expected: FAIL
[PerformanceObserver interface: operation observe(PerformanceObserverInit)]
expected: FAIL

View file

@ -1,12 +0,0 @@
[performanceentry-tojson.any.html]
[performanceentry-tojson]
expected: FAIL
[Test toJSON() in PerformanceEntry]
expected: FAIL
[performanceentry-tojson.any.worker.html]
[performanceentry-tojson]
expected: FAIL
[Test toJSON() in PerformanceEntry]
expected: FAIL

View file

@ -11,12 +11,6 @@
[Stringification of resource]
expected: FAIL
[Test default toJSON operation of PerformanceNavigationTiming]
expected: FAIL
[PerformanceResourceTiming interface: resource must inherit property "toJSON()" with the proper type]
expected: FAIL
[PerformanceResourceTiming interface: resource must inherit property "decodedBodySize" with the proper type]
expected: FAIL
@ -26,9 +20,6 @@
[PerformanceResourceTiming interface: resource must inherit property "encodedBodySize" with the proper type]
expected: FAIL
[PerformanceResourceTiming interface: operation toJSON()]
expected: FAIL
[PerformanceResourceTiming must be primary interface of resource]
expected: FAIL
@ -61,9 +52,6 @@
[PerformanceResourceTiming interface: attribute transferSize]
expected: FAIL
[Test default toJSON operation of toJSON object]
expected: FAIL
[PerformanceResourceTiming interface: resource must inherit property "secureConnectionStart" with the proper type]
expected: FAIL
@ -73,9 +61,6 @@
[PerformanceResourceTiming interface: attribute decodedBodySize]
expected: FAIL
[PerformanceResourceTiming interface: resource must inherit property "toJSON()" with the proper type]
expected: FAIL
[PerformanceResourceTiming interface: resource must inherit property "domainLookupEnd" with the proper type]
expected: FAIL
@ -88,9 +73,6 @@
[PerformanceResourceTiming interface: resource must inherit property "encodedBodySize" with the proper type]
expected: FAIL
[PerformanceResourceTiming interface: operation toJSON()]
expected: FAIL
[PerformanceResourceTiming interface: attribute secureConnectionStart]
expected: FAIL

View file

@ -1,7 +0,0 @@
[resource-timing-tojson.html]
[Untitled]
expected: FAIL
[Test toJSON() in PerformanceResourceTiming]
expected: FAIL

View file

@ -12,9 +12,6 @@
[Resource timing seems to work in workers]
expected: FAIL
[performance.toJSON is available in workers]
expected: FAIL
[performance.clearResourceTimings in workers]
expected: FAIL