chromium/chrome/test/data/extensions/api_test/service_worker/worker_based_background/early_filtered_event_dispatch/service_worker_background.js

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

var isInstanceOfServiceWorkerGlobalScope =
    ('ServiceWorkerGlobalScope' in self) &&
    (self instanceof ServiceWorkerGlobalScope);

if (!isInstanceOfServiceWorkerGlobalScope) {
  chrome.test.sendMessage('FAIL');
} else {
  // The event is dispatched directly from the test EarlyFilteredEventDispatch.
  chrome.webNavigation.onCommitted.addListener(function(details) {
    chrome.test.sendMessage('PASS');
  }, {url: [{pathSuffix: 'a.html'}]});
}