Bug 1514102 [wpt PR 14511] - [UserTiming] Fix mark-measure-return-null test, a=testonly
authorNicolas Pena <npm@chromium.org>
Wed, 19 Dec 2018 12:09:10 +0000
changeset 515029 bfd4b93ba923d4bb6746f8246656974c432ed785
parent 515028 58bbc72bb0ff922171edbc4458b8703cc9808935
child 515030 a56d3fa354af52ee057e09349d5b0c744af24099
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1514102, 14511, 914441, 1377129
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1514102 [wpt PR 14511] - [UserTiming] Fix mark-measure-return-null test, a=testonly Automatic update from web-platform-tests [UserTiming] Fix mark-measure-return-null test The test was incorrect per L2 spec: a void method 'returns' an undefined value, not a null object. This CL changes the test to show how to perform feature detection and compares L2 and L3 behavior. Bug: 914441 Change-Id: Id7173b2693d5bd42013dcdd25266d64fa8956e6a -- Merge pull request #14511 from web-platform-tests/chromium-export-cl-1377129 [UserTiming] Fix mark-measure-return-null test -- wpt-commits: 1dd43edb91fa86dbda5af3a9675e3b103c9e8cd0, ca3a8d6d2de5be8dac1daa17126d8f30d1489c95 wpt-pr: 14511
testing/web-platform/tests/user-timing/mark-measure-feature-detection.html
testing/web-platform/tests/user-timing/mark-measure-return-null.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/user-timing/mark-measure-feature-detection.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML>
+<meta charset=utf-8>
+<title>User Timing: L2 vs L3 feature detection</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+  test(() => {
+    // Feature detection for PerformanceMark.
+    assert_equals(typeof(PerformanceMark.prototype), "object");
+    // Test for UserTiming L3.
+    if (PerformanceMark.prototype.hasOwnProperty('detail')) {
+      assert_equals(typeof(performance.mark("mark")), "object",
+        "performance.mark should return an object in UserTiming L3.");
+    }
+    // Test for UserTiming L2.
+    else {
+      assert_equals(typeof(performance.mark("mark")), "undefined",
+        "performance.mark should be void in UserTiming L2.");
+    }
+  }, "Test PerformanceMark existence and feature detection");
+
+  test(() => {
+    // Feature detection for PerformanceMeasure.
+    assert_equals(typeof(PerformanceMeasure.prototype), "object");
+    // Test for UserTiming L3.
+    if (PerformanceMeasure.prototype.hasOwnProperty('detail')) {
+      assert_equals(typeof(performance.measure("measure")), "object",
+        "performance.measure should return an object in UserTiming L3.");
+    }
+    // Test for UserTiming L2.
+    else {
+      assert_equals(typeof(performance.measure("measure")), "undefined",
+        "performance.measure should be void in UserTiming L2.");
+    }
+  }, "Test PerformanceMeasure existence and feature detection");
+</script>
deleted file mode 100644
--- a/testing/web-platform/tests/user-timing/mark-measure-return-null.html
+++ /dev/null
@@ -1,46 +0,0 @@
-<!DOCTYPE HTML>
-<meta charset=utf-8>
-<title>User Timing: L2 APIs return null</title>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<p>User Timing: L2 APIs return null</p>
-<div id="log"></div>
-<script>
-  async_test(function (t) {
-    self.performance.clearMeasures();
-    const measure = self.performance.measure("measure1");
-    assert_equals(measure, null);
-    t.done();
-  }, "L2: performance.measure(name) should return null.");
-
-  async_test(function (t) {
-    self.performance.clearMeasures();
-    self.performance.mark("1");
-    const measure = self.performance.measure("measure2", 1);
-    assert_equals(measure, null);
-    t.done();
-  }, "L2: performance.measure(name, param1) should return null.");
-
-  async_test(function (t) {
-    self.performance.clearMeasures();
-    self.performance.mark("1");
-    self.performance.mark("2");
-    const measure = self.performance.measure("measure3", 1, 2);
-    assert_equals(measure, null);
-    t.done();
-  }, "L2: performance.measure(name, param1, param2) should return null.");
-
-  async_test(function (t) {
-    self.performance.clearMarks();
-    const mark = self.performance.mark("mark1");
-    assert_equals(mark, null);
-    t.done();
-  }, "L2: performance.mark(name) should return null.");
-
-  async_test(function (t) {
-    self.performance.clearMarks();
-    const mark = self.performance.mark("mark2", { startTime: 34 });
-    assert_equals(mark, null);
-    t.done();
-  }, "L2: performance.mark(name, param) should return null.");
-</script>