Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for ad-network-fake-impl to work in Safari #9331

Merged
merged 5 commits into from
Jul 21, 2017

Conversation

aghassemi
Copy link
Contributor

return {
creative: encoder.encode(creative).buffer,
creative: utf8EncodeSync(creative),
signature: 'FAKESIG',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at https://github.com/ampproject/amphtml/blob/master/src/utils/bytes.js#L84 in the case where TextEncoder is defined, utf8EncodeSync(creative) is equivalent to encoder.encode(creative), not encoder.encode(creative).buffer.
If it's easy, e.g. not too many other uses, I'd suggest changing utf8EncodeSync to return .buffer in this case (line 86). But if that would cause problems to unrelated code, then it looks like this code here would have to change to something like foo=utf8EncodeSync(creative); foo = foo.buffer || foo; return { creative:foo, ... }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jonkeller utg8EncodeSync always returns a Uint8Array so just added .buffer back here.

@lannka
Copy link
Contributor

lannka commented Jun 16, 2017

@aghassemi are you still on this?

@aghassemi
Copy link
Contributor Author

oh totally fell through the cracks. Will do the review comment and submit

@aghassemi
Copy link
Contributor Author

@lannka @jonkeller PTAL

@@ -61,9 +59,8 @@ export class AmpAdNetworkFakeImpl extends AmpA4A {
// `localDev` and primarily used for A4A Envelope for testing.
// See DEVELOPING.md for more info.
const creative = this.transformCreativeLocalDev_(deserialized);
const encoder = new TextEncoder('utf-8');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we go ahead and forbid TextEncoder/TextDecoder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@aghassemi aghassemi merged commit d7682ec into ampproject:master Jul 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants