Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /reporting/callback-this.html - WPT Dashboard Interop Dashboard
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Reporting: ReportingObserver callback is invoked with the observer as this</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script>
promise_test(async t => {
let observer;
const callbackPromise = new Promise(resolve => {
observer = new ReportingObserver(function(reports, obs) {
resolve({ thisValue: this, obs });
});
});
t.add_cleanup(() => observer.disconnect());
observer.observe();
await test_driver.generate_test_report("Test message.");
const { thisValue, obs } = await callbackPromise;
assert_equals(obs, observer, "second argument is the observer");
assert_equals(thisValue, observer, "callback this value is the observer");
}, "ReportingObserver callback this value is the observer");
</script>