MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / NewWindow3

Method NewWindow3

cpp/iedriver/Browser.cpp:111–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111void __stdcall Browser::NewWindow3(IDispatch** ppDisp,
112 VARIANT_BOOL* pbCancel,
113 DWORD dwFlags,
114 BSTR bstrUrlContext,
115 BSTR bstrUrl) {
116 LOG(TRACE) << "Entering Browser::NewWindow3";
117 ::PostMessage(this->executor_handle(), WD_BEFORE_NEW_WINDOW, NULL, NULL);
118 std::vector<HWND>* ie_window_handles = nullptr;
119 WPARAM param_flag = 0;
120
121 if (this->is_edge_chromium()) {
122 param_flag = 1000;
123 //HWND top_level_handle = this->GetTopLevelWindowHandle();
124 // 1) find all Edge browser window handles
125 std::vector<HWND>edge_window_handles;
126 ::EnumWindows(&BrowserFactory::FindEdgeBrowserHandles,
127 reinterpret_cast<LPARAM>(&edge_window_handles));
128
129 // 2) find all IE browser window handlers as child window when Edge runs in IEMode
130 ie_window_handles = new std::vector<HWND>;
131 for (HWND& edge_window_handle : edge_window_handles) {
132 std::vector<HWND> child_window_handles;
133 ::EnumChildWindows(edge_window_handle,
134 &BrowserFactory::FindIEBrowserHandles,
135 reinterpret_cast<LPARAM>(&child_window_handles));
136
137 for (HWND& child_window_handle : child_window_handles) {
138 ie_window_handles->push_back(child_window_handle);
139 }
140 }
141 } else {
142 // Handle the NewWindow3 event to allow us to immediately hook
143 // the events of the new browser window opened by the user action.
144 // The three ways we can respond to this event are documented at
145 // http://msdn.microsoft.com/en-us/library/aa768337%28v=vs.85%29.aspx
146 // We potentially use two of those response methods.
147 // This will not allow us to handle windows created by the JavaScript
148 // showModalDialog function().
149 std::wstring url = bstrUrl;
150 IWebBrowser2* browser;
151 NewWindowInfo info;
152 info.target_url = StringUtilities::ToString(url);
153 LRESULT create_result = ::SendMessage(this->executor_handle(),
154 WD_BROWSER_NEW_WINDOW,
155 NULL,
156 reinterpret_cast<LPARAM>(&info));
157 if (create_result != 0) {
158 // The new, blank IWebBrowser2 object was not created,
159 // so we can't really do anything appropriate here.
160 // Note this is "response method 2" of the aforementioned
161 // documentation.
162 LOG(WARN) << "A valid IWebBrowser2 object could not be created.";
163 *pbCancel = VARIANT_TRUE;
164 ::PostMessage(this->executor_handle(), WD_AFTER_NEW_WINDOW, NULL, NULL);
165 return;
166 }
167
168 // We received a valid IWebBrowser2 pointer, so deserialize it onto this

Callers

nothing calls this directly

Calls 3

executor_handleMethod · 0.80
is_edge_chromiumMethod · 0.80
LOGClass · 0.50

Tested by

no test coverage detected