Skip to content
Snippets Groups Projects

Draft: Resolve #3515520 "Add test coverage"

Open Vijay Mani requested to merge issue/drupal-3515520:3515520-11 into 11.x
2 files
+ 27
0
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -56,6 +56,15 @@ public function buildForm(array $form, FormStateInterface $form_state) {
@@ -56,6 +56,15 @@ public function buildForm(array $form, FormStateInterface $form_state) {
],
],
];
];
 
$form['button_safe'] = [
 
'#type' => 'submit',
 
'#name' => 'make_safe_message',
 
'#value' => 'Make Safe Message',
 
'#ajax' => [
 
'callback' => '::makeSafeMessage',
 
],
 
];
 
return $form;
return $form;
}
}
@@ -109,4 +118,15 @@ public function makeMessageWarning() {
@@ -109,4 +118,15 @@ public function makeMessageWarning() {
]));
]));
}
}
 
/**
 
* Callback for testing MessageCommand safe to XSS.
 
*
 
* @return \Drupal\Core\Ajax\AjaxResponse
 
* The AJAX response.
 
*/
 
public function makeSafeMessage() {
 
$response = new AjaxResponse();
 
return $response->addCommand(new MessageCommand('I am a warning message with script tag. <button onclick="javascript:alert(\'xss\')">Click me!</button>', NULL, ['type' => 'warning', 'announce' => '']));
 
}
 
}
}
Loading