https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 7b89105f042755ba3ef1c346cba087cfb758d0d6 authored by Luke Bjerring on 23 March 2018, 17:36:39 UTC
Support partial dictionaries
Tip revision: 7b89105
service-worker.js
var port;

importScripts('load_wasm.js');

self.onmessage = function(e) {
    var message = e.data;
    if ('port' in message) {
        port = message.port;
    }
};

// And an event listener:
self.addEventListener('message', function(e) {
    var message = e.data;
    if ("compile" in message) {
        createWasmModule()
            .then(m => {
                try {
                    port.postMessage({type:"OK", module:m});
                } catch (e) {
                    port.postMessage({type:"SEND ERROR"});
                }
            })
            .catch(e => port.postMessage({type:"OTHER ERROR"}));
    }
});
back to top