Mercurial > hg > isophonics-drupal-site
view core/modules/simpletest/tests/src/FunctionalJavascript/BrowserWithJavascriptTest.php @ 13:5fb285c0d0e3
Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've
been lucky to get away with this so far, as we don't support self-registration
which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5
was vulnerable to.
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:33:26 +0100 |
parents | 4c8ae668cc8c |
children |
line wrap: on
line source
<?php namespace Drupal\Tests\simpletest\FunctionalJavascript; use Drupal\FunctionalJavascriptTests\JavascriptTestBase; /** * Tests if we can execute JavaScript in the browser. * * @group javascript */ class BrowserWithJavascriptTest extends JavascriptTestBase { public function testJavascript() { $this->drupalGet('<front>'); $session = $this->getSession(); $session->resizeWindow(400, 300); $javascript = <<<JS (function(){ var w = window, d = document, e = d.documentElement, g = d.getElementsByTagName('body')[0], x = w.innerWidth || e.clientWidth || g.clientWidth, y = w.innerHeight || e.clientHeight|| g.clientHeight; return x == 400 && y == 300; }()); JS; $this->assertJsCondition($javascript); } public function testAssertJsCondition() { $this->drupalGet('<front>'); $session = $this->getSession(); $session->resizeWindow(500, 300); $javascript = <<<JS (function(){ var w = window, d = document, e = d.documentElement, g = d.getElementsByTagName('body')[0], x = w.innerWidth || e.clientWidth || g.clientWidth, y = w.innerHeight || e.clientHeight|| g.clientHeight; return x == 400 && y == 300; }()); JS; // We expected the following assertion to fail because the window has been // re-sized to have a width of 500 not 400. $this->setExpectedException(\PHPUnit_Framework_AssertionFailedError::class); $this->assertJsCondition($javascript, 100); } /** * Tests creating screenshots. */ public function testCreateScreenshot() { $this->drupalGet('<front>'); $this->createScreenshot('public://screenshot.jpg'); $this->assertFileExists('public://screenshot.jpg'); } }