3 namespace Drupal\Tests\system\Functional\DrupalKernel;
5 use Drupal\Tests\BrowserTestBase;
8 * Tests content negotiation.
12 class ContentNegotiationTest extends BrowserTestBase {
15 * Verifies HTML responses for bogus Accept headers.
17 * Drupal does not fully support older browsers, but a page output is still
20 * @see https://www.drupal.org/node/1716790
22 public function testBogusAcceptHeader() {
24 // See https://bugs.webkit.org/show_bug.cgi?id=27267.
25 'Firefox 3.5 (2009)' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
26 'IE8 (2009)' => 'image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, */*',
27 'Opera (2009)' => 'text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1',
28 'Chrome (2009)' => 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
29 // See https://github.com/symfony/symfony/pull/564.
30 'Firefox 3.6 (2010)' => 'text/html,application/xhtml+xml,application/json,application/xml;q=0.9,*/*;q=0.8',
31 'Safari (2010)' => '*/*',
32 'Opera (2010)' => 'image/jpeg,image/gif,image/x-xbitmap,text/html,image/webp,image/png,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.1',
33 // See https://www.drupal.org/node/1716790.
34 'Safari (2010), iOS 4.2.1 (2012)' => 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
35 'Android #1 (2012)' => 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
36 'Android #2 (2012)' => 'text/xml,text/html,application/xhtml+xml,image/png,text/plain,*/*;q=0.8',
38 foreach ($tests as $case => $header) {
39 $this->drupalGet('', [], ['Accept: ' . $header]);
40 $this->assertNoText('Unsupported Media Type', '"Unsupported Media Type" not found for ' . $case);
41 $this->assertText(t('Log in'), '"Log in" found for ' . $case);