forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing create new window commmand
The W3C WebDriver Specification recently added the ability to create a new top-level browsing context, or what appears to the user to be a new tab or window. This change implements that command. Though the command payload contains a hint argument as to what type of new top- level browsing context the user desires (tab or window), the driver implementation is free to ignore this type hint if it does not support the type being requested. Since the IE driver has never supported, and still does not support, creation of new top-level browsing contexts using a new tab, in accordance with the spec, the driver will create the new context in a new window, even if a new tab is requested. Please note this is not a bug; it is as designed, and is still fully compliant with the specification with this behavior.
- Loading branch information
Showing
16 changed files
with
236 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
cpp/iedriver/CommandHandlers/CreateNewWindowCommandHandler.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "CreateNewWindowCommandHandler.h" | ||
#include "errorcodes.h" | ||
#include "../Browser.h" | ||
#include "../IECommandExecutor.h" | ||
|
||
#define WINDOW_WINDOW_TYPE "window" | ||
#define TAB_WINDOW_TYPE "tab" | ||
|
||
namespace webdriver { | ||
|
||
CreateNewWindowCommandHandler::CreateNewWindowCommandHandler(void) { | ||
} | ||
|
||
CreateNewWindowCommandHandler::~CreateNewWindowCommandHandler(void) { | ||
} | ||
|
||
void CreateNewWindowCommandHandler::ExecuteInternal( | ||
const IECommandExecutor& executor, | ||
const ParametersMap& command_parameters, | ||
Response* response) { | ||
ParametersMap::const_iterator type_parameter_iterator = command_parameters.find("type"); | ||
if (type_parameter_iterator == command_parameters.end()) { | ||
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Missing parameter: type"); | ||
return; | ||
} | ||
if (!type_parameter_iterator->second.isString() && | ||
!type_parameter_iterator->second.isNull()) { | ||
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "type parameter must be a string or null"); | ||
return; | ||
} | ||
|
||
BrowserHandle browser_wrapper; | ||
int status_code = executor.GetCurrentBrowser(&browser_wrapper); | ||
if (status_code != WD_SUCCESS) { | ||
response->SetErrorResponse(ERROR_NO_SUCH_WINDOW, | ||
"Error retrieving current window"); | ||
return; | ||
} | ||
|
||
IECommandExecutor& mutable_executor = const_cast<IECommandExecutor&>(executor); | ||
std::string new_window_handle = mutable_executor.OpenNewBrowserWindow(); | ||
BrowserHandle tmp_browser; | ||
executor.GetManagedBrowser(new_window_handle, &tmp_browser); | ||
tmp_browser->NavigateToUrl("about:blank"); | ||
if (new_window_handle.size() == 0) { | ||
response->SetErrorResponse(ERROR_NO_SUCH_WINDOW, "New window not created"); | ||
return; | ||
} | ||
Json::Value result; | ||
result["handle"] = new_window_handle; | ||
result["type"] = WINDOW_WINDOW_TYPE; | ||
response->SetSuccessResponse(result); | ||
} | ||
|
||
} // namespace webdriver |
37 changes: 37 additions & 0 deletions
37
cpp/iedriver/CommandHandlers/CreateNewWindowCommandHandler.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef WEBDRIVER_IE_CREATENEWWINDOWCOMMANDHANDLER_H_ | ||
#define WEBDRIVER_IE_CREATENEWWINDOWCOMMANDHANDLER_H_ | ||
|
||
#include "../IECommandHandler.h" | ||
|
||
namespace webdriver { | ||
|
||
class CreateNewWindowCommandHandler : public IECommandHandler { | ||
public: | ||
CreateNewWindowCommandHandler(void); | ||
virtual ~CreateNewWindowCommandHandler(void); | ||
|
||
protected: | ||
void ExecuteInternal(const IECommandExecutor& executor, | ||
const ParametersMap& command_parameters, | ||
Response* response); | ||
}; | ||
|
||
} // namespace webdriver | ||
|
||
#endif // WEBDRIVER_IE_CREATENEWWINDOWCOMMANDHANDLER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.