Bug 820831 - Mochitest changes for contentsScaleFactor on windows; r?jimm
MozReview-Commit-ID: A9Q1rU5Z6WR
--- a/dom/plugins/test/mochitest/mochitest.ini
+++ b/dom/plugins/test/mochitest/mochitest.ini
@@ -119,17 +119,19 @@ support-files =
[test_pluginstream_src.html]
[test_pluginstream_src_dynamic.html]
[test_pluginstream_src_referer.html]
[test_positioning.html]
skip-if = true # disabled due to oddness, perhaps scrolling of the mochitest window?
[test_propertyAndMethod.html]
[test_queryCSSZoomFactor.html]
[test_queryContentsScaleFactor.html]
-skip-if = toolkit != "cocoa"
+skip-if = (toolkit != "cocoa") || (os != "win")
+[test_queryContentsScaleFactorWindowed.html]
+skip-if = (toolkit != "cocoa") || (os != "win")
[test_redirect_handling.html]
[test_secondPlugin.html]
[test_src_url_change.html]
[test_streamatclose.html]
[test_streamNotify.html]
[test_stringHandling.html]
[test_twostreams.html]
[test_visibility.html]
--- a/dom/plugins/test/mochitest/test_queryContentsScaleFactor.html
+++ b/dom/plugins/test/mochitest/test_queryContentsScaleFactor.html
@@ -16,15 +16,16 @@
var exceptionThrown = false;
try {
contentsScaleFactor = pluginElement.queryContentsScaleFactor();
} catch (e) {
exceptionThrown = true;
}
is(exceptionThrown, false, "Exception thrown getting contents scale factor.");
is(isNaN(contentsScaleFactor), false, "Invalid return getting contents scale factor");
+ ok(true, "Got Scale Factor of " + contentsScaleFactor);
SimpleTest.finish();
}
</script>
<embed id="plugin" type="application/x-test" width="400" height="400"></embed>
</body>
</html>
new file mode 100644
--- /dev/null
+++ b/dom/plugins/test/mochitest/test_queryContentsScaleFactorWindowed.html
@@ -0,0 +1,31 @@
+<html>
+<head>
+ <title>NPAPI NPNVcontentsScaleFactor Test</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="utils.js"></script>
+</head>
+
+<body onload="runTests()">
+ <script class="testbody" type="application/javascript">
+ SimpleTest.waitForExplicitFinish();
+ setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+
+ function runTests() {
+ var pluginElement = document.getElementById("plugin");
+ var contentsScaleFactor;
+ var exceptionThrown = false;
+ try {
+ contentsScaleFactor = pluginElement.queryContentsScaleFactor();
+ } catch (e) {
+ exceptionThrown = true;
+ }
+ is(exceptionThrown, false, "Exception thrown getting contents scale factor.");
+ is(isNaN(contentsScaleFactor), false, "Invalid return getting contents scale factor");
+ ok(true, "Got Scale Factor of " + contentsScaleFactor);
+ SimpleTest.finish();
+ }
+ </script>
+
+ <embed id="plugin" type="application/x-test" width="400" height="400" wmode="window"></embed>
+</body>
+</html>
--- a/dom/plugins/test/testplugin/nptest.cpp
+++ b/dom/plugins/test/testplugin/nptest.cpp
@@ -3916,17 +3916,17 @@ bool getMouseUpEventCount(NPObject* npob
}
bool queryContentsScaleFactor(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
{
if (argCount != 0)
return false;
double scaleFactor = 1.0;
-#if defined(XP_MACOSX)
+#if defined(XP_MACOSX) || defined(XP_WIN)
NPError err = NPN_GetValue(static_cast<TestNPObject*>(npobj)->npp,
NPNVcontentsScaleFactor, &scaleFactor);
if (err != NPERR_NO_ERROR) {
return false;
}
#endif
DOUBLE_TO_NPVARIANT(scaleFactor, *result);
return true;