https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 776f1c47d40d3b519ecda37ec8d9927feda79bf4 authored by Boris Zbarsky on 04 April 2018, 18:03:21 UTC
part 2. Combine HTMLConstructor and CreateXULOrHTMLElement into a single function.
Tip revision: 776f1c4
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