Skip to content

Commit

Permalink
Merge branch 'main' into shane/ntp-translations
Browse files Browse the repository at this point in the history
  • Loading branch information
shakyShane authored Nov 25, 2024
2 parents bf13f73 + 652a7cc commit 83ea26e
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
68 changes: 68 additions & 0 deletions injected/integration-test/data/har/example.com/example.com.har
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"log": {
"version": "1.2",
"creator": {
"name": "Playwright",
"version": "1.48.2"
},
"browser": {
"name": "chromium",
"version": "130.0.6723.31"
},
"entries": [
{
"startedDateTime": "2024-11-24T21:07:22.404Z",
"time": 1.384,
"request": {
"method": "GET",
"url": "http://example.com/",
"httpVersion": "HTTP/1.1",
"cookies": [],
"headers": [
{ "name": "Accept", "value": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7" },
{ "name": "Accept-Encoding", "value": "gzip, deflate" },
{ "name": "Accept-Language", "value": "en-US,en;q=0.9" },
{ "name": "Connection", "value": "keep-alive" },
{ "name": "Host", "value": "example.com" },
{ "name": "Upgrade-Insecure-Requests", "value": "1" },
{ "name": "User-Agent", "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36" }
],
"queryString": [],
"headersSize": -1,
"bodySize": -1
},
"response": {
"status": 200,
"statusText": "OK",
"httpVersion": "HTTP/1.1",
"cookies": [],
"headers": [
{ "name": "Accept-Ranges", "value": "bytes" },
{ "name": "Age", "value": "491759" },
{ "name": "Cache-Control", "value": "max-age=604800" },
{ "name": "Content-Encoding", "value": "gzip" },
{ "name": "Content-Length", "value": "648" },
{ "name": "Content-Type", "value": "text/html; charset=UTF-8" },
{ "name": "Date", "value": "Sun, 24 Nov 2024 21:07:22 GMT" },
{ "name": "Etag", "value": "\"3147526947+gzip\"" },
{ "name": "Expires", "value": "Sun, 01 Dec 2024 21:07:22 GMT" },
{ "name": "Last-Modified", "value": "Thu, 17 Oct 2019 07:18:26 GMT" },
{ "name": "Server", "value": "ECAcc (dcd/7D28)" },
{ "name": "Vary", "value": "Accept-Encoding" },
{ "name": "X-Cache", "value": "HIT" }
],
"content": {
"size": -1,
"mimeType": "text/html; charset=UTF-8",
"text": "<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>\n\n <meta charset=\"utf-8\" />\n <meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <style type=\"text/css\">\n body {\n background-color: #f0f0f2;\n margin: 0;\n padding: 0;\n font-family: -apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n \n }\n div {\n width: 600px;\n margin: 5em auto;\n padding: 2em;\n background-color: #fdfdff;\n border-radius: 0.5em;\n box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);\n }\n a:link, a:visited {\n color: #38488f;\n text-decoration: none;\n }\n @media (max-width: 700px) {\n div {\n margin: 0 auto;\n width: auto;\n }\n }\n </style> \n</head>\n\n<body>\n<div>\n <h1>Example Domain</h1>\n <p>This domain is for use in illustrative examples in documents. You may use this\n domain in literature without prior coordination or asking for permission.</p>\n <p><a href=\"https://www.iana.org/domains/example\">More information...</a></p>\n</div>\n</body>\n</html>\n"
},
"headersSize": -1,
"bodySize": -1,
"redirectURL": ""
},
"cache": {},
"timings": { "send": -1, "wait": -1, "receive": 1.384 }
}
]
}
}
27 changes: 27 additions & 0 deletions injected/integration-test/navigator-interface-insecure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { test, expect } from '@playwright/test';
import { ResultsCollector } from './page-objects/results-collector.js';

const HAR_FILE = 'integration-test/data/har/example.com/example.com.har';
const CONFIG = {
features: {
navigatorInterface: {
state: 'enabled',
exceptions: [],
},
},
unprotectedTemporary: [],
};

test.describe('insecure contexts', () => {
test('should expose navigator.isDuckDuckGo in insecure contexts', async ({ page }, testInfo) => {
const example = ResultsCollector.create(page, testInfo.project.use);
await example.setup({ config: CONFIG, locale: 'en' });
await page.routeFromHAR(HAR_FILE);
await page.goto('http://example.com');

// verify the platform was set
const actual = await page.evaluate('navigator.duckduckgo.platform');
const expected = /** @type {any} */ (testInfo.project.use).platform;
expect(actual).toEqual(expected);
});
});
1 change: 1 addition & 0 deletions injected/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default defineConfig({
name: 'apple',
// prettier-ignore
testMatch: [
'integration-test/navigator-interface-insecure.js',
'integration-test/webcompat.spec.js',
'integration-test/message-bridge-apple.spec.js'
],
Expand Down

0 comments on commit 83ea26e

Please sign in to comment.