Closed Bug 1590526 Opened 5 years ago Closed 5 years ago

Temporarily allow node adoption across different docGroups for the content/content case of WebExtensions

Categories

(Core :: XPConnect, enhancement, P1)

enhancement

Tracking

()

VERIFIED FIXED
mozilla72
Tracking Status
firefox71 --- verified
firefox72 --- verified

People

(Reporter: zombie, Assigned: sefeng)

References

Details

(Whiteboard: devrel-note, webext?)

Attachments

(2 files)

+++ This bug was initially created as a clone of Bug #1467970 +++

Basically, reverse the effects of patch in bug 1467970 across docGroups which are both content. I believe this is currently only possible in web extensions, and is already breaking them on Beta 71.

If this was less time sensitive, I would have tried to write the patch myself, but since it would be great to get this uplifted to 71 soon, Sean, could you please take this, or suggest someone else who could?

Flags: needinfo?(sefeng)
Keywords: sec-want
Priority: P2 → P1
Whiteboard: [post-critsmash-triage], devrel-note, webext? → devrel-note, webext?

Yeah, I'll do it, thanks for the bug!

Assignee: nobody → sefeng
Flags: needinfo?(sefeng)
No longer depends on: 1467970

Err, removed dependency by accident, not sure if depends on bug 1467970 is right, but feel free add it back.

(In reply to Sean Feng [:sefeng] from comment #2)

Yeah, I'll do it, thanks for the bug!

Thank you, let me know if you need any help with a test case or anything else.

Finally managed to reproduce and reduce the test case from bug 1576508 comment 25:

let xhr = new XMLHttpRequest();
xhr.responseType = 'document';
xhr.open('GET', chrome.extension.getURL('/blank.html'));

xhr.onload = function() {
    let doc = xhr.response;
    let node = doc.body.cloneNode(true); // original
    // let node = document.adoptNode(doc.body); // this works

    document.body.appendChild(node); // throws with original
    console.log("done");
}
xhr.send();
console.log("sent");

This looks much more innocuous, and probably something that we will still want to keep working. I understand the proper way to do it would be to use document.adoptNode() or .importNode(), but we never enforced that for the web at large, and would also be a surprising exception for web extensions.

I feel this should continue to work similarly to a standard web page XHR with proper CORS permissions.

// let node = document.adoptNode(doc.body); // this works

That is ... really surprising. I would have expected the changes in bug 1467970 would make that explicit adoptNode call throw!

As web extensions rely on this node adoption between content to content
documents, we want to continue allowing this capability to work for now.

(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #5)

// let node = document.adoptNode(doc.body); // this works

That is ... really surprising. I would have expected the changes in bug 1467970 would make that explicit adoptNode call throw!

I'm sorry, I was testing several different configurations across several versions (and fighting cached scripts), so I messed up. The importNode version works in current nightly:

// let node = document.importNode(doc.body, true); // this works

adoptNode throwing would be expected according to changes from bug 1467970, but seems like something that should definitely continue to work for the XHR test case.

Yes, I agree that it should keep working for the XHR testcase, and similar for use of DOMParser.

Pushed by sefeng@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/78c33df33145 Temporarily allow node adoption across different docGroups for the content/content case r=smaug,zombie
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla72

Comment on attachment 9103725 [details]
Bug 1590526 - Temporarily allow node adoption across different docGroups for the content/content case

Beta/Release Uplift Approval Request

  • User impact if declined: End users may experience some extensions stop to work
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: Yes. Unzip the adoptNodeXdocGroup.zip attachment and load it as a temporary addon from about:debugging. Go to example.com, the content of the injected iframe should be bold.
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Medium
  • Why is the change risky/not risky? (and alternatives if risky): Medium, the code itself isn't complex, but it impacts an important feature as extensions.
  • String changes made/needed: None
Attachment #9103725 - Flags: approval-mozilla-beta?
Attached file adoptNodeXdocGroup.zip

Comment on attachment 9103725 [details]
Bug 1590526 - Temporarily allow node adoption across different docGroups for the content/content case

Fix for a P1, with tests, uplift approved for 71 beta 5. let's have QA verify the fix on beta.

Attachment #9103725 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Flags: qe-verify+

Verified fixed using Firefox Nighly 72.0a1 (20191027212548) on Window 10, MacOS 10.15 and Ubuntu 18.04.
I'll be back to verify it on 71.0b5 as well.

(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #8)

Yes, I agree that it should keep working for the XHR testcase, and similar for use of DOMParser.

Right, though I meant the XHR use case should be something we support going forward, even after Fission.

QA Whiteboard: [qa-triaged]

Verified fixed on Firefox Beta 71.0b5 (20191028110005) on Windows 10, MacOS 10.15 and Ubuntu 18.04

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-triaged]
Flags: qe-verify+
See Also: → 1623122
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: