Skip to content
This repository was archived by the owner on Sep 20, 2019. It is now read-only.

Commit 43b5dfa

Browse files
committed
Merge pull request #465 from webcomponents/fix-safari-webgl
Fix safari 9 webgl wrappers
2 parents 69803cb + 0608ce8 commit 43b5dfa

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/ShadowDOM/wrappers.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ window.ShadowDOMPolyfill = {};
431431
});
432432
}
433433

434+
scope.addForwardingProperties = addForwardingProperties;
434435
scope.assert = assert;
435436
scope.constructorTable = constructorTable;
436437
scope.defineGetter = defineGetter;

src/ShadowDOM/wrappers/WebGLRenderingContext.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
(function(scope) {
1212
'use strict';
1313

14+
var addForwardingProperties = scope.addForwardingProperties;
1415
var mixin = scope.mixin;
1516
var registerWrapper = scope.registerWrapper;
1617
var setWrapper = scope.setWrapper;
@@ -44,6 +45,15 @@
4445
}
4546
});
4647

48+
// WebKit has two additional prototypes in the chain for WebGLRenderingContext which are not exposed on `window`: WebGLRenderingContextBase and CanvasRenderingContextBase.
49+
// CanvasRenderingContextBase has only one getter `canvas`, which is taken care of already, so we skip it.
50+
51+
var OriginalWebGLRenderingContextBase = Object.getPrototypeOf(OriginalWebGLRenderingContext.prototype);
52+
53+
if (OriginalWebGLRenderingContextBase !== Object.prototype) {
54+
addForwardingProperties(OriginalWebGLRenderingContextBase, WebGLRenderingContext.prototype);
55+
}
56+
4757
// Blink/WebKit has broken DOM bindings. Usually we would create an instance
4858
// of the object and pass it into registerWrapper as a "blueprint" but
4959
// creating WebGL contexts is expensive and might fail so we use a dummy

tests/ShadowDOM/js/HTMLCanvasElement.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ suite('HTMLCanvasElement', function() {
113113
try {
114114
gl = canvas.getContext('webgl');
115115
} catch (ex) {
116+
console.error(ex);
116117
}
117118
// IE10 does not have WebGL.
118119
// Chrome returns null if the graphics card is not supported

0 commit comments

Comments
 (0)