Provide feedback in the CUSTOM tab for WebGL usage attempts even if the canvas element is not attached to the DOM.
This commit is contained in:
parent
255abeddb6
commit
27281a2ada
|
@ -5,8 +5,6 @@ ns.on("capabilities", event => {
|
||||||
if (ns.allows("webgl")) return;
|
if (ns.allows("webgl")) return;
|
||||||
let env = {eventName: `nsWebgl:${uuid()}`};
|
let env = {eventName: `nsWebgl:${uuid()}`};
|
||||||
window.addEventListener(env.eventName, e => {
|
window.addEventListener(env.eventName, e => {
|
||||||
let canvas = e.target;
|
|
||||||
if (!(canvas instanceof HTMLCanvasElement)) return;
|
|
||||||
let request = {
|
let request = {
|
||||||
id: "noscript-webgl",
|
id: "noscript-webgl",
|
||||||
type: "webgl",
|
type: "webgl",
|
||||||
|
@ -15,12 +13,15 @@ ns.on("capabilities", event => {
|
||||||
embeddingDocument: true,
|
embeddingDocument: true,
|
||||||
};
|
};
|
||||||
seen.record({policyType: "webgl", request, allowed: false});
|
seen.record({policyType: "webgl", request, allowed: false});
|
||||||
try {
|
let canvas = e.target;
|
||||||
let ph = PlaceHolder.create("webgl", request);
|
if (canvas instanceof HTMLCanvasElement) {
|
||||||
ph.replace(canvas);
|
try {
|
||||||
PlaceHolder.listen();
|
let ph = PlaceHolder.create("webgl", request);
|
||||||
} catch (e) {
|
ph.replace(canvas);
|
||||||
error(e);
|
PlaceHolder.listen();
|
||||||
|
} catch (e) {
|
||||||
|
error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
notifyPage();
|
notifyPage();
|
||||||
}, true);
|
}, true);
|
||||||
|
@ -30,7 +31,8 @@ ns.on("capabilities", event => {
|
||||||
let getContext = proto.getContext;
|
let getContext = proto.getContext;
|
||||||
exportFunction(function(type, ...rest) {
|
exportFunction(function(type, ...rest) {
|
||||||
if (type && type.toLowerCase().includes("webgl")) {
|
if (type && type.toLowerCase().includes("webgl")) {
|
||||||
this.dispatchEvent(new Event(env.eventName));
|
let target = document.contains(this) ? this : window;
|
||||||
|
target.dispatchEvent(new Event(env.eventName, {composed: true}));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return getContext.call(this, type, ...rest);
|
return getContext.call(this, type, ...rest);
|
||||||
|
|
Loading…
Reference in New Issue