1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 function reportConnected() {
8 var msg
= ['connected'];
9 embedder
.postMessage(JSON
.stringify(msg
), '*');
12 function reportAlertCompletion(messageText
) {
13 window
.alert(messageText
);
14 var msg
= ['alert-dialog-done'];
15 embedder
.postMessage(JSON
.stringify(msg
), '*');
18 function reportConfirmDialogResult(messageText
) {
19 var result
= window
.confirm(messageText
);
20 var msg
= ['confirm-dialog-result', result
];
21 embedder
.postMessage(JSON
.stringify(msg
), '*');
24 function reportPromptDialogResult(messageText
, defaultPromptText
) {
25 var result
= window
.prompt(messageText
, defaultPromptText
);
26 var msg
= ['prompt-dialog-result', result
];
27 embedder
.postMessage(JSON
.stringify(msg
), '*');
30 window
.addEventListener('message', function(e
) {
32 var data
= JSON
.parse(e
.data
);
38 case 'start-confirm-dialog-test': {
39 var messageText
= data
[1];
40 reportConfirmDialogResult(messageText
);
43 case 'start-alert-dialog-test': {
44 var messageText
= data
[1];
45 reportAlertCompletion(messageText
);
48 case 'start-prompt-dialog-test': {
49 var messageText
= data
[1];
50 var defaultPromptText
= data
[2];
51 reportPromptDialogResult(messageText
, defaultPromptText
);