Skip to content

Commit

Permalink
Merge pull request #147 from oat-sa/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
poyuki authored Mar 12, 2022
2 parents 73473f6 + 42b06bd commit 107033b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

6.7.1
-----

* `LtiMessage` auto submit script wrapped by `window.onload` callback

6.7.0
-----

Expand Down
5 changes: 4 additions & 1 deletion src/Message/LtiMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ public function toHtmlRedirectForm(bool $autoSubmit = true): string
$formInputs[] = sprintf('<input type="hidden" name="%s" value="%s"/>', $name, $value);
}

$autoSubmitScript = sprintf('<script>document.getElementById("%s").submit();</script>', $formId);
$autoSubmitScript = sprintf(
'<script>window.onload=function(){document.getElementById("%s").submit()}</script>',
$formId
);

return sprintf(
'<form id="%s" action="%s" method="POST">%s</form>%s',
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Message/LtiMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function testToHtmlLink(): void
public function testToHtmlRedirectForm(): void
{
$this->assertEquals(
'<form id="launch_0e7d4b4c23fd7b077aba0602246820ff" action="http://example.com" method="POST"><input type="hidden" name="parameter" value="value"/></form><script>document.getElementById("launch_0e7d4b4c23fd7b077aba0602246820ff").submit();</script>',
'<form id="launch_0e7d4b4c23fd7b077aba0602246820ff" action="http://example.com" method="POST"><input type="hidden" name="parameter" value="value"/></form><script>window.onload=function(){document.getElementById("launch_0e7d4b4c23fd7b077aba0602246820ff").submit()}</script>',
$this->subject->toHtmlRedirectForm()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testAuthenticationSuccessResponse(): void

$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(
'<form id="launch_0e7d4b4c23fd7b077aba0602246820ff" action="http://example.com" method="POST"><input type="hidden" name="parameter" value="value"/></form><script>document.getElementById("launch_0e7d4b4c23fd7b077aba0602246820ff").submit();</script>',
'<form id="launch_0e7d4b4c23fd7b077aba0602246820ff" action="http://example.com" method="POST"><input type="hidden" name="parameter" value="value"/></form><script>window.onload=function(){document.getElementById("launch_0e7d4b4c23fd7b077aba0602246820ff").submit()}</script>',
(string)$response->getBody()
);
}
Expand Down

0 comments on commit 107033b

Please sign in to comment.