Skip to content

Commit 480b0fc

Browse files
committed
Move SSL alerts to BWebWindow
This allows client to overwrite the alert with another handling for SSL errors. DumpRenderTree replaces it by an "always accept" strategy, which allows to run the test suite without constantly clicking the "continue" button for hundreds of requests using a self signed certificate.
1 parent bca2697 commit 480b0fc

File tree

4 files changed

+63
-24
lines changed

4 files changed

+63
-24
lines changed

Source/WebKit/haiku/API/WebViewConstants.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ enum {
5050
MAIN_DOCUMENT_ERROR = 318,
5151
LOAD_STARTED = 319,
5252
RESPONSE_RECEIVED = 320,
53-
ICON_CHANGED = 321
53+
ICON_CHANGED = 321,
54+
SSL_CERT_ERROR = 322
5455
};
5556

5657
enum {

Source/WebKit/haiku/API/WebWindow.cpp

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -246,30 +246,48 @@ void BWebWindow::MessageReceived(BMessage* message)
246246
break;
247247
}
248248
case AUTHENTICATION_CHALLENGE: {
249-
BString text;
250-
bool rememberCredentials = false;
251-
uint32 failureCount = 0;
252-
BString user;
253-
BString password;
249+
BString text;
250+
bool rememberCredentials = false;
251+
uint32 failureCount = 0;
252+
BString user;
253+
BString password;
254254

255-
message->FindString("text", &text);
256-
message->FindString("user", &user);
257-
message->FindString("password", &password);
258-
message->FindUInt32("failureCount", &failureCount);
255+
message->FindString("text", &text);
256+
message->FindString("user", &user);
257+
message->FindString("password", &password);
258+
message->FindUInt32("failureCount", &failureCount);
259259

260260
if (!AuthenticationChallenge(text, user, password, rememberCredentials,
261-
failureCount, _WebViewForMessage(message))) {
262-
message->SendReply((uint32)0);
263-
break;
261+
failureCount, _WebViewForMessage(message))) {
262+
message->SendReply((uint32)0);
263+
break;
264264
}
265265

266-
BMessage reply;
267-
reply.AddString("user", user);
268-
reply.AddString("password", password);
269-
reply.AddBool("rememberCredentials", rememberCredentials);
270-
message->SendReply(&reply);
266+
BMessage reply;
267+
reply.AddString("user", user);
268+
reply.AddString("password", password);
269+
reply.AddBool("rememberCredentials", rememberCredentials);
270+
message->SendReply(&reply);
271271
break;
272272
}
273+
case SSL_CERT_ERROR: {
274+
BString text;
275+
276+
message->FindString("text", &text);
277+
278+
BAlert* alert = new BAlert("Unsecure SSL certificate", text,
279+
"Continue", "Stop", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
280+
// TODO add information about the certificate to the alert
281+
// (in a "details" area or so)
282+
// (but this can be done in WebPositive as well)
283+
284+
int button = alert->Go();
285+
BMessage reply;
286+
reply.AddBool("continue", button == 0);
287+
message->SendReply(&reply);
288+
break;
289+
}
290+
273291

274292
case TOOLBARS_VISIBILITY: {
275293
bool flag;

Source/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,22 +238,27 @@ void FrameLoaderClientHaiku::dispatchDidCancelAuthenticationChallenge(DocumentLo
238238

239239

240240
bool FrameLoaderClientHaiku::dispatchDidReceiveInvalidCertificate(DocumentLoader*,
241-
const CertificateInfo& /*certificate*/, const char* message)
241+
const CertificateInfo& certificate, const char* message)
242242
{
243+
// FIXME use m_messenger as above, so that the alert is generated from the
244+
// API side and can be overriden by clients with a fancier one (or hidden
245+
// completely in case of DumpRenderTree).
243246
String text = "The SSL certificate received from " +
244247
m_webFrame->Frame()->document()->url().string() + " could not be "
245248
"authenticated for the following reason: " + message + ".\n\n"
246249
"The secure connection to the website may be compromised, make sure "
247250
"to not send any sensitive information.";
248251

249-
// TODO add information about the certificate to the alert (in a "details" area or so)
252+
BMessage warningMessage(SSL_CERT_ERROR);
253+
warningMessage.AddString("text", text.utf8().data());
254+
warningMessage.AddPointer("certificate info", &certificate);
250255

251-
BAlert* alert = new BAlert("Unsecure SSL certificate", text.utf8().data(),
252-
"Continue", "Stop", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
256+
BMessage reply;
257+
m_messenger.SendMessage(&warningMessage, &reply);
253258

254-
int button = alert->Go();
259+
bool continueAnyway = reply.FindBool("continue");
255260

256-
return button == 0;
261+
return continueAnyway;
257262
}
258263

259264

Tools/DumpRenderTree/haiku/DumpRenderTree.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,21 @@ class DumpRenderTreeChrome: public BWebWindow
488488
B_NO_BORDER_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, 0)
489489
{
490490
}
491+
492+
void MessageReceived(BMessage* msg)
493+
{
494+
if (msg->what == SSL_CERT_ERROR)
495+
{
496+
// Always accept SSL certificates, since the test suite uses an
497+
// auto-generated one and that would normally produce warnings.
498+
BMessage reply;
499+
reply.AddBool("continue", true);
500+
msg->SendReply(&reply);
501+
return;
502+
}
503+
504+
BWebWindow::MessageReceived(msg);
505+
}
491506
};
492507

493508
void DumpRenderTreeApp::ReadyToRun()

0 commit comments

Comments
 (0)