Closed Bug 1745819 Opened 5 months ago Closed 2 months ago

Require granted host permission for content scripts in mv3

Categories

(WebExtensions :: General, enhancement, P1)

enhancement
Points:
5

Tracking

(firefox100 fixed)

RESOLVED FIXED
100 Branch
Tracking Status
firefox100 --- fixed

People

(Reporter: zombie, Assigned: zombie)

References

(Blocks 1 open bug)

Details

(Whiteboard: [mv3-m2])

Attachments

(1 file)

  • ⬜ When a content_script pattern matches a document URI, we don’t currently check allowedOrigins. Instead of dynamically changing matchPatterns (probably impossible), check the permission after matching.
  • ⬜ For better testing/code coverage, and since we (currently) add match patterns to allowedOrigins, we can do this universally for mv3 and mv2 extensions at the same time.
  • ⬜ Write new tests for above.
Points: --- → 5
Severity: -- → N/A
Priority: -- → P1
Summary: Require granted host permission for content scripts → Require granted host permission for content scripts in mv3
Assignee: nobody → tomica
Status: NEW → ASSIGNED
Blocks: 1760451

(In reply to Tomislav Jovanovic :zombie from comment #0)

  • ⬜ For better testing/code coverage, and since we (currently) add match patterns to allowedOrigins, we can do this universally for mv3 and mv2 extensions at the same time.

This was incorrect, we never did this for mv2, and only add CS match patterns to optional permissions in mv3 as of bug 1745818.

Depends on: 1760526
Pushed by tjovanovic@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b4f503076020
Require origin permission for content scripts in mv3  r=robwu

Backed out for causing mochitest failures on test_ext_scripting_contentScripts.html.
Affected platforms so far: Android 7.0 x86-64 WebRender debug, Android 7.0 x86-64 Lite WebRender opt, Android 7.0 x86-64 Lite WebRender debug.

Push with failures

Failure log

Backout link

[task 2022-03-25T00:20:58.908Z] 00:20:58     INFO -  TEST-PASS | toolkit/components/extensions/test/mochitest/test_ext_scripting_contentScripts.html | got expected scripts - Expected: [{"id":"script-1","allFrames":false,"matches":["*://test1.example.com/*"],"runAt":"document_idle","persistAcrossSessions":false,"js":["script-1.js"]},{"id":"script-2","allFrames":true,"matches":["*://test1.example.com/*","*://example.org/*"],"runAt":"document_idle","persistAcrossSessions":false,"js":["script-2.js"]},{"id":"script-3","allFrames":true,"matches":["*://test1.example.com/*","*://example.org/*"],"runAt":"document_idle","persistAcrossSessions":false,"excludeMatches":["*://test1.example.com/*"],"js":["script-3.js"]},{"id":"script-4","allFrames":false,"matches":["*://test1.example.com/*"],"runAt":"document_idle","persistAcrossSessions":false,"js":["script-4-1.js","script-4-2.js"]},{"id":"script-5","allFrames":false,"matches":["*://test1.example.com/*"],"runAt":"document_idle","persistAcrossSessions":false,"js":["script-5.js"]}], Actual: [{"id":"script-1","allFrames":false,"matches":["*://test1.example.com/*"],"runAt":"document_idle","persistAcrossSessions":false,"js":["script-1.js"]},{"id":"script-2","allFrames":true,"matches":["*://test1.example.com/*","*://example.org/*"],"runAt":"document_idle","persistAcrossSessions":false,"js":["script-2.js"]},{"id":"script-3","allFrames":true,"matches":["*://test1.example.com/*","*://example.org/*"],"runAt":"document_idle","persistAcrossSessions":false,"excludeMatches":["*://test1.example.com/*"],"js":["script-3.js"]},{"id":"script-4","allFrames":false,"matches":["*://test1.example.com/*"],"runAt":"document_idle","persistAcrossSessions":false,"js":["script-4-1.js","script-4-2.js"]},{"id":"script-5","allFrames":false,"matches":["*://test1.example.com/*"],"runAt":"document_idle","persistAcrossSessions":false,"js":["script-5.js"]}]
[task 2022-03-25T00:20:58.908Z] 00:20:58     INFO -  Buffered messages finished
[task 2022-03-25T00:20:58.909Z] 00:20:58  WARNING -  TEST-UNEXPECTED-FAIL | toolkit/components/extensions/test/mochitest/test_ext_scripting_contentScripts.html | Test timed out. -
[task 2022-03-25T00:20:58.909Z] 00:20:58  WARNING -  TEST-UNEXPECTED-FAIL | toolkit/components/extensions/test/mochitest/test_ext_scripting_contentScripts.html | Extension left running at test shutdown
[task 2022-03-25T00:20:58.909Z] 00:20:58     INFO -      SimpleTest.ok@SimpleTest/SimpleTest.js:417:16
[task 2022-03-25T00:20:58.909Z] 00:20:58     INFO -      ExtensionTestUtils.loadExtension/<@SimpleTest/ExtensionTestUtils.js:133:18
[task 2022-03-25T00:20:58.909Z] 00:20:58     INFO -      executeCleanupFunction@SimpleTest/SimpleTest.js:1487:13
[task 2022-03-25T00:20:58.909Z] 00:20:58     INFO -      SimpleTest.finish@SimpleTest/SimpleTest.js:1501:3
[task 2022-03-25T00:20:58.909Z] 00:20:58     INFO -      killTest@SimpleTest/TestRunner.js:194:22
[task 2022-03-25T00:20:58.909Z] 00:20:58     INFO -      async*delayedKillTest@SimpleTest/TestRunner.js:231:17
[task 2022-03-25T00:20:58.909Z] 00:20:58     INFO -      setTimeout handler*TestRunner._checkForHangs@SimpleTest/TestRunner.js:229:17
[task 2022-03-25T00:20:58.910Z] 00:20:58     INFO -      setTimeout handler*TestRunner._checkForHangs@SimpleTest/TestRunner.js:242:15
[task 2022-03-25T00:20:58.910Z] 00:20:58     INFO -      setTimeout handler*TestRunner._checkForHangs@SimpleTest/TestRunner.js:242:15
[task 2022-03-25T00:20:58.910Z] 00:20:58     INFO -      setTimeout handler*TestRunner._checkForHangs@SimpleTest/TestRunner.js:242:15
[task 2022-03-25T00:20:58.910Z] 00:20:58     INFO -      setTimeout handler*TestRunner._checkForHangs@SimpleTest/TestRunner.js:242:15
[task 2022-03-25T00:20:58.910Z] 00:20:58     INFO -      setTimeout handler*TestRunner._checkForHangs@SimpleTest/TestRunner.js:242:15
[task 2022-03-25T00:20:58.910Z] 00:20:58     INFO -      setTimeout handler*TestRunner._checkForHangs@SimpleTest/TestRunner.js:242:15
[task 2022-03-25T00:20:58.910Z] 00:20:58     INFO -      setTimeout handler*TestRunner._checkForHangs@SimpleTest/TestRunner.js:242:15
[task 2022-03-25T00:20:58.910Z] 00:20:58     INFO -      setTimeout handler*TestRunner._checkForHangs@SimpleTest/TestRunner.js:242:15
[task 2022-03-25T00:20:58.910Z] 00:20:58     INFO -      setTimeout handler*TestRunner._checkForHangs@SimpleTest/TestRunner.js:242:15
[task 2022-03-25T00:20:58.911Z] 00:20:58     INFO -      setTimeout handler*TestRunner._checkForHangs@SimpleTest/TestRunner.js:242:15
[task 2022-03-25T00:20:58.911Z] 00:20:58     INFO -      setTimeout handler*TestRunner._checkForHangs@SimpleTest/TestRunner.js:242:15
[task 2022-03-25T00:20:58.911Z] 00:20:58     INFO -      setTimeout handler*TestRunner._checkForHangs@SimpleTest/TestRunner.js:242:15
[task 2022-03-25T00:20:58.911Z] 00:20:58     INFO -      TestRunner.runTests/<@SimpleTest/TestRunner.js:521:16
[task 2022-03-25T00:20:58.911Z] 00:20:58     INFO -      Async*TestRunner.runTests@SimpleTest/TestRunner.js:508:48
[task 2022-03-25T00:20:58.911Z] 00:20:58     INFO -      RunSet.runtests@SimpleTest/setup.js:232:14
[task 2022-03-25T00:20:58.911Z] 00:20:58     INFO -      RunSet.runall@SimpleTest/setup.js:211:12
[task 2022-03-25T00:20:58.911Z] 00:20:58     INFO -      hookupTests@SimpleTest/setup.js:308:12
[task 2022-03-25T00:20:58.911Z] 00:20:58     INFO -  parseTestManifest@http://mochi.test:8888/manifestLibrary.js:51:13
[task 2022-03-25T00:20:58.911Z] 00:20:58     INFO -  getTestManifest/req.onload@http://mochi.test:8888/manifestLibrary.js:64:28
[task 2022-03-25T00:20:58.912Z] 00:20:58     INFO -  EventHandlerNonNull*getTestManifest@http://mochi.test:8888/manifestLibrary.js:60:3
[task 2022-03-25T00:20:58.912Z] 00:20:58     INFO -      hookup@SimpleTest/setup.js:284:20
[task 2022-03-25T00:20:58.912Z] 00:20:58     INFO -  EventHandlerNonNull*@http://mochi.test:8888/tests?autorun=1&closeWhenDone=1&logFile=%2Fdata%2Flocal%2Ftmp%2Ftest_root%2Flogs%2Fmochitest.log&fileLevel=INFO&consoleLevel=INFO&hideResultsTable=1&manifestFile=tests.json&dumpOutputDirectory=%2Fdata%2Flocal%2Ftmp%2Ftest_root:11:1
[task 2022-03-25T00:20:58.912Z] 00:20:58     INFO -  TEST-OK | toolkit/components/extensions/test/mochitest/test_ext_scripting_contentScripts.html | took 321839ms
[task 2022-03-25T00:20:58.912Z] 00:20:58  WARNING -  TEST-UNEXPECTED-FAIL | /tests/toolkit/components/extensions/test/mochitest/test_ext_scripting_contentScripts.html logged result after SimpleTest.finish(): Extension left running at test shutdown
[task 2022-03-25T00:20:58.912Z] 00:20:58     INFO -  TEST-START | toolkit/components/extensions/test/mochitest/test_ext_scripting_executeScript.html
[task 2022-03-25T00:20:58.913Z] 00:20:58     INFO -  <snipped 9 output lines - if you need more context, please use SimpleTest.requestCompleteLog() in your test>
[task 2022-03-25T00:20:58.913Z] 00:20:58     INFO -  Buffered messages logged at 00:20:55
[task 2022-03-25T00:20:58.913Z] 00:20:58     INFO -  TEST-PASS | toolkit/components/extensions/test/mochitest/test_ext_scripting_executeScript.html | Promise rejected, expecting rejection to match '/Cannot specify both 'allFrames' and 'frameIds'/', got 'Error: Cannot specify both 'allFrames' and 'frameIds'.': expected error when: both allFrames and frameIds are passed
[task 2022-03-25T00:20:58.913Z] 00:20:58     INFO -  TEST-PASS | toolkit/components/extensions/test/mochitest/test_ext_scripting_executeScript.html | Promise rejected, expecting rejection to match '"Invalid frame IDs: [1, 2]."', got 'Error: Invalid frame IDs: [1, 2].': expected error when: invalid IDs in frameIds
[task 2022-03-25T00:20:58.913Z] 00:20:58     INFO -  TEST-PASS | toolkit/components/extensions/test/mochitest/test_ext_scripting_executeScript.html | execute-script
Flags: needinfo?(tomica)
Pushed by tjovanovic@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/cfe47d0d9f1e
Require origin permission for content scripts in mv3  r=robwu

Backed out changeset cfe47d0d9f1e (bug 1745819) for causing build bustages in toolkit/components/extensions/WebExtensionPolicy.cpp

Backout link: https://hg.mozilla.org/integration/autoland/rev/2aae7b3af7ce31292e6854c2b6a75293314b2ace

Push with failures

Failure log

 INFO -  /builds/worker/checkouts/gecko/toolkit/components/extensions/WebExtensionPolicy.cpp: In member function 'bool mozilla::extensions::MozDocumentMatcher::MatchesURI(const mozilla::extensions::URLInfo&) const':
[task 2022-03-25T16:07:11.290Z] 16:07:11    ERROR -  /builds/worker/checkouts/gecko/toolkit/components/extensions/WebExtensionPolicy.cpp:761:27: error: suggest parentheses around '&&' within '||' [-Werror=parentheses]
[task 2022-03-25T16:07:11.290Z] 16:07:11     INFO -     MOZ_ASSERT(!mRestricted && !mCheckPermissions || mExtension);
[task 2022-03-25T16:07:11.290Z] 16:07:11     INFO -                ~~~~~~~~~~~~~^~~~~
[task 2022-03-25T16:07:11.290Z] 16:07:11     INFO -  /builds/worker/workspace/obj-build/dist/include/mozilla/Assertions.h:374:58: note: in definition of macro 'MOZ_VALIDATE_ASSERT_CONDITION_TYPE'
[task 2022-03-25T16:07:11.290Z] 16:07:11     INFO -           mozilla::detail::AssertionConditionType<decltype(x)>::isValid, \
Pushed by tjovanovic@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/42f46da71486
Require origin permission for content scripts in mv3  r=robwu
Flags: needinfo?(tomica)
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 100 Branch
No longer depends on: 1760526
See Also: → 1760526
Regressions: 1761550
See Also: → 1766752
See Also: → 1766822
You need to log in before you can comment on or make changes to this bug.