chromium/third_party/blink/web_tests/http/tests/workers/resources/shared-worker-create-common.js

// Make a SharedWorker that has the same external interface as a DedicatedWorker, to use in shared test code.
function createWorker()
{
    var worker = new SharedWorker('resources/shared-worker-common.js', 'name');
    worker.port.onmessage = function(evt) { worker.onmessage(evt); };
    worker.postMessage = function(msg, port) { worker.port.postMessage(msg, port); };
    return worker;
}