Create array of extension views without side effects

BUG=608104

Review-Url: https://codereview.chromium.org/1935953002
Cr-Commit-Position: refs/heads/master@{#390961}
(cherry picked from commit aa7a889002dd7a1288cc5e962086e517131fb01e)

Review URL: https://codereview.chromium.org/1948773002 .

Cr-Commit-Position: refs/branch-heads/2704@{#362}
Cr-Branched-From: 6e53600def8f60d8c632fadc70d7c1939ccea347-refs/heads/master@{#386251}
diff --git a/extensions/renderer/runtime_custom_bindings.cc b/extensions/renderer/runtime_custom_bindings.cc
index 915abf8..8c6f270 100644
--- a/extensions/renderer/runtime_custom_bindings.cc
+++ b/extensions/renderer/runtime_custom_bindings.cc
@@ -156,6 +156,7 @@
   std::vector<content::RenderFrame*> frames =
       ExtensionFrameHelper::GetExtensionFrames(extension_id, browser_window_id,
                                                view_type);
+  v8::Local<v8::Context> v8_context = args.GetIsolate()->GetCurrentContext();
   v8::Local<v8::Array> v8_views = v8::Array::New(args.GetIsolate());
   int v8_index = 0;
   for (content::RenderFrame* frame : frames) {
@@ -171,7 +172,9 @@
     if (!context.IsEmpty()) {
       v8::Local<v8::Value> window = context->Global();
       DCHECK(!window.IsEmpty());
-      v8_views->Set(v8::Integer::New(args.GetIsolate(), v8_index++), window);
+      v8::Maybe<bool> maybe =
+        v8_views->CreateDataProperty(v8_context, v8_index++, window);
+      DCHECK(maybe.IsJust() && maybe.FromJust());
     }
   }