Skip to content

Commit 190cbb4

Browse files
authored
Disable component extensions (#1241)
* Disable component extensions * Fix test
1 parent 57a32a7 commit 190cbb4

File tree

6 files changed

+21
-13
lines changed

6 files changed

+21
-13
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
console.log('hey from the content-script');
2+
self.thisIsTheContentScript = true;
3+
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
// Mock script for background extension
1+
// Mock script for background extension
2+
window.MAGIC = 42;
Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
{
2-
"name": "Simple extension",
3-
"version": "0.1",
4-
"app": {
5-
"background": {
6-
"scripts": ["index.js"]
7-
}
8-
},
9-
"permissions": ["background"],
10-
11-
"manifest_version": 2
12-
}
2+
"name": "Simple extension",
3+
"version": "0.1",
4+
"background": {
5+
"scripts": ["index.js"]
6+
},
7+
"content_scripts": [{
8+
"matches": ["<all_urls>"],
9+
"css": [],
10+
"js": ["content-script.js"]
11+
}],
12+
"permissions": ["background", "activeTab"],
13+
"manifest_version": 2
14+
}

lib/PuppeteerSharp.Tests/PuppeteerTests/HeadfulTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public async Task TargetPageShouldReturnABackgroundPage()
3737
var backgroundPageTarget = await WaitForBackgroundPageTargetAsync(browserWithExtension);
3838
var page = await backgroundPageTarget.PageAsync();
3939
Assert.Equal(6, await page.EvaluateFunctionAsync<int>("() => 2 * 3"));
40+
Assert.Equal(42, await page.EvaluateFunctionAsync<int>("() => window.MAGIC"));
4041
}
4142
}
4243

lib/PuppeteerSharp/ChromiumProcess.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class ChromiumProcess : IDisposable
2727
"--disable-backgrounding-occluded-windows",
2828
"--disable-breakpad",
2929
"--disable-client-side-phishing-detection",
30+
"--disable-component-extensions-with-background-pages",
3031
"--disable-default-apps",
3132
"--disable-dev-shm-usage",
3233
"--disable-extensions",

lib/PuppeteerSharp/Helpers/RemoteObjectHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ internal static object ValueFromRemoteObject<T>(RemoteObject remoteObject)
2323

2424
if (value == null)
2525
{
26-
return null;
26+
return default(T);
2727
}
2828

2929
return typeof(T) == typeof(JToken) ? value : ValueFromType<T>(value, remoteObject.Type);

0 commit comments

Comments
 (0)