bugbug icon indicating copy to clipboard operation
bugbug copied to clipboard

[code_review] Try generating comment inline with the patch

Open marco-c opened this issue 1 year ago • 0 comments

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.

marco-c avatar Aug 02 '24 16:08 marco-c