Skip to content

[code_review] Try generating comment inline with the patch #4391

Open
@marco-c

Description

@marco-c

This would allow us to add comments in specific lines of the patch.

The output should be something like:

@@ -8264,13 +8264,24 @@
     return NS_OK;
   }
 
   // Check if the caller is from the same origin as this docshell,
   // or any of its ancestors.
-  nsCOMPtr<nsIDocShellTreeItem> item(this);
+  RefPtr<BrowsingContext> bc(mBrowsingContext);
   do {
-    nsCOMPtr<nsIScriptGlobalObject> sgo = do_GetInterface(item);
+    // If the given BrowsingContex is not in process, then it
+    // is true by construction that its principal will not
+    // subsume the current docshell principal.
+    if (!bc->IsInProcess()) {
+      bc = bc->GetParent();
+      continue;
+    }
+
+    nsCOMPtr<nsIDocShell> docShell(bc->GetDocShell());
+    MOZ_ASSERT(docShell);
COMMENT: Please add an assertion message here.
+
+    nsCOMPtr<nsIScriptGlobalObject> sgo = docShell->GetScriptGlobalObject();
     nsCOMPtr<nsIScriptObjectPrincipal> sop(do_QueryInterface(sgo));
 
     nsIPrincipal* p;
     if (!sop || !(p = sop->GetPrincipal())) {
       return NS_ERROR_UNEXPECTED;

Not sure how to best write the prompt to achieve this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions