diff --git a/tests/forms/RequirementsTest.php b/tests/forms/RequirementsTest.php index 71845ada5..8b73a6a61 100644 --- a/tests/forms/RequirementsTest.php +++ b/tests/forms/RequirementsTest.php @@ -264,6 +264,24 @@ class RequirementsTest extends SapphireTest { $backend->assertFileIncluded('css', array($basePath .'/RequirementsTest_b.css', $basePath .'/RequirementsTest_c.css')); Requirements::set_backend($holder); } + + function testJsWriteToBody() { + $backend = new Requirements_Backend(); + $backend->javascript('http://www.mydomain.com/test.js'); + + // Test matching with HTML5
tags as well + $template = '
My header

Body

'; + + $backend->set_write_js_to_body(false); + $html = $backend->includeInHTML(false, $template); + $this->assertContains('set_write_js_to_body(true); + $html = $backend->includeInHTML(false, $template); + $this->assertNotContains('assertContains('', $html); + + } } class RequirementsTest_Backend extends Requirements_Backend implements TestOnly { diff --git a/view/Requirements.php b/view/Requirements.php index 599091a57..30f889bc1 100644 --- a/view/Requirements.php +++ b/view/Requirements.php @@ -645,7 +645,7 @@ class Requirements_Backend { function includeInHTML($templateFile, $content) { if(isset($_GET['debug_profile'])) Profiler::mark("Requirements::includeInHTML"); - if(strpos($content, 'css || $this->javascript || $this->customCSS || $this->customScript || $this->customHeadTags)) { + if((strpos($content, '') !== false || strpos($content, 'css || $this->javascript || $this->customCSS || $this->customScript || $this->customHeadTags)) { $requirements = ''; $jsRequirements = '';