diff --git a/shell/browser/api/electron_api_browser_view.cc b/shell/browser/api/electron_api_browser_view.cc index 00317909e7..d2cbf2e085 100644 --- a/shell/browser/api/electron_api_browser_view.cc +++ b/shell/browser/api/electron_api_browser_view.cc @@ -192,10 +192,9 @@ v8::Local BrowserView::GetWebContents(v8::Isolate* isolate) { } // static -v8::Local BrowserView::FillObjectTemplate( - v8::Isolate* isolate, - v8::Local templ) { - return gin::ObjectTemplateBuilder(isolate, "BrowserView", templ) +void BrowserView::FillObjectTemplate(v8::Isolate* isolate, + v8::Local templ) { + gin::ObjectTemplateBuilder(isolate, "BrowserView", templ) .SetMethod("setAutoResize", &BrowserView::SetAutoResize) .SetMethod("setBounds", &BrowserView::SetBounds) .SetMethod("getBounds", &BrowserView::GetBounds) diff --git a/shell/browser/api/electron_api_browser_view.h b/shell/browser/api/electron_api_browser_view.h index a0b517c033..f7bcc0584f 100644 --- a/shell/browser/api/electron_api_browser_view.h +++ b/shell/browser/api/electron_api_browser_view.h @@ -44,9 +44,7 @@ class BrowserView : public gin::Wrappable, // gin_helper::Constructible static gin::Handle New(gin_helper::ErrorThrower thrower, gin::Arguments* args); - static v8::Local FillObjectTemplate( - v8::Isolate*, - v8::Local); + static void FillObjectTemplate(v8::Isolate*, v8::Local); // gin::Wrappable static gin::WrapperInfo kWrapperInfo; diff --git a/shell/browser/api/electron_api_menu.cc b/shell/browser/api/electron_api_menu.cc index 1208144c96..798e1ad15a 100644 --- a/shell/browser/api/electron_api_menu.cc +++ b/shell/browser/api/electron_api_menu.cc @@ -266,10 +266,9 @@ void Menu::OnMenuWillShow() { } // static -v8::Local Menu::FillObjectTemplate( - v8::Isolate* isolate, - v8::Local templ) { - return gin::ObjectTemplateBuilder(isolate, "Menu", templ) +void Menu::FillObjectTemplate(v8::Isolate* isolate, + v8::Local templ) { + gin::ObjectTemplateBuilder(isolate, "Menu", templ) .SetMethod("insertItem", &Menu::InsertItemAt) .SetMethod("insertCheckItem", &Menu::InsertCheckItemAt) .SetMethod("insertRadioItem", &Menu::InsertRadioItemAt) diff --git a/shell/browser/api/electron_api_menu.h b/shell/browser/api/electron_api_menu.h index fa30d89d49..d8de583209 100644 --- a/shell/browser/api/electron_api_menu.h +++ b/shell/browser/api/electron_api_menu.h @@ -27,9 +27,7 @@ class Menu : public gin::Wrappable, public: // gin_helper::Constructible static gin::Handle New(gin::Arguments* args); - static v8::Local FillObjectTemplate( - v8::Isolate*, - v8::Local); + static void FillObjectTemplate(v8::Isolate*, v8::Local); // gin::Wrappable static gin::WrapperInfo kWrapperInfo; diff --git a/shell/browser/api/electron_api_notification.cc b/shell/browser/api/electron_api_notification.cc index 6f77147c46..4d0303e969 100644 --- a/shell/browser/api/electron_api_notification.cc +++ b/shell/browser/api/electron_api_notification.cc @@ -253,10 +253,9 @@ bool Notification::IsSupported() { ->GetNotificationPresenter(); } -v8::Local Notification::FillObjectTemplate( - v8::Isolate* isolate, - v8::Local templ) { - return gin::ObjectTemplateBuilder(isolate, "Notification", templ) +void Notification::FillObjectTemplate(v8::Isolate* isolate, + v8::Local templ) { + gin::ObjectTemplateBuilder(isolate, "Notification", templ) .SetMethod("show", &Notification::Show) .SetMethod("close", &Notification::Close) .SetProperty("title", &Notification::GetTitle, &Notification::SetTitle) diff --git a/shell/browser/api/electron_api_notification.h b/shell/browser/api/electron_api_notification.h index bbc35a9a52..854e862833 100644 --- a/shell/browser/api/electron_api_notification.h +++ b/shell/browser/api/electron_api_notification.h @@ -38,9 +38,7 @@ class Notification : public gin::Wrappable, // gin_helper::Constructible static gin::Handle New(gin_helper::ErrorThrower thrower, gin::Arguments* args); - static v8::Local FillObjectTemplate( - v8::Isolate*, - v8::Local); + static void FillObjectTemplate(v8::Isolate*, v8::Local); // NotificationDelegate: void NotificationAction(int index) override; diff --git a/shell/browser/api/electron_api_tray.cc b/shell/browser/api/electron_api_tray.cc index ebc46ae7bf..1c310fe9de 100644 --- a/shell/browser/api/electron_api_tray.cc +++ b/shell/browser/api/electron_api_tray.cc @@ -394,10 +394,9 @@ bool Tray::CheckAlive() { } // static -v8::Local Tray::FillObjectTemplate( - v8::Isolate* isolate, - v8::Local templ) { - return gin::ObjectTemplateBuilder(isolate, "Tray", templ) +void Tray::FillObjectTemplate(v8::Isolate* isolate, + v8::Local templ) { + gin::ObjectTemplateBuilder(isolate, "Tray", templ) .SetMethod("destroy", &Tray::Destroy) .SetMethod("isDestroyed", &Tray::IsDestroyed) .SetMethod("setImage", &Tray::SetImage) diff --git a/shell/browser/api/electron_api_tray.h b/shell/browser/api/electron_api_tray.h index 64cc856df7..ba28862e87 100644 --- a/shell/browser/api/electron_api_tray.h +++ b/shell/browser/api/electron_api_tray.h @@ -45,9 +45,7 @@ class Tray : public gin::Wrappable, v8::Local image, absl::optional guid, gin::Arguments* args); - static v8::Local FillObjectTemplate( - v8::Isolate*, - v8::Local); + static void FillObjectTemplate(v8::Isolate*, v8::Local); // gin::Wrappable static gin::WrapperInfo kWrapperInfo; diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index 51accc979d..2d1ba4599d 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -3941,9 +3941,8 @@ void WebContents::UpdateHtmlApiFullscreen(bool fullscreen) { } // static -v8::Local WebContents::FillObjectTemplate( - v8::Isolate* isolate, - v8::Local templ) { +void WebContents::FillObjectTemplate(v8::Isolate* isolate, + v8::Local templ) { gin::InvokerOptions options; options.holder_is_first_argument = true; options.holder_type = "WebContents"; @@ -3955,7 +3954,7 @@ v8::Local WebContents::FillObjectTemplate( // We use gin_helper::ObjectTemplateBuilder instead of // gin::ObjectTemplateBuilder here to handle the fact that WebContents is // destroyable. - return gin_helper::ObjectTemplateBuilder(isolate, templ) + gin_helper::ObjectTemplateBuilder(isolate, templ) .SetMethod("destroy", &WebContents::Destroy) .SetMethod("close", &WebContents::Close) .SetMethod("getBackgroundThrottling", diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h index 03415966ad..df8901a452 100644 --- a/shell/browser/api/electron_api_web_contents.h +++ b/shell/browser/api/electron_api_web_contents.h @@ -150,9 +150,7 @@ class WebContents : public ExclusiveAccessContext, // gin::Wrappable static gin::WrapperInfo kWrapperInfo; - static v8::Local FillObjectTemplate( - v8::Isolate*, - v8::Local); + static void FillObjectTemplate(v8::Isolate*, v8::Local); const char* GetTypeName() override; void Destroy(); diff --git a/shell/browser/api/electron_api_web_frame_main.cc b/shell/browser/api/electron_api_web_frame_main.cc index 1fbac721bd..7c968dfc32 100644 --- a/shell/browser/api/electron_api_web_frame_main.cc +++ b/shell/browser/api/electron_api_web_frame_main.cc @@ -386,10 +386,9 @@ gin::Handle WebFrameMain::FromOrNull( } // static -v8::Local WebFrameMain::FillObjectTemplate( - v8::Isolate* isolate, - v8::Local templ) { - return gin_helper::ObjectTemplateBuilder(isolate, templ) +void WebFrameMain::FillObjectTemplate(v8::Isolate* isolate, + v8::Local templ) { + gin_helper::ObjectTemplateBuilder(isolate, templ) .SetMethod("executeJavaScript", &WebFrameMain::ExecuteJavaScript) .SetMethod("reload", &WebFrameMain::Reload) .SetMethod("_send", &WebFrameMain::Send) diff --git a/shell/browser/api/electron_api_web_frame_main.h b/shell/browser/api/electron_api_web_frame_main.h index 32e5e351d5..4facae73d9 100644 --- a/shell/browser/api/electron_api_web_frame_main.h +++ b/shell/browser/api/electron_api_web_frame_main.h @@ -53,9 +53,7 @@ class WebFrameMain : public gin::Wrappable, // gin::Wrappable static gin::WrapperInfo kWrapperInfo; - static v8::Local FillObjectTemplate( - v8::Isolate*, - v8::Local); + static void FillObjectTemplate(v8::Isolate*, v8::Local); const char* GetTypeName() override; content::RenderFrameHost* render_frame_host() const { return render_frame_; } diff --git a/shell/common/gin_helper/constructible.h b/shell/common/gin_helper/constructible.h index c6eaaef330..f2ac51c4c2 100644 --- a/shell/common/gin_helper/constructible.h +++ b/shell/common/gin_helper/constructible.h @@ -24,7 +24,7 @@ class EventEmitterMixin; // public gin_helper::Constructible { // public: // static gin::Handle New(...usual gin method arguments...); -// static v8::Local FillObjectTemplate( +// static void FillObjectTemplate( // v8::Isolate*, // v8::Local); // } @@ -55,9 +55,8 @@ class Constructible { } constructor->InstanceTemplate()->SetInternalFieldCount( gin::kNumberOfInternalFields); - v8::Local obj_templ = - T::FillObjectTemplate(isolate, constructor->InstanceTemplate()); - data->SetObjectTemplate(wrapper_info, obj_templ); + T::FillObjectTemplate(isolate, constructor->PrototypeTemplate()); + data->SetObjectTemplate(wrapper_info, constructor->InstanceTemplate()); data->SetFunctionTemplate(wrapper_info, constructor); } return constructor->GetFunction(context).ToLocalChecked(); diff --git a/spec/api-web-frame-main-spec.ts b/spec/api-web-frame-main-spec.ts index 3843302ff4..f666fc5b10 100644 --- a/spec/api-web-frame-main-spec.ts +++ b/spec/api-web-frame-main-spec.ts @@ -177,12 +177,12 @@ describe('webFrameMain module', () => { const w = new BrowserWindow({ show: false }); await w.loadFile(path.join(subframesPath, 'frame.html')); const webFrame = w.webContents.mainFrame; - expect(webFrame).to.have.ownProperty('url').that.is.a('string'); - expect(webFrame).to.have.ownProperty('frameTreeNodeId').that.is.a('number'); - expect(webFrame).to.have.ownProperty('name').that.is.a('string'); - expect(webFrame).to.have.ownProperty('osProcessId').that.is.a('number'); - expect(webFrame).to.have.ownProperty('processId').that.is.a('number'); - expect(webFrame).to.have.ownProperty('routingId').that.is.a('number'); + expect(webFrame).to.have.property('url').that.is.a('string'); + expect(webFrame).to.have.property('frameTreeNodeId').that.is.a('number'); + expect(webFrame).to.have.property('name').that.is.a('string'); + expect(webFrame).to.have.property('osProcessId').that.is.a('number'); + expect(webFrame).to.have.property('processId').that.is.a('number'); + expect(webFrame).to.have.property('routingId').that.is.a('number'); }); }); diff --git a/spec/chromium-spec.ts b/spec/chromium-spec.ts index 658abb089b..6ce63aa285 100644 --- a/spec/chromium-spec.ts +++ b/spec/chromium-spec.ts @@ -2787,7 +2787,7 @@ describe('navigator.hid', () => { let haveDevices = false; let selectFired = false; w.webContents.session.on('select-hid-device', (event, details, callback) => { - expect(details.frame).to.have.ownProperty('frameTreeNodeId').that.is.a('number'); + expect(details.frame).to.have.property('frameTreeNodeId').that.is.a('number'); selectFired = true; if (details.deviceList.length > 0) { haveDevices = true; @@ -2810,7 +2810,7 @@ describe('navigator.hid', () => { w.loadURL(serverUrl); const [,,,,, frameProcessId, frameRoutingId] = await emittedOnce(w.webContents, 'did-frame-navigate'); const frame = webFrameMain.fromId(frameProcessId, frameRoutingId); - expect(frame).to.not.be.empty(); + expect(!!frame).to.be.true(); if (frame) { const grantedDevicesOnNewPage = await frame.executeJavaScript('navigator.hid.getDevices()'); expect(grantedDevicesOnNewPage).to.be.empty(); @@ -2988,7 +2988,7 @@ describe('navigator.usb', () => { let haveDevices = false; let selectFired = false; w.webContents.session.on('select-usb-device', (event, details, callback) => { - expect(details.frame).to.have.ownProperty('frameTreeNodeId').that.is.a('number'); + expect(details.frame).to.have.property('frameTreeNodeId').that.is.a('number'); selectFired = true; if (details.deviceList.length > 0) { haveDevices = true; @@ -3011,7 +3011,7 @@ describe('navigator.usb', () => { w.loadURL(serverUrl); const [,,,,, frameProcessId, frameRoutingId] = await emittedOnce(w.webContents, 'did-frame-navigate'); const frame = webFrameMain.fromId(frameProcessId, frameRoutingId); - expect(frame).to.not.be.empty(); + expect(!!frame).to.be.true(); if (frame) { const grantedDevicesOnNewPage = await frame.executeJavaScript('navigator.usb.getDevices()'); expect(grantedDevicesOnNewPage).to.be.empty();