mozilla-mobile / focus-ios

⚠️ Firefox Focus (iOS) has moved to a new repository. It is now developed and maintained as part of: https://github.com/mozilla-mobile/firefox-ios

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Web platform incompatibility for Image's src property

zaygraveyard opened this issue · comments

The Image's src instance property is configurable and enumerable in all browsers except Focus for iOS.
This incompatibility is causing https://ovl.oceandatalab.com to not load properly.

It's caused by the following code that replaces the src property with a non-configurable and non-enumerable one (which is the default when using Object.defineProperty).

var originalImageSrc = Object.getOwnPropertyDescriptor(Image.prototype, 'src');
delete Image.prototype.src;
Object.defineProperty(Image.prototype, 'src', {
get: function() {
return originalImageSrc.get.call(this);
},
set: function(value) {
messageHandler.postMessage({ url: value })
originalImageSrc.set.call(this, value);
}
});

This issue can easily fixed by setting both configurable and enumerable to true, like this:

  var originalImageSrc = Object.getOwnPropertyDescriptor(Image.prototype, 'src');
  delete Image.prototype.src;
  Object.defineProperty(Image.prototype, 'src', {
    configurable: true,
    enumerable: true,
    get: function() {
      return originalImageSrc.get.call(this);
    },
    set: function(value) {
      messageHandler.postMessage({ url: value })
      originalImageSrc.set.call(this, value);
    }
  });

I'm open to submitting a PR.

PS: I'm one of the developers of the linked page that is not loading properly.

┆Issue is synchronized with this Jira Task