7

When LockerService is enabled and I run the example code from Mozilla:

var array = new Uint32Array(10);
window.crypto.getRandomValues(array);

I get this error:

Uncaught TypeError: Failed to execute 'getRandomValues' on 'Crypto': parameter 1 is not of type 'ArrayBufferView'.

It seems like unfilterEverything doesn't unfilter the ArrayBufferView objects.

Anything I can do to make it work? Right now, I simply use another method to generate random values.

2
  • Are you trying to generate random values? why not to use Math.random() instead? Mar 3, 2017 at 15:26
  • As I said, I am able to use another method to generate random values, but, in LockerService, I expect it to work. Also, sometime we use a library and cannot change the implementation easily. Mar 3, 2017 at 17:05

2 Answers 2

3

Yes, you are correct in that Locker did not properly handle those Objects. This was fixed in the .12 patch, which was released last week. This should be functioning as expected with Locker enabled now.

0
0

Actually, it's happening due to new changes introduced by the Salesforce after enabling the LockerService in your org. LockerService creates it's own custom DOM ("secureDOM") and custom Window object too. Due to custom window object you are likely to see these behaviors of JS.

For more details please refer the following blog. Salesforce blog about LockerService

1
  • 1
    You are right, but what I am referring to is the actual LockerService implementation of the "SecureWindow" (You can check it out here: github.com/forcedotcom/aura/blob/master/aura-impl/src/main/… ) As you can see, it will use the SecureObject.$$unfilterEverything$$ on the function arguments to unpop the "safe" arguments. It should consider ArrayBufferView as a safe argument and unpop it. Mar 4, 2017 at 21:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .