Title: [252407] trunk/Source/WebDriver
- Revision
- 252407
- Author
- [email protected]
- Date
- 2019-11-13 06:38:06 -0800 (Wed, 13 Nov 2019)
Log Message
WebDriver: check the frameID parameter before running switch to frame command
https://bugs.webkit.org/show_bug.cgi?id=204150
Reviewed by Carlos Alberto Lopez Perez.
We should check it's either null, a number (unsigned sort) or an object referencing a web element.
Fixes: imported/w3c/webdriver/tests/switch_to_frame/switch.py::test_frame_id_invalid_types[foo]
imported/w3c/webdriver/tests/switch_to_frame/switch.py::test_frame_id_invalid_types[True]
imported/w3c/webdriver/tests/switch_to_frame/switch.py::test_frame_id_invalid_types[value2]
imported/w3c/webdriver/tests/switch_to_frame/switch.py::test_frame_id_invalid_types[value3]
imported/w3c/webdriver/tests/switch_to_frame/switch.py::test_frame_id_out_of_bounds[-1]
imported/w3c/webdriver/tests/switch_to_frame/switch.py::test_frame_id_out_of_bounds[65536]
* Session.cpp:
(WebDriver::Session::switchToFrame): Remove the validation here. Also remove the case of being a frame name,
since that's not in the spec.
* WebDriverService.cpp:
(WebDriver::WebDriverService::switchToFrame): Check frameID type before calling Session::switchToFrame().
Modified Paths
Diff
Modified: trunk/Source/WebDriver/ChangeLog (252406 => 252407)
--- trunk/Source/WebDriver/ChangeLog 2019-11-13 14:27:58 UTC (rev 252406)
+++ trunk/Source/WebDriver/ChangeLog 2019-11-13 14:38:06 UTC (rev 252407)
@@ -1,3 +1,25 @@
+2019-11-13 Carlos Garcia Campos <[email protected]>
+
+ WebDriver: check the frameID parameter before running switch to frame command
+ https://bugs.webkit.org/show_bug.cgi?id=204150
+
+ Reviewed by Carlos Alberto Lopez Perez.
+
+ We should check it's either null, a number (unsigned sort) or an object referencing a web element.
+
+ Fixes: imported/w3c/webdriver/tests/switch_to_frame/switch.py::test_frame_id_invalid_types[foo]
+ imported/w3c/webdriver/tests/switch_to_frame/switch.py::test_frame_id_invalid_types[True]
+ imported/w3c/webdriver/tests/switch_to_frame/switch.py::test_frame_id_invalid_types[value2]
+ imported/w3c/webdriver/tests/switch_to_frame/switch.py::test_frame_id_invalid_types[value3]
+ imported/w3c/webdriver/tests/switch_to_frame/switch.py::test_frame_id_out_of_bounds[-1]
+ imported/w3c/webdriver/tests/switch_to_frame/switch.py::test_frame_id_out_of_bounds[65536]
+
+ * Session.cpp:
+ (WebDriver::Session::switchToFrame): Remove the validation here. Also remove the case of being a frame name,
+ since that's not in the spec.
+ * WebDriverService.cpp:
+ (WebDriver::WebDriverService::switchToFrame): Check frameID type before calling Session::switchToFrame().
+
2019-11-12 Carlos Garcia Campos <[email protected]>
[GTK] WebDriver: implement new window command
Modified: trunk/Source/WebDriver/Session.cpp (252406 => 252407)
--- trunk/Source/WebDriver/Session.cpp 2019-11-13 14:27:58 UTC (rev 252406)
+++ trunk/Source/WebDriver/Session.cpp 2019-11-13 14:38:06 UTC (rev 252407)
@@ -652,23 +652,12 @@
int frameIndex;
if (frameID->asInteger(frameIndex)) {
- if (frameIndex < 0 || frameIndex > USHRT_MAX) {
- completionHandler(CommandResult::fail(CommandResult::ErrorCode::NoSuchFrame));
- return;
- }
+ ASSERT(frameIndex >= 0 && frameIndex < std::numeric_limits<unsigned short>::max());
parameters->setInteger("ordinal"_s, frameIndex);
} else {
String frameElementID = extractElementID(*frameID);
- if (!frameElementID.isEmpty())
- parameters->setString("nodeHandle"_s, frameElementID);
- else {
- String frameName;
- if (!frameID->asString(frameName)) {
- completionHandler(CommandResult::fail(CommandResult::ErrorCode::NoSuchFrame));
- return;
- }
- parameters->setString("name"_s, frameName);
- }
+ ASSERT(!frameElementID.isEmpty());
+ parameters->setString("nodeHandle"_s, frameElementID);
}
m_host->sendCommandToBackend("resolveChildFrameHandle"_s, WTFMove(parameters), [this, protectedThis = protectedThis.copyRef(), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
Modified: trunk/Source/WebDriver/WebDriverService.cpp (252406 => 252407)
--- trunk/Source/WebDriver/WebDriverService.cpp 2019-11-13 14:27:58 UTC (rev 252406)
+++ trunk/Source/WebDriver/WebDriverService.cpp 2019-11-13 14:38:06 UTC (rev 252407)
@@ -1176,6 +1176,32 @@
return;
}
+ switch (frameID->type()) {
+ case JSON::Value::Type::Null:
+ break;
+ case JSON::Value::Type::Double:
+ case JSON::Value::Type::Integer:
+ if (!valueAsNumberInRange(*frameID, 0, std::numeric_limits<unsigned short>::max())) {
+ completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
+ return;
+ }
+ break;
+ case JSON::Value::Type::Object: {
+ RefPtr<JSON::Object> frameIDObject;
+ frameID->asObject(frameIDObject);
+ if (frameIDObject->find(Session::webElementIdentifier()) == frameIDObject->end()) {
+ completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
+ return;
+ }
+ break;
+ }
+ case JSON::Value::Type::Boolean:
+ case JSON::Value::Type::String:
+ case JSON::Value::Type::Array:
+ completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
+ return;
+ }
+
m_session->waitForNavigationToComplete([this, frameID, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
if (result.isError()) {
completionHandler(WTFMove(result));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes