Bug 1260630 - Don't use a CPOW to get data from content in browser_computed_style-editor-link.js. r=bgrins, a=test-only
authorPatrick Brosset <pbrosset@mozilla.com>
Fri, 13 May 2016 12:54:38 +0200
changeset 332937 360e90227281e8675e72db6a1eda64c29a3ee77c
parent 332936 7a3a4f2cd15ac522e45c387d5b0101b5386070cb
child 332938 a737e987dfa7608d47c26d99c27c807172cdd185
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins, test-only
bugs1260630
milestone48.0a2
Bug 1260630 - Don't use a CPOW to get data from content in browser_computed_style-editor-link.js. r=bgrins, a=test-only MozReview-Commit-ID: Jtb6C247ltM
devtools/client/inspector/computed/test/browser_computed_style-editor-link.js
--- a/devtools/client/inspector/computed/test/browser_computed_style-editor-link.js
+++ b/devtools/client/inspector/computed/test/browser_computed_style-editor-link.js
@@ -47,23 +47,23 @@ const DOCUMENT_URL = "data:text/html;cha
    '<p id="closing">more text</p>',
    '<p>even more text</p>',
    '</div>',
    '</body>',
    '</html>'].join("\n"));
 
 add_task(function*() {
   yield addTab(DOCUMENT_URL);
-  let {toolbox, inspector, view} = yield openComputedView();
+  let {toolbox, inspector, view, testActor} = yield openComputedView();
   yield selectNode("span", inspector);
 
   yield testInlineStyle(view);
-  yield testFirstInlineStyleSheet(view, toolbox);
-  yield testSecondInlineStyleSheet(view, toolbox);
-  yield testExternalStyleSheet(view, toolbox);
+  yield testFirstInlineStyleSheet(view, toolbox, testActor);
+  yield testSecondInlineStyleSheet(view, toolbox, testActor);
+  yield testExternalStyleSheet(view, toolbox, testActor);
 });
 
 function* testInlineStyle(view) {
   info("Testing inline style");
 
   yield expandComputedViewPropertyByIndex(view, 0);
 
   let onTab = waitForTab();
@@ -73,73 +73,75 @@ function* testInlineStyle(view) {
   let tab = yield onTab;
 
   let tabURI = tab.linkedBrowser.documentURI.spec;
   ok(tabURI.startsWith("view-source:"), "View source tab is open");
   info("Closing tab");
   gBrowser.removeTab(tab);
 }
 
-function* testFirstInlineStyleSheet(view, toolbox) {
+function* testFirstInlineStyleSheet(view, toolbox, testActor) {
   info("Testing inline stylesheet");
 
   info("Listening for toolbox switch to the styleeditor");
   let onSwitch = waitForStyleEditor(toolbox);
 
   info("Clicking an inline stylesheet");
   clickLinkByIndex(view, 2);
   let editor = yield onSwitch;
 
   ok(true, "Switched to the style-editor panel in the toolbox");
 
-  validateStyleEditorSheet(editor, 0);
+  yield validateStyleEditorSheet(editor, 0, testActor);
 }
 
-function* testSecondInlineStyleSheet(view, toolbox) {
+function* testSecondInlineStyleSheet(view, toolbox, testActor) {
   info("Testing second inline stylesheet");
 
   info("Waiting for the stylesheet editor to be selected");
   let panel = toolbox.getCurrentPanel();
   let onSelected = panel.UI.once("editor-selected");
 
   info("Switching back to the inspector panel in the toolbox");
   yield toolbox.selectTool("inspector");
 
   info("Clicking on second inline stylesheet link");
   clickLinkByIndex(view, 4);
   let editor = yield onSelected;
 
   is(toolbox.currentToolId, "styleeditor",
     "The style editor is selected again");
-  validateStyleEditorSheet(editor, 1);
+  yield validateStyleEditorSheet(editor, 1, testActor);
 }
 
-function* testExternalStyleSheet(view, toolbox) {
+function* testExternalStyleSheet(view, toolbox, testActor) {
   info("Testing external stylesheet");
 
   info("Waiting for the stylesheet editor to be selected");
   let panel = toolbox.getCurrentPanel();
   let onSelected = panel.UI.once("editor-selected");
 
   info("Switching back to the inspector panel in the toolbox");
   yield toolbox.selectTool("inspector");
 
   info("Clicking on an external stylesheet link");
   clickLinkByIndex(view, 1);
   let editor = yield onSelected;
 
   is(toolbox.currentToolId, "styleeditor",
     "The style editor is selected again");
-  validateStyleEditorSheet(editor, 2);
+  yield validateStyleEditorSheet(editor, 2, testActor);
 }
 
-function validateStyleEditorSheet(editor, expectedSheetIndex) {
+function* validateStyleEditorSheet(editor, expectedSheetIndex, testActor) {
   info("Validating style editor stylesheet");
-  let sheet = content.document.styleSheets[expectedSheetIndex];
-  is(editor.styleSheet.href, sheet.href,
+  let expectedHref = yield testActor.eval(`
+    document.styleSheets[${expectedSheetIndex}].href;
+  `);
+  is(editor.styleSheet.href, expectedHref,
     "loaded stylesheet matches document stylesheet");
 }
 
 function clickLinkByIndex(view, index) {
   let link = getComputedViewLinkByIndex(view, index);
   link.scrollIntoView();
   link.click();
 }