Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/internal/perf/observe.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const {
const {
isPerformanceEntry,
createPerformanceNodeEntry,
markPerformanceEntryQueued,
} = require('internal/perf/performance_entry');

const {
Expand Down Expand Up @@ -388,6 +389,8 @@ function enqueue(entry) {
if (!isPerformanceEntry(entry))
throw new ERR_INVALID_ARG_TYPE('entry', 'PerformanceEntry', entry);

markPerformanceEntryQueued(entry);

for (const obs of kObservers) {
obs[kMaybeBuffer](entry);
}
Expand Down
32 changes: 32 additions & 0 deletions lib/internal/perf/performance_entry.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict';

const {
MathFloor,
MathRandom,
ObjectDefineProperties,
Symbol,
} = primordials;
Expand All @@ -20,12 +22,27 @@ const { validateThisInternalField } = require('internal/validators');
const { inspect } = require('util');

const kName = Symbol('PerformanceEntry.Name');
const kId = Symbol('PerformanceEntry.Id');
const kEntryType = Symbol('PerformanceEntry.EntryType');
const kStartTime = Symbol('PerformanceEntry.StartTime');
const kDuration = Symbol('PerformanceEntry.Duration');
const kNavigationId = Symbol('PerformanceEntry.NavigationId');
const kDetail = Symbol('NodePerformanceEntry.Detail');
const kSkipThrow = Symbol('kSkipThrow');

let lastPerformanceEntryId = MathFloor(MathRandom() * 9901) + 100;

function nextPerformanceEntryId() {
return ++lastPerformanceEntryId;
}

function markPerformanceEntryQueued(entry) {
validateThisInternalField(entry, kName, 'PerformanceEntry');
if (entry[kId] === 0) {
entry[kId] = nextPerformanceEntryId();
}
}

function isPerformanceEntry(obj) {
return obj?.[kName] !== undefined;
}
Expand All @@ -43,9 +60,16 @@ class PerformanceEntry {
}

this[kName] = name;
this[kId] = 0;
this[kEntryType] = type;
this[kStartTime] = start;
this[kDuration] = duration;
this[kNavigationId] = 0;
}

get id() {
validateThisInternalField(this, kName, 'PerformanceEntry');
return this[kId];
}

get name() {
Expand All @@ -68,6 +92,11 @@ class PerformanceEntry {
return this[kDuration];
}

get navigationId() {
validateThisInternalField(this, kName, 'PerformanceEntry');
return this[kNavigationId];
}

[kInspect](depth, options) {
if (depth < 0) return this;

Expand All @@ -90,10 +119,12 @@ class PerformanceEntry {
}
}
ObjectDefineProperties(PerformanceEntry.prototype, {
id: kEnumerableProperty,
name: kEnumerableProperty,
entryType: kEnumerableProperty,
startTime: kEnumerableProperty,
duration: kEnumerableProperty,
navigationId: kEnumerableProperty,
toJSON: kEnumerableProperty,
});

Expand Down Expand Up @@ -134,6 +165,7 @@ module.exports = {
createPerformanceEntry,
PerformanceEntry,
isPerformanceEntry,
markPerformanceEntryQueued,
PerformanceNodeEntry,
createPerformanceNodeEntry,
kSkipThrow,
Expand Down
9 changes: 0 additions & 9 deletions test/wpt/status/performance-timeline.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@
]
}
},
"idlharness.any.js": {
"fail": {
"note": "not implemented",
"expected": [
"PerformanceEntry interface: attribute id",
"PerformanceEntry interface: attribute navigationId"
]
}
},
"navigation-id.helper.js": {
"skip": "This is not a test file."
},
Expand Down
Loading