Skip to content

Commit

Permalink
Merge pull request mozilla#426 from ochameau/bug/751595-fix-test-cont…
Browse files Browse the repository at this point in the history
…ent-symbiont-dead-object

Bug 751595: Simplify badly written test (test-content-symbiont) r=@Gozala
  • Loading branch information
ochameau committed May 3, 2012
2 parents 487eba4 + af6fdbe commit 35cf82a
Showing 1 changed file with 37 additions and 43 deletions.
80 changes: 37 additions & 43 deletions packages/api-utils/tests/test-content-symbiont.js
Expand Up @@ -25,50 +25,44 @@ function makeWindow() {
}

exports['test:constructing symbiont && validating API'] = function(test) {
let window = makeWindow();
window.addEventListener("load", function onLoad() {
window.removeEventListener("load", onLoad, false);
let frame = window.document.getElementById("content");
// TODO: support arrays ??
let contentScripts = ["1;", "2;"];
let contentSymbiont = Symbiont({
frame: frame,
contentScriptFile: self.data.url("test-content-symbiont.js"),
contentScript: contentScripts,
contentScriptWhen: "start"
});

test.assertEqual(
self.data.url("test-content-symbiont.js"),
contentSymbiont.contentScriptFile,
"There is one contentScriptFile, as specified in options."
);
test.assertEqual(
contentScripts.length,
contentSymbiont.contentScript.length,
"There are two contentScripts, as specified in options."
);
test.assertEqual(
contentScripts[0],
contentSymbiont.contentScript[0],
"There are two contentScripts, as specified in options."
);
test.assertEqual(
contentScripts[1],
contentSymbiont.contentScript[1],
"There are two contentScripts, as specified in options."
)
test.assertEqual(
contentSymbiont.contentScriptWhen,
"start",
"contentScriptWhen is as specified in options."
);
let contentScript = ["1;", "2;"];
let contentScriptFile = self.data.url("test-content-symbiont.js");

// We can avoid passing a `frame` argument. Symbiont will create one
// by using HiddenFrame module
let contentSymbiont = Symbiont({
contentScriptFile: contentScriptFile,
contentScript: contentScript,
contentScriptWhen: "start"
});

test.done();
window.close();
frame.setAttribute("src", "data:text/html,<html><body></body></html>");
}, false);
test.waitUntilDone();
test.assertEqual(
contentScriptFile,
contentSymbiont.contentScriptFile,
"There is one contentScriptFile, as specified in options."
);
test.assertEqual(
contentScript.length,
contentSymbiont.contentScript.length,
"There are two contentScripts, as specified in options."
);
test.assertEqual(
contentScript[0],
contentSymbiont.contentScript[0],
"There are two contentScripts, as specified in options."
);
test.assertEqual(
contentScript[1],
contentSymbiont.contentScript[1],
"There are two contentScripts, as specified in options."
)
test.assertEqual(
contentSymbiont.contentScriptWhen,
"start",
"contentScriptWhen is as specified in options."
);

contentSymbiont.destroy();
};

exports["test:communication with worker global scope"] = function(test) {
Expand Down

0 comments on commit 35cf82a

Please sign in to comment.