browser_DOMDocElementInserted.js 795 B

12345678910111213141516171819202122232425
  1. // Tests that the DOMDocElementInserted event is visible on the frame
  2. add_task(function*() {
  3. let tab = gBrowser.addTab();
  4. let uri = "data:text/html;charset=utf-8,<html/>"
  5. let eventPromise = ContentTask.spawn(tab.linkedBrowser, null, function() {
  6. Cu.import("resource://gre/modules/PromiseUtils.jsm");
  7. let deferred = PromiseUtils.defer();
  8. let listener = (event) => {
  9. removeEventListener("DOMDocElementInserted", listener, true);
  10. deferred.resolve(event.target.documentURIObject.spec);
  11. };
  12. addEventListener("DOMDocElementInserted", listener, true);
  13. return deferred.promise;
  14. });
  15. tab.linkedBrowser.loadURI(uri);
  16. let loadedURI = yield eventPromise;
  17. is(loadedURI, uri, "Should have seen the event for the right URI");
  18. gBrowser.removeTab(tab);
  19. });