1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29

content / test / data / indexeddb / open_connection / open_connection_from_shared_worker.js [blame]

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

'use strict';

onconnect = function(e) {
  var port = e.ports[0];

  port.onmessage = async function(e) {
    let connected;
    let connected_promise = new Promise(r => { connected = r; });
    let request = indexedDB.open("Foo", 1);

    request.onsuccess = e => {
      connected(e.target.result);
    };
    request.onerror = e => {
      connected(undefined);
    }

    let connection = await connected_promise;
    if (connection)
      connection.close();

    port.postMessage({rqid: e.data.rqid, result: connection != undefined});
  }

}