Bug 1549384 - Implement Page.getFrameTree. r=remote-protocol-reviewers,ato
authorAlexandre Poirot <poirot.alex@gmail.com>
Tue, 14 May 2019 09:07:36 +0000
changeset 532579 6d2d415ff8eb6347339a2ac08e3d8fbcfe0322ca
parent 532578 2a529f87452c613b0da7fffa222eeb182ff5c903
child 532580 fe847bf289767657759062cf54d5a93a1f12c6fb
push id11270
push userrgurzau@mozilla.com
push dateWed, 15 May 2019 15:07:19 +0000
treeherdermozilla-beta@571bc76da583 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersremote-protocol-reviewers, ato
bugs1549384
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1549384 - Implement Page.getFrameTree. r=remote-protocol-reviewers,ato Differential Revision: https://phabricator.services.mozilla.com/D30207
remote/domains/content/Page.jsm
remote/test/browser/browser_page_frameNavigated.js
--- a/remote/domains/content/Page.jsm
+++ b/remote/domains/content/Page.jsm
@@ -72,20 +72,25 @@ class Page extends ContentProcessDomain 
     };
   }
 
   async reload() {
     this.docShell.reload(Ci.nsIWebNavigation.LOAD_FLAGS_NONE);
   }
 
   getFrameTree() {
+    const frameId = this.content.windowUtils.outerWindowID;
     return {
       frameTree: {
         frame: {
-          // id, parentId
+          id: frameId,
+          url: this.content.location.href,
+          loaderId: null,
+          securityOrigin: null,
+          mimeType: null,
         },
         childFrames: [],
       },
     };
   }
 
   setLifecycleEventsEnabled() {}
   addScriptToEvaluateOnNewDocument() {}
--- a/remote/test/browser/browser_page_frameNavigated.js
+++ b/remote/test/browser/browser_page_frameNavigated.js
@@ -30,16 +30,22 @@ add_task(async function() {
   ok(true, "CDP client has been instantiated");
 
   const {Page} = client;
 
   // turn on navigation related events, such as DOMContentLoaded et al.
   await Page.enable();
   ok(true, "Page domain has been enabled");
 
+  const { frameTree } = await Page.getFrameTree();
+  ok(!!frameTree.frame, "getFrameTree exposes one frame");
+  is(frameTree.childFrames.length, 0, "getFrameTree reports no child frame");
+  ok(frameTree.frame.id, "getFrameTree's frame has an id");
+  is(frameTree.frame.url, TEST_URI, "getFrameTree's frame has the right url");
+
   // Save the given `promise` resolution into the `promises` global Set
   function recordPromise(name, promise) {
     promise.then(event => {
       ok(true, `Received Page.${name}`);
       resolutions.set(name, event);
     });
     promises.add(promise);
   }
@@ -54,16 +60,18 @@ add_task(async function() {
 
   info("Test Page.navigate");
   recordPromises();
 
   const url = "data:text/html;charset=utf-8,test-page";
   const { frameId } = await Page.navigate({ url });
   ok(true, "A new page has been loaded");
   ok(frameId, "Page.navigate returned a frameId");
+  is(frameId, frameTree.frame.id, "The Page.navigate's frameId is the same than " +
+    "getFrameTree's one");
 
   await assertNavigationEvents({ url, frameId });
 
   info("Test Page.reload");
   recordPromises();
 
   await Page.reload();
   ok(true, "The page has been reloaded");