+ jarEntry; let filePathResponse = await fetch(filePath); let fileContents = await filePathResponse.blob(); let fileData = await new Promise(resolve => { reader.onloadend = function () { resolve(reader.result); }; reader.readAsArrayBuffer(fileContents); }); await IOUtils.makeDirectory(installToDirPath); // Do not extract into directories. Extract all files to the same // directory. let destPath = PathUtils.join(installToDirPath, fileName); await IOUtils.write(destPath, new Uint8Array(fileData), { tmpPath: destPath + ".tmp", }); // Ensure files are writable and executable. Otherwise, we may be // unable to execute or uninstall them. await IOUtils.setPermissions(destPath, 0o700); if (IOUtils.delMacXAttr) { // If we're on MacOS Firefox will add the quarantine xattr to files it // downloads. In this case we want to clear that xattr so we can load // the CDM. try { await IOUtils.delMacXAttr(destPath, "com.apple.quarantine"); } catch (e) { // Failed to remove the attribute. This could be because the profile // exists on a file system without xattr support. // // Don't fail the extraction here, as in this case it's likely we // didn't set quarantine on these files in the first place. } } extractedPaths.push(destPath); } return extractedPaths; } onmessage = async function (msg) { try { // Construct a jar URI from the file URI so we can use the JAR URI scheme // handling to navigate inside the zip file. let jarPath = "jar:" + msg.data.zipURI + "!/"; let installToDirPath = PathUtils.join( await PathUtils.getProfileDir(), ...msg.data.relativeInstallPath ); let extractedPaths = await readJarDirectory(jarPath, installToDirPath); postMessage({ result: "success", extractedPaths, }); } catch (e) { postMessage({ result: "fail", exception: e.message, }); } }; PK