Proxy Does Not Work From Extension Background Page

Confirmed Issue #12227553 • Assigned to Scott S.

Details

Author
Kyle S.
Created
Jun 3, 2017
Privacy
This issue is public.
Found in
  • Microsoft Edge
Found in build #
38.14393
Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

I have re-created a simple extension with an AngularJS popup (browserAction) that reproduces the problem in my larger app. Find the repo here: https://github.com/kspearrin/angular-edge-proxy

Trying to access a proxy from a background page instance does not work. It always returns undefined. This is only a problem in Edge and all other web extension browsers accept it (Firefox, Chrome, Opera).

Popup Controller

myApp.controller('myController', function ($scope){
    var bg = chrome.extension.getBackgroundPage();
    var locali18nService = new Locali18nService();
    
    // works
    $scope.bar = bg.myService.foo();
    
    // works
    $scope.directHello = chrome.i18n.getMessage('hello');
    // works
    $scope.localHello = locali18nService.hello;
    // DOES NOT work in Edge
    $scope.bgProxyHello = bg.myProxyi18nService.hello;
    // works
    $scope.bgFunctionHello = bg.myFunctioni18nService.get('hello');

    $scope.firstName = "John";
    $scope.lastName = "Doe";
});

function Locali18nService() {
    return new Proxy({}, {
        get: function (target, name) {
            return chrome.i18n.getMessage(name);
        },
        set: function (target, name, value) {
            throw 'set not allowed for i18n';
        }
    });
};

Popup HTML

<div ng-controller="myController">
    <p>Foo: {{bar}}</p>
    <p>
        direct: {{directHello}}<br>
        local proxy: {{localHello}}<br>
        bg proxy: {{bgProxyHello}}<br>
        bg function: {{bgFunctionHello}}
    </p>
</div>

Background

var myService = new MyService();
var myProxyi18nService = new MyProxyi18nService();
var myFunctioni18nService = new MyFunctioni18nService();

function MyService() {
    MyService.prototype.foo = function () {
        return 'bar';
    };
};

function MyProxyi18nService() {
    return new Proxy({}, {
        get: function (target, name) {
            return chrome.i18n.getMessage(name);
        },
        set: function (target, name, value) {
            throw 'set not allowed for i18n';
        }
    });
};

function MyFunctioni18nService() {
    MyFunctioni18nService.prototype.get = function (name) {
        return chrome.i18n.getMessage(name);
    };
};

messages.json

{
  "appName": {
    "message": "My AngulatJS App",
    "description": "The app name"
  },
  "hello": {
    "message": "hello!",
    "description": "-"
  }
}

Results

Opera/Chrome

Foo: bar
direct: hello!
local proxy: hello!
bg proxy: hello!
bg function: hello! 

Edge

Foo: bar
direct: hello!
local proxy: hello!
bg proxy:
bg function: hello!

Attachments

1 attachment

Comments and activity

  • Microsoft Edge Team

    Changed Assigned To to “Kiril S.”

    Changed Assigned To from “Kiril S.” to “Jaikishan R.”

    Changed Assigned To from “Jaikishan R.” to “Scott S.”

    Changed Status to “Confirmed”

    Changed Title from “Proxy Does Not Work From Extension Background Page” to “Proxy Does Not Work From Extension Background Page”

You need to sign in to your Microsoft account to add a comment.

Sign in