Skip to content

Commit

Permalink
Bug 1396399: Test for content scripts and activeTab permission.
Browse files Browse the repository at this point in the history
  • Loading branch information
aswan committed Sep 15, 2020
1 parent 69ea94a commit f56339c
Show file tree
Hide file tree
Showing 7 changed files with 419 additions and 0 deletions.
4 changes: 4 additions & 0 deletions testing/specialpowers/content/SpecialPowersChild.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -2141,6 +2141,10 @@ class SpecialPowersChild extends JSWindowActorChild {
sendMessage(...args) {
sp.sendAsyncMessage("SPExtensionMessage", { id, args });
},

grantActiveTab(tabId) {
sp.sendAsyncMessage("SPExtensionGrantActiveTab", { id, tabId });
},
};

this.sendAsyncMessage("SPLoadExtension", { ext, id });
Expand Down
7 changes: 7 additions & 0 deletions testing/specialpowers/content/SpecialPowersParent.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,13 @@ class SpecialPowersParent extends JSWindowActorParent {
return undefined;
}

case "SPExtensionGrantActiveTab": {
let {id, tabId} = aMessage.data;
let {tabManager} = this._extensions.get(id);
tabManager.addActiveTabPermission(tabManager.get(tabId).nativeTab);
return undefined;
}

case "SPUnloadExtension": {
let id = aMessage.data.id;
let extension = this._extensions.get(id);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE HTML>

<html>
<head>
<meta charset="utf-8">
</head>
<body>
<iframe id="emptyframe"></iframe>
<iframe id="regularframe" src="http://test1.example.com/"></iframe>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE HTML>

<html>
<head>
<meta charset="utf-8">
</head>
<body>
<iframe srcdoc="<iframe src='http://test1.example.com/'&gt;</iframe&gt;"></iframe>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE HTML>

<html>
<head>
<meta charset="utf-8">
</head>
<body>
<iframe id="frame" src="http://test2.example.com/"></iframe>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ support-files =
file_WebRequest_page3.html
file_contains_img.html
file_contains_iframe.html
file_contentscript_activeTab.html
file_contentscript_activeTab2.html
file_contentscript_iframe.html
file_image_bad.png
file_image_good.png
file_image_great.png
Expand Down Expand Up @@ -77,6 +80,8 @@ skip-if = os == 'android'
skip-if = headless # Bug 1405872
[test_ext_contentscript_about_blank.html]
skip-if = os == 'android' # bug 1369440
[test_ext_contentscript_activeTab.html]
fail-if = true # Broken by DocumentChannel
[test_ext_contentscript_cache.html]
skip-if = (os == 'linux' && debug) || (toolkit == 'android' && debug) # bug 1348241
fail-if = xorigin # TypeError: can't access property "staticScripts", ext is undefined - Should not throw any errors
Expand Down
Loading

0 comments on commit f56339c

Please sign in to comment.