From 48a326c0d47c8f49eb50706420a33bfcbe24f2c7 Mon Sep 17 00:00:00 2001 From: tristantheb Date: Sun, 11 Apr 2021 09:03:44 +0200 Subject: L10N: Translation of all Performance APIs/Interfaces/Properties/Methods (#232) * L10N: Translation of the Performance API pages * L10N: Translation of the Performance Timeline API pages * Fix typo, style and KS elements * UPDATE: Update content of code blocks with the Guideline * L10N: Translation of the PerformanceElementTiming pages * L10N: Translation of the PerformanceEntry pages * L10N: Translation of the PerformanceEventTiming interface * L10N: Translation of the PerformanceFrameTiming interface * L10N: Translation of the PerformanceLongTaskTiming interface * L10N: Translation of the PerformanceMark interface * L10N: Translation of the PerformanceMeasure interface * L10N: Translation of the PerformanceNavigation interface * L10N: Translation of the PerformanceNavigationTiming interface * L10N: Translation of the PerformanceObserver interface * L10N: Translation of the PerformanceObserverEntryList interface * L10N: Translation of the PerformancePaintTiming interface * L10N: Translation of the PerformanceResourceTiming interface * L10N: Translation of the PerformanceServerTiming interface * L10N: Translation of the PerformanceTiming interface * FIX: Fix KS error on PerformanceTiming interface * FIX: Change some summary and typo * FIX: Fix CSS and sentences on PerformanceObserverEntryList interface * FIX: Update KS + Change {{event()}} by link on PerformanceEventTiming interface * Review - Landing page * Review 'using' page - rm domxref * Perforamance_timeline review: rm domxref, minor rewording, missing translation * Review timeline guide page, rm domxref, rm vars in pre * Review - PerformanceElementTiming - rm domxref + trailing spaces * Review - PerformanceElementTiming.id - rm xref macros + trailing spaces * Review - PerformanceElementTiming.identifier - rm xref macros + trailing spaces * Review - PerformanceElementTiming - rm xref macros + trailing spaces * Review - PET.intersectionrect - rm domxref / minor typos * Undo spec table mixup * Review - loadTime - rm domxref * Review - naturalheight - rm domxref / trailing spaces * Review - naturalwidth - rm domxref / trailing spaces * Review - renderTime - rm domxref / trailing spaces / minor rewordings * Review - tojson - rm domxref / trailing spaces * Review - url - rm domxref / trailing spaces * Review - duration - rm domxref / minor rewordings * Review - entryType - rm domxref / minor rewordings * Review - performanceentry index - rm domxref / minor rewordings * Review PerformanceEntry.name - rm xref macros * Review PerformanceEntry.startTime - rm xref macros * Review PerformanceEntry.toJSON - rm xref macros * Review PerformanceEventTiming - rm domxref * Review PerformanceFrameTiming - rm xref macros * Review PerformanceLongTaskTiming.attribution - rm xref macros * Review PerformanceLongTaskTiming - rm xref macros * Review - PerformanceMark - rm domxref * Review - PerformanceMeasure - rm domxref * Review - PerformanceNavigation - rm domxref * Review - PerformanceNavigation.redirectcount - rm domxref * Review - PerformanceNavigation.type - rm domxref * Review - PerformanceNavigationTiming.domComplete - rm domxref * Review - PerformanceNavigationTiming.domContentLoadedEvent - rm domxref * Review - PerformanceNavigationTiming.domContentLoadedEventStart - rm domxref * Review - PerformanceNavigationTiming.domInteractive - rm domxref * Review - PerformanceNavigationTiming - rm domxref * Review - PerformanceNavigationTiming.loadEventEnd - rm domxref * Review - PerformanceNavigationTiming.loadEventStart - rm domxref * Review - PerformanceNavigationTiming.redirectCount - rm domxref * Review - PerformanceNavigationTiming.toJSON - rm domxref * Review - PerformanceNavigationTiming.type - rm domxref * Review - PerformanceNavigationTiming.unloadEventEnd - rm domxref * Review - PerformanceNavigationTiming.unloadEventStart - rm domxref * Remove DOMxRef for PerformanceTiming * Remove DOMxRef for PerformanceServerTiming * Remove DOMxRef for PerformanceResourceTiming * Review - PerformanceObserver.disconnect - rm domxref * Review - PerformanceObserver - rm domxref * Review - PerformanceObserver.observe - rm domxref * Review - PerformanceObserver.PerformanceObserver() - rm domxref * Review - PerformanceObserver.takeRecords() - rm domxref * Review - PerformanceObserverEntryList.getEntries() - rm domxref * Review - PerformanceObserver.getEntriesByName() - rm domxref * Review - PerformanceObserver.getEntriesByType() - rm domxref * Review - PerformanceObserverEntryList - rm domxref * Review - PerformanceResourceTiming.connectEnd - rm domxref * Review - PerformanceResourceTiming.connectStart * Review - PerformanceResourceTiming.decodedBodySize * Review - PerformanceResourceTiming.domainLookupEnd * Review - PerformanceResourceTiming.domainLookupStart * Review - PerformanceResourceTiming.encodedBodySize * Review - PerformanceResourceTiming.fetchStart * Review - PerformanceResourceTiming * Review - PerformanceResourceTiming.iniatorType * Review - PerformanceResourceTiming.nextHopProtocol * Review - PerformanceResourceTiming.redirectEnd * Review - PerformanceResourceTiming.redirectStart * Review - PerformanceResourceTiming.requestStart * Review - PerformanceResourceTiming.responseEnd * Review - PerformanceResourceTiming.responseStart * Review - PerformanceResourceTiming.secureConnectionStart * Review - PerformanceResourceTiming.toJSON() * Review - PerformanceResourceTiming.transferSize * Review - PerformanceResourceTiming.workerStart * Review - PerformanceServerTiming.description * Review - PerformanceServerTiming.duration * Review - PerformanceServerTiming * Review - PerformanceServerTiming.name * Review - PerformanceServerTiming.toJSON() * Review - PerformanceTiming.domComplete - rm Event * Review - PerformanceTiming.domContentLoadedEventStart - rm Event * Review - PerformanceTiming.domInteractive - rm Event * Review - PerformanceTiming.domLoading - rm Event * Review - PerformanceTiming - minor typos + thead spec * Review - PerformanceTiming.loadEventEnd - rm Event * Review - PerformanceTiming.loadEventStart - rm Event * Review - PerformanceTiming.unloadEventEnd - rm Event * Review - PerformanceTiming.unloadEventStart - rm Event * Remove final domxref / rm var in examples Co-authored-by: julieng --- .../web/api/performanceentry/duration/index.html | 120 +++++++++++++++++ .../web/api/performanceentry/entrytype/index.html | 138 +++++++++++++++++++ files/fr/web/api/performanceentry/index.html | 147 ++++++++++++++++++++ files/fr/web/api/performanceentry/name/index.html | 150 +++++++++++++++++++++ .../web/api/performanceentry/starttime/index.html | 122 +++++++++++++++++ .../fr/web/api/performanceentry/tojson/index.html | 107 +++++++++++++++ 6 files changed, 784 insertions(+) create mode 100644 files/fr/web/api/performanceentry/duration/index.html create mode 100644 files/fr/web/api/performanceentry/entrytype/index.html create mode 100644 files/fr/web/api/performanceentry/index.html create mode 100644 files/fr/web/api/performanceentry/name/index.html create mode 100644 files/fr/web/api/performanceentry/starttime/index.html create mode 100644 files/fr/web/api/performanceentry/tojson/index.html (limited to 'files/fr/web/api/performanceentry') diff --git a/files/fr/web/api/performanceentry/duration/index.html b/files/fr/web/api/performanceentry/duration/index.html new file mode 100644 index 0000000000..14b9f3e4e7 --- /dev/null +++ b/files/fr/web/api/performanceentry/duration/index.html @@ -0,0 +1,120 @@ +--- +title: PerformanceEntry.duration +slug: Web/API/PerformanceEntry/duration +tags: + - API + - PerformanceEntry + - Property + - Propriété + - Reference + - Performance Web +translation_of: Web/API/PerformanceEntry/duration +--- +
{{APIRef("Performance Timeline API")}}
+ +

La propriété duration renvoie un timestamp qui correspond à la durée de l'entrée de performance.

+ +

{{AvailableInWorkers}}

+ +

La valeur retournée par cette propriété dépend du type de l'entrée de performance :

+ + + +

Cette propriété est en {{readonlyInline}}.

+ +

Syntaxe

+ +
entry.duration;
+ +

Valeur de retour

+ +

Un objet DOMHighResTimeStamp représentant la durée de l'entrée de performance. Si le concept de durée ne s'applique pas à une mesure de performance particulière, le navigateur peut choisir de renvoyer une durée de 0.

+ +
+

Note : si l'entrée de performance a un entryType "resource" (c'est-à-dire que l'entrée est un objet PerformanceResourceTiming), cette propriété renvoie la différence entre les timestamps PerformanceEntry.responseEnd et PerformanceEntry.startTime.

+
+ +

Exemple

+ +

L'exemple suivant montre l'utilisation de la propriété duration.

+ +
function run_PerformanceEntry() {
+  console.log("Support de PerformanceEntry ...");
+
+  if (performance.mark === undefined) {
+    console.log("... performance.mark N'est pas pris en charge");
+    return;
+  }
+
+  // Créer quelques entrées de performance via la méthode mark()
+  performance.mark("Begin");
+  do_work(50000);
+  performance.mark("End");
+
+  // Utilise getEntries() pour itérer à travers chaque entrée.
+  let p = performance.getEntries();
+  for (let i=0; i < p.length; i++) {
+    console.log("Entry[" + i + "]");
+    check_PerformanceEntry(p[i]);
+  }
+}
+function check_PerformanceEntry(obj) {
+  let properties = ["name", "entryType", "startTime", "duration"];
+  let methods = ["toJSON"];
+
+  for (let i=0; i < properties.length; i++) {
+    // check each property
+    let supported = properties[i] in obj;
+    if (supported)
+      console.log("..." + properties[i] + " = " + obj[properties[i]]);
+    else
+      console.log("..." + properties[i] + " = N'est pas pris en charge");
+  }
+  for (let i=0; i < methods.length; i++) {
+    // check each method
+    let supported = typeof obj[methods[i]] == "function";
+    if (supported) {
+      let js = obj[methods[i]]();
+      console.log("..." + methods[i] + "() = " + JSON.stringify(js));
+    } else {
+      console.log("..." + methods[i] + " = N'est pas pris en charge");
+    }
+  }
+}
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaire
{{SpecName('Performance Timeline Level 2', '#dom-performanceentry-duration', + 'duration')}}{{Spec2('Performance Timeline Level 2')}}
{{SpecName('Performance Timeline', '#dom-performanceentry-duration', + 'duration')}}{{Spec2('Performance Timeline')}}Définition initiale.
+ +

Compatibilité des navigateurs

+ +

{{Compat("api.PerformanceEntry.duration")}}

diff --git a/files/fr/web/api/performanceentry/entrytype/index.html b/files/fr/web/api/performanceentry/entrytype/index.html new file mode 100644 index 0000000000..f2223e82cd --- /dev/null +++ b/files/fr/web/api/performanceentry/entrytype/index.html @@ -0,0 +1,138 @@ +--- +title: PerformanceEntry.entryType +slug: Web/API/PerformanceEntry/entryType +tags: + - API + - Performance Timeline API + - PerformanceEntry + - Property + - Propriété + - Reference + - Performance Web +translation_of: Web/API/PerformanceEntry/entryType +--- +
{{APIRef("Performance Timeline API")}}
+ +

La propriété entryType renvoie un DOMString représentant le type de mesure de performance tel que, par exemple, « mark ». Cette propriété est en lecture seule.

+ +

{{AvailableInWorkers}}

+ +

Syntaxe

+ +
var type = entry.entryType;
+ +

Valeur de retour

+ +

La valeur de retour dépend du sous-type de l'objet PerformanceEntry et affecte la valeur de la propriété PerformanceEntry.name comme le montre le tableau ci-dessous.

+ +

Noms des types d'entrée de performance

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ValeurSous-typeType de propriété pour le nomDescription de la valeur du nom.
elementPerformanceElementTimingDOMStringRapporte le temps de chargement des éléments.
frame, navigationPerformanceFrameTiming, + PerformanceNavigationTimingURLL'adresse du document.
resourcePerformanceResourceTimingURLL'URL résolue de la ressource demandée. Cette valeur ne change pas même si la demande est redirigée.
markPerformanceMarkDOMStringLe nom utilisé lorsque la marque a été créée en appelant mark().
measurePerformanceMeasureDOMStringLe nom utilisé lorsque la mesure a été créée en appelant measure().
paintPerformancePaintTimingDOMStringSoit 'first-paint' ou 'first-contentful-paint'.
longtaskPerformanceLongTaskTimingDOMStringSignale les cas de tâches longues.
+ +

Exemple

+ +

L'exemple suivant montre l'utilisation de la propriété entryType.

+ +
function run_PerformanceEntry() {
+
+  // Vérifie le support des fonctionnalités avant de continuer
+  if (performance.mark === undefined) {
+    console.log("performance.mark n'est pas pris en charge");
+    return;
+  }
+
+  // Crée une entrée de performance nommée "begin" via la méthode mark()
+  performance.mark("begin");
+
+  // Vérifie le type d'entrée de toutes les entrées "begin".
+  let entriesNamedBegin = performance.getEntriesByName("begin");
+  for (let i=0; i < entriesNamedBegin.length; i++) {
+    let typeOfEntry = entriesNamedBegin[i].entryType;
+    console.log("L'entrée est de type : " + typeOfEntry);
+  }
+}
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaire
{{SpecName('Performance Timeline Level 2', '#dom-performanceentry-entrytype', + 'entryType')}}{{Spec2('Performance Timeline Level 2')}}
{{SpecName('Performance Timeline', '#dom-performanceentry-entrytype', + 'entryType')}}{{Spec2('Performance Timeline')}}Définition initiale.
+ +

Compatibilité des navigateurs

+ +

{{Compat("api.PerformanceEntry.entryType")}}

diff --git a/files/fr/web/api/performanceentry/index.html b/files/fr/web/api/performanceentry/index.html new file mode 100644 index 0000000000..1e7ef376ea --- /dev/null +++ b/files/fr/web/api/performanceentry/index.html @@ -0,0 +1,147 @@ +--- +title: PerformanceEntry +slug: Web/API/PerformanceEntry +tags: + - API + - Interface + - Performance Timeline API + - PerformanceEntry + - Reference + - Performance Web +translation_of: Web/API/PerformanceEntry +--- +
{{APIRef("Performance Timeline API")}}
+ +

L'objet PerformanceEntry encapsule une seule mesure de performance qui fait partie de la chronologie de performance. Une entrée de performance peut être créée directement en faisant une marque ou une mesure (par exemple en appelant la méthode mark()) à un point explicite d'une application. Les entrées de performance sont également créées de manière indirecte, par exemple en chargeant une ressource (telle qu'une image).

+ +

Les instances PerformanceEntry auront toujours l'un des sous-types suivants :

+ + + +

{{AvailableInWorkers}}

+ +

Propriétés

+ +
+
PerformanceEntry.name {{readonlyInline}}
+
Une valeur qui précise davantage la valeur renvoyée par la propriété PerformanceEntry.entryType. La valeur des deux dépend du sous-type. Voir la page de la propriété pour les valeurs valides.
+
PerformanceEntry.entryType {{readonlyInline}}
+
Une chaîne de caractère DOMString représentant le type de mesure de performance comme, par exemple, "mark". Voir la page des propriétés pour les valeurs valides.
+
PerformanceEntry.startTime {{readonlyInline}}
+
Un objet DOMHighResTimeStamp représentant l'heure de départ de la mesure de performance.
+
PerformanceEntry.duration {{readonlyInline}}
+
Un objet DOMHighResTimeStamp représentant la valeur temporelle de la durée de l'événement de performance.
+
+ +

Méthodes

+ +
+
PerformanceEntry.toJSON()
+
Renvoie une représentation JSON de l'objet PerformanceEntry.
+
+ +

Exemple

+ +

L'exemple suivant vérifie toutes les propriétés PerformanceEntry pour voir si le navigateur les prend en charge et, le cas échéant, écrit leurs valeurs dans la console.

+ +
function print_PerformanceEntries() {
+  // Utilise getEntries() pour obtenir une liste de toutes les entrées de performance.
+  let p = performance.getEntries();
+  for (let i = 0; i < p.length; i++) {
+    console.log("PerformanceEntry[" + i + "]");
+    print_PerformanceEntry(p[i]);
+  }
+}
+function print_PerformanceEntry(perfEntry) {
+  let properties = ["name",
+                    "entryType",
+                    "startTime",
+                    "duration"];
+
+  for (let i = 0; i < properties.length; i++) {
+    // Vérifie chaque propriété
+    let supported = properties[i] in perfEntry;
+    if (supported) {
+      let value = perfEntry[properties[i]];
+      console.log("... " + properties[i] + " = " + value);
+    } else {
+      console.log("... " + properties[i] + " n'est PAS pris en charge");
+    }
+  }
+}
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaire
{{SpecName('Resource Timing 3')}}{{Spec2('Resource Timing 3')}}
{{SpecName('Resource Timing 2')}}{{Spec2('Resource Timing 2')}}
{{SpecName('Resource Timing')}}{{Spec2('Resource Timing')}}Ajoute l'interface PerformanceResourceTiming et la valeur resource pour entryType.
{{SpecName('Navigation Timing Level 2')}}{{Spec2('Navigation Timing Level 2')}}
{{SpecName('Navigation Timing')}}{{Spec2('Navigation Timing')}}Ajoute l'interface PerformanceNavigationTiming et la valeur navigation pour entryType.
{{SpecName('User Timing Level 2')}}{{Spec2('User Timing Level 2')}}
{{SpecName('User Timing')}}{{Spec2('User Timing')}}Ajoute les interfaces PerformanceMark et PerformanceMeasure ainsi que les valeurs mark et measure pour entryType.
{{SpecName('Frame Timing')}}{{Spec2('Frame Timing')}}Ajoute l'interface PerformanceFrameTiming et la valeur frame pour entryType.
{{SpecName('Performance Timeline Level 2', '#dom-performanceentry', 'PerformanceEntry')}}{{Spec2('Performance Timeline Level 2')}}Ajout de la méthode de sérialisation toJSON().
{{SpecName('Performance Timeline', '#dom-performanceentry', 'PerformanceEntry')}}{{Spec2('Performance Timeline')}}Définition initiale.
+ +

Compatibilité des navigateurs

+ +

{{Compat("api.PerformanceEntry")}}

diff --git a/files/fr/web/api/performanceentry/name/index.html b/files/fr/web/api/performanceentry/name/index.html new file mode 100644 index 0000000000..1683f51f51 --- /dev/null +++ b/files/fr/web/api/performanceentry/name/index.html @@ -0,0 +1,150 @@ +--- +title: PerformanceEntry.name +slug: Web/API/PerformanceEntry/name +tags: + - API + - Performance Timeline API + - PerformanceEntry + - Property + - Propriété + - Reference + - Performance Web +translation_of: Web/API/PerformanceEntry/name +--- +
{{APIRef("Performance Timeline API")}}
+ +

La propriété name de l'interface PerformanceEntry renvoie une valeur qui précise davantage la valeur renvoyée par la propriété PerformanceEntry.entryType. Cette propriété est en lecture seule.

+ +

{{AvailableInWorkers}}

+ +

Syntaxe

+ +
var name = entry.name;
+
+ +

Valeur de retour

+ +

La valeur de retour dépend du sous-type de l'objet PerformanceEntry et de la valeur de PerformanceEntry.entryType, comme le montre le tableau ci-dessous.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Type de valeur pour nameSous-typeType (entryType)Description
URLPerformanceFrameTiming, + PerformanceNavigationTimingframe, navigationL'adresse du document.
URLPerformanceResourceTimingresourceL'URL résolue de la ressource demandée. Cette valeur ne change pas même si la demande est redirigée.
DOMStringPerformanceMarkmarkLe nom utilisé lorsque le marqueur a été créé en appelant mark().
DOMStringPerformanceMeasuremeasureLe nom utilisé lorsque la mesure a été créée en appelant measure().
DOMStringPerformancePaintTimingpaintSoit 'first-paint' ou 'first-contentful-paint'.
+ +

Exemple

+ +

L'exemple suivant montre l'utilisation de la propriété name.

+ +
function run_PerformanceEntry() {
+  console.log("Support de PerformanceEntry ...");
+
+  if (performance.mark === undefined) {
+    console.log("... performance.mark n'est pas pris en charge");
+    return;
+  }
+
+  // Crée quelques entrées de performance via la méthode mark()
+  performance.mark("Begin");
+  do_work(50000);
+  performance.mark("End");
+
+  // Utilise getEntries() pour itérer à travers chaque entrée.
+  let p = performance.getEntries();
+  for (let i = 0; i < p.length; i++) {
+    console.log("Entry[" + i + "]");
+    check_PerformanceEntry(p[i]);
+  }
+}
+function check_PerformanceEntry(obj) {
+  let properties = ["name", "entryType", "startTime", "duration"];
+  let methods = ["toJSON"];
+
+  for (let i = 0; i < properties.length; i++) {
+    // Vérifie chaque propriété
+    let supported = properties[i] in obj;
+    if (supported)
+      console.log("..." + properties[i] + " = " + obj[properties[i]]);
+    else
+      console.log("..." + properties[i] + " = Not supported");
+  }
+  for (let i = 0; i < methods.length; i++) {
+    // Vérifie chaque méthode
+    let supported = typeof obj[methods[i]] == "function";
+    if (supported) {
+      let js = obj[methods[i]]();
+      console.log("..." + methods[i] + "() = " + JSON.stringify(js));
+    } else {
+      console.log("..." + methods[i] + " = Not supported");
+    }
+  }
+}
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaire
{{SpecName('Performance Timeline Level 2', '#dom-performanceentry-name', + 'name')}}{{Spec2('Performance Timeline Level 2')}}
{{SpecName('Performance Timeline', '#dom-performanceentry-name', + 'name')}}{{Spec2('Performance Timeline')}}Définition initiale.
+ +

Compatibilité des navigateurs

+ +

{{Compat("api.PerformanceEntry.name")}}

diff --git a/files/fr/web/api/performanceentry/starttime/index.html b/files/fr/web/api/performanceentry/starttime/index.html new file mode 100644 index 0000000000..864d4ac068 --- /dev/null +++ b/files/fr/web/api/performanceentry/starttime/index.html @@ -0,0 +1,122 @@ +--- +title: PerformanceEntry.startTime +slug: Web/API/PerformanceEntry/startTime +tags: + - API + - Performance Timeline API + - PerformanceEntry + - Property + - Propriété + - Reference + - Performance Web +translation_of: Web/API/PerformanceEntry/startTime +--- +
{{APIRef("Performance Timeline API")}}
+ +

La propriété startTime renvoie le premier timestamp enregistré pour l'entrée de performance.

+ +

{{AvailableInWorkers}}

+ +

La valeur renvoyée par cette propriété dépend du type de l'entrée de performance :

+ + + +

Cette propriété est en lecture seule.

+ +

Syntaxe

+ +
entry.startTime;
+ +

Valeur de retour

+ +

Un objet DOMHighResTimeStamp représentant le premier horodatage lorsque l'entrée de performance a été créée.

+ +
+

Note : Si l'entrée de performance a un entryType "resource" (c'est-à-dire que l'entrée est un objet PerformanceResourceTiming), cette propriété renvoie la valeur de l'horodatage fournie par PerformanceResourceTiming.fetchStart.

+
+ +

Exemple

+ +

L'exemple suivant montre l'utilisation de la propriété startTime.

+ +
function run_PerformanceEntry() {
+  console.log("Support de PerformanceEntry ...");
+
+  if (performance.mark === undefined) {
+    console.log("... performance.mark n'est pas pris en charge");
+    return;
+  }
+
+  // Crée quelques entrées de performance via la méthode mark()
+  performance.mark("Begin");
+  do_work(50000);
+  performance.mark("End");
+
+  // Utilise getEntries() pour itérer à travers chaque entrée
+  let p = performance.getEntries();
+  for (let i = 0; i < p.length; i++) {
+    log("Entry[" + i + "]");
+    check_PerformanceEntry(p[i]);
+  }
+}
+function check_PerformanceEntry(obj) {
+  let properties = ["name", "entryType", "startTime", "duration"];
+  let methods = ["toJSON"];
+
+  for (let i = 0; i < properties.length; i++) {
+    // On vérifie chaque propriété
+    let supported = properties[i] in obj;
+    if (supported)
+      log("..." + properties[i] + " = " + obj[properties[i]]);
+    else
+      log("..." + properties[i] + " = N'est pas pris en charge");
+  }
+  for (let i = 0; i < methods.length; i++) {
+    // On vérifie chaque méthode
+    let supported = typeof obj[methods[i]] == "function";
+    if (supported) {
+      let js = obj[methods[i]]();
+      log("..." + methods[i] + "() = " + JSON.stringify(js));
+    } else {
+      log("..." + methods[i] + " = N'est pas pris en charge");
+    }
+  }
+}
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaire
{{SpecName('Performance Timeline Level 2', '#dom-performanceentry-starttime', + 'startTime')}}{{Spec2('Performance Timeline Level 2')}}
{{SpecName('Performance Timeline', '#dom-performanceentry-starttime', + 'startTime')}}{{Spec2('Performance Timeline')}}Définition initiale.
+ +

Compatibilité des navigateurs

+ +

{{Compat("api.PerformanceEntry.startTime")}}

diff --git a/files/fr/web/api/performanceentry/tojson/index.html b/files/fr/web/api/performanceentry/tojson/index.html new file mode 100644 index 0000000000..13a8c3bb5e --- /dev/null +++ b/files/fr/web/api/performanceentry/tojson/index.html @@ -0,0 +1,107 @@ +--- +title: PerformanceEntry.toJSON() +slug: Web/API/PerformanceEntry/toJSON +tags: + - API + - Method + - Méthode + - Performance Timeline API + - PerformanceEntry + - Reference + - Performance Web +translation_of: Web/API/PerformanceEntry/toJSON +--- +
{{APIRef("Performance Timeline API")}}
+ +

La méthode toJSON() permet de sérialiser l'objet PerformanceEntry courant et renvoie une représentation JSON de l'objet.

+ +

{{AvailableInWorkers}}

+ +

Syntaxe

+ +
let jsonObj = perfEntry.toJSON();
+
+ +

Arguments

+ +

Aucun.

+ +

Valeur de retour

+ +
+
json
+
Un objet JSON qui est la sérialisation de l'objet PerformanceEntry.
+
+ +

Exemple

+ +

L'exemple suivant montre l'utilisation de la méthode toJSON().

+ +
function run_PerformanceEntry() {
+  console.log("Support de PerformanceEntry ...");
+
+  if (performance.mark === undefined) {
+    console.log("... performance.mark n'est pas pris en charge");
+    return;
+  }
+
+  // Crée quelques entrées de performance via la méthode mark()
+  performance.mark("Begin");
+  do_work(50000);
+  performance.mark("End");
+
+  // Utilise getEntries() pour itérer à travers chaque entrée.
+  let p = performance.getEntries();
+  for (let i = 0; i < p.length; i++) {
+    console.log("Entry[" + i + "]");
+    check_PerformanceEntry(p[i]);
+  }
+}
+function check_PerformanceEntry(obj) {
+  let properties = ["name", "entryType", "startTime", "duration"];
+  let methods = ["toJSON"];
+
+  for (let i = 0; i < properties.length; i++) {
+    // On vérifie chaque propriété
+    let supported = properties[i] in obj;
+    if (supported)
+      console.log("..." + properties[i] + " = " + obj[properties[i]]);
+    else
+      console.log("..." + properties[i] + " = N'est pas pris en charge");
+  }
+  for (let i = 0; i < methods.length; i++) {
+    // On vérifie chaque méthode
+    let supported = typeof obj[methods[i]] == "function";
+    if (supported) {
+      let js = obj[methods[i]]();
+      console.log("..." + methods[i] + "() = " + JSON.stringify(js));
+    } else {
+      console.log("..." + methods[i] + " = N'est pas pris en charge");
+    }
+  }
+}
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + +
SpécificationStatutCommentaire
{{SpecName('Performance Timeline Level 2', '#dom-performanceentry-tojson', + 'toJSON')}}{{Spec2('Performance Timeline Level 2')}}Définition initiale de la méthode toJSON().
+ +

Compatibilité des navigateurs

+ +

{{Compat("api.PerformanceEntry.toJSON")}}

-- cgit v1.2.3-54-g00ecf